moderncvheadvi.sty 8.0 KB

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