moderncvheadiv.sty 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. %% start of file `moderncvheadiv.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{moderncvheadiv}[2015/07/28 v2.0.0 modern curriculum vitae and letter header variant: 4]
  12. % details options: "details" (default) or "nodetails"
  13. \@initializeif{\if@details}\@detailsfalse
  14. \DeclareOption{details}{\@detailstrue}
  15. \DeclareOption{nodetails}{\@detailsfalse}
  16. \DeclareOption*{}% avoid choking on unknown options
  17. \ExecuteOptions{details}
  18. \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
  19. %-------------------------------------------------------------------------------
  20. % required packages
  21. %-------------------------------------------------------------------------------
  22. % change the layout of the page on the fly, for resume or letter layout
  23. \RequirePackage{changepage}
  24. %-------------------------------------------------------------------------------
  25. % overall head definition
  26. %-------------------------------------------------------------------------------
  27. % fonts
  28. \renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
  29. \renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
  30. \renewcommand*{\addressfont}{\small\mdseries}
  31. \renewcommand*{\quotefont}{\large\itshape}
  32. % styles
  33. \renewcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
  34. \renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
  35. \renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
  36. \renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
  37. %-------------------------------------------------------------------------------
  38. % resume head definition
  39. %-------------------------------------------------------------------------------
  40. % lengths
  41. \@initializelength{\quotewidth}
  42. \setlength{\marginparwidth}{0\p@}
  43. \setlength{\marginparsep}{0\p@}
  44. \renewcommand*{\recomputecvheadlengths}{%
  45. \changepage{}{+\marginparwidth+\marginparsep}{}{}{}{}{}{}{}% if a letter was typeset before the resume, \marginparwidth and \marginparsep will be non-zero; otherwise, this has no effect
  46. \setlength{\marginparwidth}{0\p@}%
  47. \setlength{\marginparsep}{0\p@}%
  48. \setlength{\quotewidth}{0.85\textwidth}}
  49. % commands
  50. \newcommand*{\makecvheadinfo}[1]{% TODO: use \@initializecommand, which requires modifying its definition to handle mandatory and optional arguments
  51. \newbox{\makecvheadinfobox}%
  52. \savebox{\makecvheadinfobox}{\parbox[t]{\hintscolumnwidth}{#1}}%
  53. \newlength{\makecvheadinfoheight}%
  54. \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
  55. \usebox{\makecvheadinfobox}\vspace{-\makecvheadinfoheight}%
  56. % \newlength{\leftcolumnwidth}%
  57. % \setlength{\leftcolumnwidth}{\hintscolumnwidth+\separatorcolumnwidth}%
  58. % \par\vspace{-\baselineskip}\vspace{-\parskip}\leftskip=\leftcolumnwidth%
  59. \par\vspace{-\baselineskip}\vspace{-\parskip}%
  60. \leftskip=\dimexpr\hintscolumnwidth+\separatorcolumnwidth\relax% \dimexpr require e-TeX engine extensions
  61. \recomputecvlengths} % need to recompute the layout lenghts as we just changed \leftskip
  62. \renewcommand*{\makecvhead}{
  63. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  64. \recomputecvlengths%
  65. % optional picture box
  66. \newbox{\makecvheadpicturebox}%
  67. \savebox{\makecvheadpicturebox}{%
  68. \ifthenelse{\isundefined{\@photo}}%
  69. {}%
  70. {%
  71. \color{color1}%
  72. \setlength\fboxrule{\@photoframewidth}%
  73. \ifdim\@photoframewidth=0pt%
  74. \setlength{\fboxsep}{0pt}\fi%
  75. \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
  76. % name and optional title
  77. \newlength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
  78. \newlength{\makecvheadnamewidth}\setlength{\makecvheadnamewidth}{\textwidth-\makecvheadpicturewidth}%
  79. \begin{minipage}[b]{\makecvheadnamewidth}%
  80. \namestyle{\@firstname\ \@lastname}%
  81. \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  82. \end{minipage}%
  83. % optional photo
  84. \usebox{\makecvheadpicturebox}\\[2.5em]%
  85. % optional quote
  86. \ifthenelse{\isundefined{\@quote}}%
  87. {}%
  88. {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  89. % optional details
  90. \if@details%
  91. \makecvheadinfo{%
  92. \addressfont\color{color2}%
  93. \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
  94. \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
  95. \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
  96. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  97. \makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
  98. \ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
  99. \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
  100. \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
  101. \makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
  102. \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}\fi}
  103. %-------------------------------------------------------------------------------
  104. % letter head definition
  105. %-------------------------------------------------------------------------------
  106. % lengths
  107. %\newlength{\textwidthdelta}%
  108. \renewcommand*{\recomputeletterheadlengths}{%
  109. \recomputecvlengths%
  110. % \setlength{\textwidthdelta}{+\marginparwidth+\marginparsep}%
  111. % \addtolength{\textwidthdelta}{-\marginparwidth-\marginparsep}%
  112. % \changepage{}{\textwidthdelta}{-\textwidthdelta}{}{}{}{}{}{}%\changepage{<textheight>}{<textwidth>}{<evensidemargin>}{<oddsidemargin>}{<columnsep>}{<topmargin>}{<headheight>}{<headsep>}{<footskip>}
  113. \setlength{\marginparwidth}{\hintscolumnwidth}%
  114. \setlength{\marginparsep}{2\separatorcolumnwidth}%
  115. \changepage{}{-\marginparwidth-\marginparsep}{}{}{}{}{}{}{}%\changepage{<textheight>}{<textwidth>}{<evensidemargin>}{<oddsidemargin>}{<columnsep>}{<topmargin>}{<headheight>}{<headsep>}{<footskip>}
  116. }
  117. % commands
  118. \renewcommand*{\makeletterhead}{%
  119. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  120. \leftskip=0pt% needs to be set before \recomputeletterlengths
  121. \recomputeletterlengths%
  122. % recipient block
  123. {\addressfont%
  124. {\bfseries\upshape\@recipientname}\\%
  125. \@recipientaddress}\\[1em]%
  126. % date
  127. \@date\\[2em]%
  128. % opening
  129. \@opening\\[1.5em]%
  130. % sender contact info
  131. \if@details%
  132. \hspace{0pt}%
  133. \marginpar{%
  134. \addressfont\textcolor{color2}{%
  135. {\bfseries\@firstname~\@lastname}\@firstdetailselementfalse%
  136. \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
  137. \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
  138. \ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
  139. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  140. \makenewline\hbox to 1.0em{\csname\collectionloopkey phonesymbol\endcsname}~\collectionloopitem}%
  141. \ifthenelse{\isundefined{\@email}}{}{\makenewline\hbox to 1.0em{\emailsymbol}~\emaillink{\@email}}%
  142. \ifthenelse{\isundefined{\@homepage}}{}{\makenewline\hbox to 1.0em{\homepagesymbol}~\httplink{\@homepage}}%
  143. \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
  144. \makenewline\hbox to 1.0em{\csname\collectionloopkey socialsymbol\endcsname}~\collectionloopitem}%
  145. \ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}}}%
  146. % ensure no extra spacing after \makelettertitle due to a possible blank line
  147. %\ignorespacesafterend% not working
  148. \par\vspace{-\baselineskip}\vspace{-\parskip}\fi}
  149. \endinput
  150. %% end of file `moderncvheadiv.sty'.