-
Notifications
You must be signed in to change notification settings - Fork 560
/
moderncvheadiv.sty
171 lines (153 loc) · 8.99 KB
/
moderncvheadiv.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
%% start of file `moderncvheadiv.sty'.
%% Copyright 2006-2015 Xavier Danaux (xdanaux@gmail.com).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.
%-------------------------------------------------------------------------------
% identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvheadiv}[2015/07/28 v2.0.0 modern curriculum vitae and letter header variant: 4]
% details options: "details" (default) or "nodetails"
\@initializeif{\if@details}\@detailsfalse
\DeclareOption{details}{\@detailstrue}
\DeclareOption{nodetails}{\@detailsfalse}
\DeclareOption*{}% avoid choking on unknown options
\ExecuteOptions{details}
\ProcessOptions*\relax% \ProcessOptions* processes the options in the order provided (i.e., with the later ones possibly overriding the former ones), while \ProcessOptions processes them in the order of the package
%-------------------------------------------------------------------------------
% required packages
%-------------------------------------------------------------------------------
% change the layout of the page on the fly, for resume or letter layout
\RequirePackage{changepage}
%-------------------------------------------------------------------------------
% overall head definition
%-------------------------------------------------------------------------------
% fonts
\renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
\renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
\renewcommand*{\addressfont}{\small\mdseries}
\renewcommand*{\quotefont}{\large\itshape}
% styles
\renewcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
\renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
\renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
\renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
%-------------------------------------------------------------------------------
% resume head definition
%-------------------------------------------------------------------------------
% lengths
\@initializelength{\quotewidth}
\@initializelength{\makecvheadnamewidth}% optional makecvheadname width to force a certain width (if set/remains to 0pt, the width is calculated automatically)
\setlength{\marginparwidth}{0\p@}
\setlength{\marginparsep}{0\p@}
\renewcommand*{\recomputecvheadlengths}{%
\changepage{}{+\marginparwidth+\marginparsep}{}{}{}{}{}{}{}% if a letter was typeset before the resume, \marginparwidth and \marginparsep will be non-zero; otherwise, this has no effect
\setlength{\marginparwidth}{0\p@}%
\setlength{\marginparsep}{0\p@}%
\setlength{\quotewidth}{0.85\textwidth}}
% commands
\newcommand*{\makecvheadinfo}[1]{% TODO: use \@initializecommand, which requires modifying its definition to handle mandatory and optional arguments
\newbox{\makecvheadinfobox}%
\savebox{\makecvheadinfobox}{\parbox[t]{\hintscolumnwidth}{#1}}%
\newlength{\makecvheadinfoheight}%
\setlength{\makecvheadinfoheight}{\totalheightof{\usebox{\makecvheadinfobox}}}% the total height of the parbox is the sum of its height (\the\ht\makeinfobox) and its depth (\the\dp\makeinfobox); the \totalheightof command is provided by the "calc" package
\usebox{\makecvheadinfobox}\vspace{-\makecvheadinfoheight}%
% \newlength{\leftcolumnwidth}%
% \setlength{\leftcolumnwidth}{\hintscolumnwidth+\separatorcolumnwidth}%
% \par\vspace{-\baselineskip}\vspace{-\parskip}\leftskip=\leftcolumnwidth%
\par\vspace{-\baselineskip}\vspace{-\parskip}%
\leftskip=\dimexpr\hintscolumnwidth+\separatorcolumnwidth\relax% \dimexpr require e-TeX engine extensions
\recomputecvlengths} % need to recompute the layout lenghts as we just changed \leftskip
\renewcommand*{\makecvhead}{
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional picture box
\newbox{\makecvheadpicturebox}%
\savebox{\makecvheadpicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
\color{color1}%
\setlength\fboxrule{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
% name and optional title
\newlength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
\ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
{\setlength{\makecvheadnamewidth}{\textwidth-\makecvheadpicturewidth}}%
{}%
\begin{minipage}[b]{\makecvheadnamewidth}%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
\end{minipage}%
% optional photo
\usebox{\makecvheadpicturebox}\\[2.5em]%
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
% optional details
\if@details%
\makecvheadinfo{%
\addressfont\color{color2}%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
\ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi}
%-------------------------------------------------------------------------------
% letter head definition
%-------------------------------------------------------------------------------
% lengths
%\newlength{\textwidthdelta}%
\renewcommand*{\recomputeletterheadlengths}{%
\recomputecvlengths%
% \setlength{\textwidthdelta}{+\marginparwidth+\marginparsep}%
% \addtolength{\textwidthdelta}{-\marginparwidth-\marginparsep}%
% \changepage{}{\textwidthdelta}{-\textwidthdelta}{}{}{}{}{}{}%\changepage{<textheight>}{<textwidth>}{<evensidemargin>}{<oddsidemargin>}{<columnsep>}{<topmargin>}{<headheight>}{<headsep>}{<footskip>}
\setlength{\marginparwidth}{\hintscolumnwidth}%
\setlength{\marginparsep}{2\separatorcolumnwidth}%
\changepage{}{-\marginparwidth-\marginparsep}{}{}{}{}{}{}{}%\changepage{<textheight>}{<textwidth>}{<evensidemargin>}{<oddsidemargin>}{<columnsep>}{<topmargin>}{<headheight>}{<headsep>}{<footskip>}
}
% commands
\renewcommand*{\makeletterhead}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\leftskip=0pt% needs to be set before \recomputeletterlengths
\recomputeletterlengths%
% recipient block
{\addressfont%
{\bfseries\upshape\@recipientname}\\%
\@recipientaddress}\\[1em]%
% date
\@date\\[2em]%
% opening
\@opening\\[1.5em]%
% sender contact info
\if@details%
\hspace{0pt}%
\marginpar{%
\addressfont\textcolor{color2}{%
{\bfseries\@firstname~\@lastname}\@firstdetailselementfalse%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
\ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}}%
% ensure no extra spacing after \makelettertitle due to a possible blank line
%\ignorespacesafterend% not working
\par\vspace{-\baselineskip}\vspace{-\parskip}\fi}
\endinput
%% end of file `moderncvheadiv.sty'.