moderncvheadi.sty 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. %% start of file `moderncvheadi.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{moderncvheadi}[2015/07/28 v2.0.0 modern curriculum vitae and letter header variant: 1]
  12. % details options: "details" (default) or "nodetails"
  13. \@initializeif{\if@details}\@detailsfalse
  14. \DeclareOption{details} {\@detailstrue}
  15. \DeclareOption{nodetails} {\@detailsfalse}
  16. % left/right options: "left" (default) or "right"
  17. \@initializeif{\if@left} \@leftfalse
  18. \DeclareOption{left} {\@lefttrue\@rightfalse}
  19. \@initializeif{\if@right}\@rightfalse
  20. \DeclareOption{right} {\@leftfalse\@righttrue}
  21. \DeclareOption*{}% avoid choking on unknown options
  22. \ExecuteOptions{details,left}
  23. \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
  24. %-------------------------------------------------------------------------------
  25. % required packages
  26. %-------------------------------------------------------------------------------
  27. %-------------------------------------------------------------------------------
  28. % overall head definition
  29. %-------------------------------------------------------------------------------
  30. % fonts
  31. \renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
  32. \renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
  33. \renewcommand*{\addressfont}{\small\mdseries\slshape}
  34. \renewcommand*{\quotefont}{\large\slshape}
  35. % styles
  36. \renewcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
  37. \renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
  38. \renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
  39. \renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
  40. %-------------------------------------------------------------------------------
  41. % resume head definition
  42. %-------------------------------------------------------------------------------
  43. % lengths
  44. \@initializelength{\quotewidth}
  45. % optional makecvheadname width to force a certain width (if set/remains to 0pt, the width is calculated automatically)
  46. \@initializelength{\makecvheadnamewidth}
  47. \renewcommand*{\recomputecvheadlengths}{%
  48. \setlength{\quotewidth}{0.65\textwidth}}
  49. % commands
  50. \renewcommand*{\makecvhead}{%
  51. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  52. \recomputecvlengths%
  53. % optional detailed information (pre-rendering)
  54. \@initializebox{\makecvheaddetailsbox}%
  55. \if@details%
  56. \def\phonesdetails{}%
  57. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  58. \protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
  59. \def\socialsdetails{}%
  60. \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
  61. \protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
  62. \savebox{\makecvheaddetailsbox}{%
  63. \addressfont\color{color2}%
  64. \if@left\begin{tabular}[b]{@{}r@{}}\fi%
  65. \if@right\begin{tabular}[b]{@{}l@{}}\fi%
  66. \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
  67. \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
  68. \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
  69. \phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
  70. \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
  71. \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
  72. \socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
  73. \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
  74. \end{tabular}
  75. }\fi%
  76. % optional photo (pre-rendering)
  77. \@initializebox{\makecvheadpicturebox}%
  78. \savebox{\makecvheadpicturebox}{%
  79. \ifthenelse{\isundefined{\@photo}}%
  80. {}%
  81. {%
  82. \if@left%
  83. \hspace*{\separatorcolumnwidth}\fi%
  84. \color{color1}%
  85. \setlength{\fboxrule}{\@photoframewidth}%
  86. \ifdim\@photoframewidth=0pt%
  87. \setlength{\fboxsep}{0pt}\fi%
  88. \framebox{\includegraphics[width=\@photowidth]{\@photo}}}%
  89. \if@right%
  90. \hspace*{\separatorcolumnwidth}\fi}%
  91. % name and title (pre-rendering)
  92. \@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
  93. \@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
  94. \ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
  95. {\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
  96. {}%
  97. \@initializebox{\makecvheadnamebox}%
  98. \savebox{\makecvheadnamebox}{%
  99. \begin{minipage}[b]{\makecvheadnamewidth}%
  100. \if@left\raggedright\fi%
  101. \if@right\raggedleft\fi%
  102. \namestyle{\@firstname\ \@lastname}%
  103. \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  104. \end{minipage}}%
  105. % rendering
  106. \if@left%
  107. \usebox{\makecvheadnamebox}%
  108. \hfill%
  109. \llap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
  110. \usebox{\makecvheadpicturebox}\fi%
  111. \if@right%
  112. \usebox{\makecvheadpicturebox}%
  113. \rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
  114. \hfill%
  115. \usebox{\makecvheadnamebox}\fi%
  116. \\[2.5em]%
  117. % optional quote
  118. \ifthenelse{\isundefined{\@quote}}%
  119. {}%
  120. {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  121. \par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvhead
  122. %-------------------------------------------------------------------------------
  123. % letter head definition
  124. %-------------------------------------------------------------------------------
  125. % lengths
  126. %\renewcommand*{\recomputeletterheadlengths}{}
  127. % commands
  128. \renewcommand*{\makeletterhead}{%
  129. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  130. \recomputeletterlengths%
  131. % sender contact info
  132. \hfill%
  133. \begin{minipage}{.5\textwidth}%
  134. % optional detailed information
  135. \if@details%
  136. \raggedleft%
  137. \addressfont\textcolor{color2}{%
  138. {\bfseries\upshape\@firstname~\@lastname}\@firstdetailselementfalse%
  139. % optional detailed information
  140. \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
  141. \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
  142. \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
  143. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  144. \makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}%
  145. \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
  146. \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
  147. \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi%
  148. \end{minipage}\\[1em]
  149. % recipient block
  150. \begin{minipage}[t]{.5\textwidth}
  151. \raggedright%
  152. \addressfont%
  153. {\bfseries\upshape\@recipientname}\\%
  154. \@recipientaddress%
  155. \end{minipage}
  156. % date
  157. \hfill% US style
  158. % \\[1em]% UK style
  159. \@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  160. % opening
  161. \raggedright%
  162. \@opening\\[1.5em]%
  163. % ensure no extra spacing after \makelettertitle due to a possible blank line
  164. % \ignorespacesafterend% not working
  165. \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
  166. \endinput
  167. %% end of file `moderncvheadi.sty'.