moderncvheadiii.sty 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. %% start of file `moderncvheadiii.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{moderncvheadiii}[2015/07/28 v2.0.0 modern curriculum vitae and letter header variant: 3]
  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. %-------------------------------------------------------------------------------
  23. % overall head definition
  24. %-------------------------------------------------------------------------------
  25. % fonts
  26. \renewcommand*{\namefont}{\Huge\bfseries\upshape}
  27. \renewcommand*{\titlefont}{\Huge\mdseries\upshape}
  28. \renewcommand*{\addressfont}{\normalsize\mdseries\upshape}
  29. \renewcommand*{\quotefont}{\large\slshape}
  30. % styles
  31. \renewcommand*{\namestyle}[1]{{\namefont\textcolor{color1}{#1}}}
  32. \renewcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2!85}{#1}}}
  33. \renewcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
  34. \renewcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
  35. % commands
  36. \@initializecommand{\makeheaddetailssymbol}{%
  37. {~~~{\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
  38. % internal command to add an element to the footer
  39. % it collects the elements in a temporary box, and checks when to flush the box
  40. \@initializebox{\makeheaddetailsbox}%
  41. \@initializebox{\makeheaddetailstempbox}%
  42. \@initializelength{\makeheaddetailswidth}%
  43. \@initializelength{\makeheaddetailsboxwidth}%
  44. \@initializeif{\if@firstmakeheaddetailselement}\@firstmakeheaddetailselementtrue%
  45. % adds an element to the makehead, separated by makeheadsymbol
  46. % usage: \addtomakehead[makeheadsymbol]{element}
  47. \newcommand*{\addtomakeheaddetails}[2][\makeheaddetailssymbol]{% TODO: use \@initializecommand, which requires modifying its definition to handle mandatory and optional arguments
  48. \if@firstmakeheaddetailselement%
  49. \savebox{\makeheaddetailstempbox}{\usebox{\makeheaddetailsbox}#2}%
  50. \else%
  51. \savebox{\makeheaddetailstempbox}{\usebox{\makeheaddetailsbox}#1#2}\fi%
  52. \settowidth{\makeheaddetailsboxwidth}{\usebox{\makeheaddetailstempbox}}%
  53. \ifnum\makeheaddetailsboxwidth<\makeheaddetailswidth%
  54. \savebox{\makeheaddetailsbox}{\usebox{\makeheaddetailstempbox}}%
  55. \@firstmakeheaddetailselementfalse%
  56. \else%
  57. \flushmakeheaddetails\\%
  58. \savebox{\makeheaddetailsbox}{#2}%
  59. \savebox{\makeheaddetailstempbox}{#2}%
  60. \settowidth{\makeheaddetailsboxwidth}{\usebox{\makeheaddetailsbox}}%
  61. \@firstmakeheaddetailselementfalse\fi}
  62. % internal command to flush the makehead
  63. \@initializecommand{\flushmakeheaddetails}{%
  64. \strut\usebox{\makeheaddetailsbox}%
  65. \savebox{\makeheaddetailsbox}{}%
  66. \savebox{\makeheaddetailstempbox}{}%
  67. \setlength{\makeheaddetailsboxwidth}{0pt}}
  68. \@initializecommand{\makehead}{%
  69. \setlength{\makeheaddetailswidth}{0.8\textwidth}%
  70. \hfil%
  71. \parbox{\makeheaddetailswidth}{%
  72. \centering%
  73. % name and title
  74. \namestyle{\@firstname~\@lastname}%
  75. \ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title)
  76. % optional detailed information
  77. \if@details{%
  78. \addressfont\color{color2}%
  79. \ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
  80. \ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
  81. \ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
  82. \flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}%
  83. \collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
  84. \addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
  85. \ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
  86. \ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
  87. \collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
  88. \addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
  89. \ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
  90. \flushmakeheaddetails}\fi}\\[2.5em]}% need to force a \par after this to avoid weird spacing bug at the first section if no blank line is left after \makehead
  91. %-------------------------------------------------------------------------------
  92. % resume head definition
  93. %-------------------------------------------------------------------------------
  94. % lengths
  95. \@initializelength{\quotewidth}
  96. \renewcommand*{\recomputecvheadlengths}{%
  97. \setlength{\quotewidth}{0.65\textwidth}}
  98. % commands
  99. \renewcommand*{\makecvhead}{% TODO: use \@initializecommand, which requires modifying its definition to handle \par
  100. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  101. \recomputecvlengths%
  102. \makehead%
  103. % optional quote
  104. \ifthenelse{\isundefined{\@quote}}%
  105. {}%
  106. {{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  107. \par}% to avoid weird spacing bug at the first section if no blank line is left after \maketitle}
  108. %-------------------------------------------------------------------------------
  109. % letter head definition
  110. %-------------------------------------------------------------------------------
  111. % lengths
  112. %\renewcommand*{\recomputeletterheadlengths}{}
  113. % commands
  114. \renewcommand*{\makeletterhead}{%
  115. % recompute lengths (in case we are switching from letter to resume, or vice versa)
  116. \recomputeletterlengths%
  117. % sender block
  118. \makehead%
  119. \par%
  120. % recipient block
  121. \begin{minipage}[t]{.5\textwidth}
  122. \raggedright%
  123. \addressfont%
  124. {\bfseries\upshape\@recipientname}\\%
  125. \@recipientaddress%
  126. \end{minipage}
  127. % date
  128. \hfill% US style
  129. % \\[1em]% UK style
  130. \@date\\[2em]% US informal style: "January 1, 1900"; UK formal style: "01/01/1900"
  131. % opening
  132. \raggedright%
  133. \@opening\\[1.5em]%
  134. % ensure no extra spacing after \makelettertitle due to a possible blank line
  135. % \ignorespacesafterend% not working
  136. \hspace{0pt}\par\vspace{-\baselineskip}\vspace{-\parskip}}
  137. \endinput
  138. %% end of file `moderncvheadiii.sty'.