moderncvheadii.sty 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. %% start of file `moderncvheadii.sty'.
  2. %% Copyright 2006-2015 Xavier Danaux (xdanaux@gmail.com).
  3. %
  4. % This work may be distributed and/or modified under the
  5. % conditions of the LaTeX Project Public License version 1.3c,
  6. % available at http://www.latex-project.org/lppl/.
  7. %-------------------------------------------------------------------------------
  8. % identification
  9. %-------------------------------------------------------------------------------
  10. \NeedsTeXFormat{LaTeX2e}
  11. \ProvidesPackage{moderncvheadii}[2015/07/28 v2.0.0 modern curriculum vitae and letter header variant: 2]
  12. % details options: "details" or "nodetails" (default)
  13. \@initializeif{\if@details}\@detailsfalse
  14. \DeclareOption{details}{\@detailstrue}
  15. \DeclareOption{nodetails}{\@detailsfalse}
  16. % name design options: "alternate" (lowercase names & title, no spacing)
  17. \@initializeif{\if@alternate}\@alternatefalse
  18. \DeclareOption{alternate}{\@alternatetrue}
  19. % left/right options: "left" or "right" (default)
  20. \@initializeif{\if@left} \@leftfalse
  21. \DeclareOption{left} {\@lefttrue\@rightfalse}
  22. \@initializeif{\if@right}\@rightfalse
  23. \DeclareOption{right} {\@leftfalse\@righttrue}
  24. \DeclareOption*{}% avoid choking on unknown options
  25. \ExecuteOptions{nodetails,right}
  26. \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
  27. %-------------------------------------------------------------------------------
  28. % required packages
  29. %-------------------------------------------------------------------------------
  30. %-------------------------------------------------------------------------------
  31. % overall head definition
  32. %-------------------------------------------------------------------------------
  33. % fonts
  34. \renewcommand*{\namefont}{\fontsize{38}{40}\mdseries\upshape}
  35. \renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
  36. \renewcommand*{\addressfont}{\normalsize\mdseries\slshape}
  37. \renewcommand*{\quotefont}{\large\slshape}
  38. % styles
  39. \renewcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
  40. \renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
  41. \renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
  42. \renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
  43. % commands
  44. \@initializecommand{\makeheaddetailssymbol}{%
  45. {~~~{\rmfamily\textbullet}~~~}}% the \rmfamily is required to force Latin Modern fonts when using sans serif, as OMS/lmss/m/n is not defined and gets substituted by OMS/cmsy/m/n
  46. % internal command to add an element to the footer
  47. % it collects the elements in a temporary box, and checks when to flush the box
  48. \@initializebox{\makeheaddetailsbox}%
  49. \@initializebox{\makeheaddetailstempbox}%
  50. \@initializelength{\makeheaddetailswidth}%
  51. \@initializelength{\makeheaddetailsboxwidth}%
  52. \@initializeif{\if@firstmakeheaddetailselement}\@firstmakeheaddetailselementtrue%
  53. % adds an element to the makehead, separated by makeheadsymbol
  54. % usage: \addtomakehead[makeheadsymbol]{element}
  55. \newcommand*{\addtomakeheaddetails}[2][\makeheaddetailssymbol]{% TODO: use \@initializecommand, which requires modifying its definition to handle mandatory and optional arguments
  56. \if@firstmakeheaddetailselement%
  57. \savebox{\makeheaddetailstempbox}{\usebox{\makeheaddetailsbox}#2}%
  58. \else%
  59. \savebox{\makeheaddetailstempbox}{\usebox{\makeheaddetailsbox}#1#2}\fi%
  60. \settowidth{\makeheaddetailsboxwidth}{\usebox{\makeheaddetailstempbox}}%
  61. \ifnum\makeheaddetailsboxwidth<\makeheaddetailswidth%
  62. \savebox{\makeheaddetailsbox}{\usebox{\makeheaddetailstempbox}}%
  63. \@firstmakeheaddetailselementfalse%
  64. \else%
  65. \flushmakeheaddetails\\\null% \null is required as there is no box on the line after \\, so glue such as \hfill (and leaders) disappear; this is in contrast to after \par, where the next line starts with an indent box (even after \noindent)
  66. \savebox{\makeheaddetailsbox}{#2}%
  67. \savebox{\makeheaddetailstempbox}{#2}%
  68. \settowidth{\makeheaddetailsboxwidth}{\usebox{\makeheaddetailsbox}}%
  69. \@firstmakeheaddetailselementfalse\fi}
  70. % internal command to flush the makehead
  71. \@initializecommand{\flushmakeheaddetails}{%
  72. \if@right\hfill\fi%
  73. \strut\usebox{\makeheaddetailsbox}%
  74. \savebox{\makeheaddetailsbox}{}%
  75. \savebox{\makeheaddetailstempbox}{}%
  76. \setlength{\makeheaddetailsboxwidth}{0pt}}
  77. %-------------------------------------------------------------------------------
  78. % resume head definition
  79. %-------------------------------------------------------------------------------
  80. % lengths
  81. \@initializelength{\quotewidth}
  82. % optional makecvheadname width to force a certain width (if set/remains to 0pt, the width is calculated automatically)
  83. \@initializelength{\makecvheadnamewidth}
  84. \renewcommand*{\recomputecvheadlengths}{%
  85. \setlength{\makeheaddetailswidth}{\textwidth}%
  86. \setlength{\quotewidth}{0.65\textwidth}}
  87. % commands
  88. \renewcommand*{\makecvhead}{% TODO: use \@initializecommand, which requires modifying its definition to handle \par
  89. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  90. \recomputecvlengths%
  91. % optional picture (pre-rendering)
  92. \@initializebox{\makecvheadpicturebox}%
  93. \savebox{\makecvheadpicturebox}{%
  94. \ifthenelse{\isundefined{\@photo}}%
  95. {}%
  96. {%
  97. \setlength\fboxrule{\@photoframewidth}%
  98. \ifdim\@photoframewidth=0pt%
  99. \setlength{\fboxsep}{0pt}\fi%
  100. {\color{color1}\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}}%
  101. % name (pre-rendering)
  102. \@initializelength{\makecvheadpicturewidth}%
  103. \settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
  104. \@initializebox{\makecvheadnamebox}%
  105. \savebox{\makecvheadnamebox}{%
  106. \parbox[b]{\textwidth-\makecvheadpicturewidth}{%
  107. \if@left\raggedright\fi%
  108. \if@right\raggedleft\fi%
  109. \namefont%
  110. \if@alternate% alternate design: first- and lastname in lowercase with no space in between (distinction is made by color difference)
  111. {\color{color2!50}\MakeLowercase\@firstname}{\color{color2}\MakeLowercase\@lastname}%
  112. \else% default design: first- and lastname as given with a space in between
  113. {\color{color2!50}\@firstname} {\color{color2}\@lastname}\fi}}%
  114. % rendering
  115. \if@left%
  116. \usebox{\makecvheadnamebox}%
  117. \usebox{\makecvheadpicturebox}\fi
  118. \if@right%
  119. \usebox{\makecvheadpicturebox}%
  120. \usebox{\makecvheadnamebox}\fi\\[-.35em]%
  121. {\color{color2!50}\rule{\textwidth}{.25ex}}%
  122. % optional detailed information
  123. \if@details{%
  124. \\\null%
  125. \addressfont\color{color2}%
  126. \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
  127. \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
  128. \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
  129. \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
  130. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  131. \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
  132. \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
  133. \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
  134. \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
  135. \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
  136. \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
  137. \flushmakeheaddetails}\fi% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
  138. % optional title
  139. \ifthenelse{\equal{\@title}{}}{}{%
  140. \\[1.25em]\null% \null is required as there is no box on the line after \\, so glue such as \hfill (and leaders) disappear; this is in contrast to after \par, where the next line starts with an indent box (even after \noindent)
  141. \if@right\hfill\fi%
  142. \if@alternate%
  143. \titlestyle{\MakeLowercase\@title}%
  144. \else%
  145. \titlestyle{\@title}\fi%
  146. }\\[2.5em]%
  147. % optional quote
  148. \ifthenelse{\isundefined{\@quote}}%
  149. {}%
  150. {{\null\hfill%
  151. \begin{minipage}{\quotewidth}%
  152. \centering%
  153. \quotestyle{\@quote}%
  154. \end{minipage}\hfill\null\\[2.5em]}}%
  155. \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle
  156. %-------------------------------------------------------------------------------
  157. % letter head definition
  158. %-------------------------------------------------------------------------------
  159. % lengths
  160. %\renewcommand*{\recomputeletterheadlengths}{}
  161. % commands
  162. \renewcommand*{\makeletterhead}{%
  163. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  164. \recomputeletterlengths%
  165. % recipient block
  166. \begin{minipage}[t]{.5\textwidth}
  167. \raggedright%
  168. \addressfont%
  169. {\bfseries\upshape\@recipientname}\\%
  170. \@recipientaddress%
  171. \end{minipage}
  172. % date
  173. \hfill% US style
  174. % \\[1em]% UK style
  175. \@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  176. % opening
  177. \raggedright%
  178. \@opening\\[1.5em]%
  179. % ensure no extra spacing after \makelettertitle due to a possible blank line
  180. % \ignorespacesafterend% not working
  181. \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
  182. \endinput
  183. %% end of file `moderncvheadii.sty'.