moderncvbodyv.sty 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. %% start of file `moderncvbodyv.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{moderncvbodyv}[2015/07/28 v2.0.0 modern curriculum vitae and letter body variant: 5]
  12. %-------------------------------------------------------------------------------
  13. % required packages
  14. %-------------------------------------------------------------------------------
  15. %-------------------------------------------------------------------------------
  16. % overall style definition
  17. %-------------------------------------------------------------------------------
  18. %-------------------------------------------------------------------------------
  19. % resume style definition
  20. %-------------------------------------------------------------------------------
  21. % fonts
  22. \renewcommand*{\sectionfont}{\Large\mdseries\upshape}
  23. \renewcommand*{\subsectionfont}{\large\mdseries\slshape}
  24. \renewcommand*{\hintfont}{\bfseries}
  25. % styles
  26. \renewcommand*{\sectionstyle}[1]{{\sectionfont\textcolor{color1}{#1}}}
  27. \renewcommand*{\subsectionstyle}[1]{{\subsectionfont\textcolor{color1}{#1}}}
  28. \renewcommand*{\hintstyle}[1]{{\hintfont\textcolor{color0}{#1}}}
  29. % lengths
  30. % used by \cvitem (and all children command)
  31. \@initializelength{\hintscolumnwidth} \setlength{\hintscolumnwidth}{0.25\textwidth}
  32. \@initializelength{\separatorcolumnwidth} \setlength{\separatorcolumnwidth}{0.025\textwidth}
  33. \@initializelength{\separatorrulewidth} \setlength{\separatorrulewidth}{1.2\p@}%
  34. \@initializelength{\maincolumnwidth}
  35. % used by \cvdoubleitem
  36. \@initializelength{\doubleitemcolumnwidth}
  37. % used by \cvlistitem
  38. \@initializelength{\listitemsymbolwidth} \settowidth{\listitemsymbolwidth}{\listitemsymbol}
  39. \@initializelength{\listitemcolumnwidth}
  40. %\@initializelength{\listitemmaincolumnwidth}
  41. % used by \cvlistdoubleitem
  42. \@initializelength{\listdoubleitemcolumnwidth}
  43. %\@initializelength{\listdoubleitemmaincolumnwidth}
  44. % commands
  45. \@initializecommand{\recomputecvbodylengths}{%
  46. % body lengths
  47. \setlength{\maincolumnwidth}{\textwidth-\leftskip-\rightskip-\separatorcolumnwidth-\separatorcolumnwidth-\hintscolumnwidth-\separatorrulewidth}%
  48. \setlength{\listitemcolumnwidth}{\maincolumnwidth-\listitemsymbolwidth}%
  49. \setlength{\doubleitemcolumnwidth}{\maincolumnwidth-\separatorcolumnwidth}%
  50. \setlength{\doubleitemcolumnwidth}{0.5\doubleitemcolumnwidth}%
  51. \setlength{\listdoubleitemcolumnwidth}{\maincolumnwidth-\listitemsymbolwidth-\separatorcolumnwidth-\listitemsymbolwidth}%
  52. \setlength{\listdoubleitemcolumnwidth}{0.5\listdoubleitemcolumnwidth}%
  53. % regular lengths
  54. \setlength{\parskip}{0\p@}}
  55. \@initializeif{\if@aftersection}\@aftersectionfalse%
  56. \RenewDocumentCommand{\section}{sm}{%
  57. \addvspace{2.5ex}%
  58. \phantomsection{}% reset the anchor for hyperrefs
  59. \addcontentsline{toc}{section}{#2}%
  60. \noindent\rlap{\@cvitem{\raggedleft\sectionstyle{#2}}{}}%
  61. \nobreak\@afterheading\@aftersectiontrue\ignorespaces}
  62. %\@initializeif{\if@aftersubsection}\@aftersubsectionfalse%
  63. \RenewDocumentCommand{\subsection}{sm}{%
  64. %\addvspace{1ex}%
  65. \vspace*{-\arrayrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
  66. \if@aftersection%
  67. \par\ignorespaces\fi%
  68. \phantomsection{}% reset the anchor for hyperrefs
  69. \addcontentsline{toc}{subsection}{#2}%
  70. \noindent\rlap{\@cvitem{\if@aftersection\else\@moderncvstrut{4pt}{24pt}\fi\raggedleft\subsectionstyle{#2}}{}}%
  71. \nobreak\@afterheading\@aftersectiontrue\ignorespaces}
  72. \renewcommand*{\cvitem}[3][.5ex]{%
  73. \@cvitem[#1]{}{\ifthenelse{\equal{#2}{}}{}{\hintstyle{#2}: }{#3}}}
  74. % underlying command to implement \cvitem, \subsection and \section
  75. \newcommand*{\@cvitem}[3][.5ex]{%
  76. \arrayrulecolor{color1}%
  77. \setlength\arrayrulewidth{\separatorrulewidth}%
  78. \if@aftersection\else%
  79. \vspace*{-\separatorrulewidth}\fi% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
  80. \noindent%
  81. % \setlength{\fboxsep}{0pt}\framebox{% start of debuging
  82. \begin{tabular}[t]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
  83. \@moderncvstrut{4pt}{16pt}#2 &#3\\[#1]% the spacing needs to be inside the cell for the vertical rule to extend correctly
  84. \end{tabular}%
  85. % }% end of debuging
  86. \par\@aftersectionfalse\ignorespaces}
  87. \renewcommand*{\cvdoubleitem}[5][.5ex]{%
  88. \@cvitem[#1]{}{%
  89. \begin{minipage}[t]{\doubleitemcolumnwidth}\hintstyle{#2}: #3\end{minipage}%
  90. \hfill% fill of \separatorcolumnwidth
  91. \begin{minipage}[t]{\doubleitemcolumnwidth}\ifthenelse{\equal{#4}{}}{}{\hintstyle{#4}: }#5\end{minipage}}}
  92. \renewcommand*{\cvlistitem}[2][.5ex]{%
  93. \@cvitem[#1]{}{\listitemsymbol\begin{minipage}[t]{\listitemcolumnwidth}#2\end{minipage}}}
  94. \renewcommand*{\cvlistdoubleitem}[3][.5ex]{%
  95. \@cvitem[#1]{}{\listitemsymbol\begin{minipage}[t]{\listdoubleitemcolumnwidth}#2\end{minipage}%
  96. \hfill% fill of \separatorcolumnwidth
  97. \ifthenelse{\equal{#3}{}}%
  98. {}%
  99. {\listitemsymbol\begin{minipage}[t]{\listdoubleitemcolumnwidth}#3\end{minipage}}}}
  100. \@initializebox{\cventryyearbox}
  101. \@initializelength{\cventrytitleboxwidth}
  102. \renewcommand*{\cventry}[7][.5ex]{%
  103. \savebox{\cventryyearbox}{%
  104. \hspace*{2\separatorcolumnwidth}%
  105. \hintstyle{#2}}%
  106. \setlength{\cventrytitleboxwidth}{\widthof{\usebox{\cventryyearbox}}}%
  107. \setlength{\cventrytitleboxwidth}{\maincolumnwidth-\cventrytitleboxwidth}%
  108. \cvitem[#1]{}{%
  109. \parbox[t]{\cventrytitleboxwidth}{%
  110. \strut%
  111. {\bfseries#3}%
  112. \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
  113. \ifthenelse{\equal{#5}{}}{}{, #5}%
  114. \ifthenelse{\equal{#6}{}}{}{, #6}%
  115. .\strut}%
  116. \usebox{\cventryyearbox}}%
  117. \ifx&#7&%
  118. \else%
  119. \vspace*{-4pt}%
  120. \cvitem[#1]{}{\small#7}\fi}
  121. \@initializebox{\cvitemwithcommentmainbox}
  122. \@initializelength{\cvitemwithcommentmainlength}
  123. \@initializelength{\cvitemwithcommentcommentlength}
  124. \renewcommand*{\cvitemwithcomment}[4][.5ex]{%
  125. \savebox{\cvitemwithcommentmainbox}{\ifthenelse{\equal{#2}{}}{}{\hintstyle{#2}: }#3}%
  126. \setlength{\cvitemwithcommentmainlength}{\widthof{\usebox{\cvitemwithcommentmainbox}}}%
  127. \setlength{\cvitemwithcommentcommentlength}{\maincolumnwidth-\separatorcolumnwidth-\cvitemwithcommentmainlength}%
  128. \@cvitem[#1]{}{%
  129. \begin{minipage}[t]{\cvitemwithcommentmainlength}\usebox{\cvitemwithcommentmainbox}\end{minipage}%
  130. \hfill% fill of \separatorcolumnwidth
  131. \begin{minipage}[t]{\cvitemwithcommentcommentlength}\raggedleft\small\itshape#4\end{minipage}}}
  132. \renewenvironment{thebibliography}[1]% BUG/TODO: remove extra space between heading and first bibliography entry, as well as after last one
  133. {%
  134. \bibliographyhead{\refname}%
  135. % \small%
  136. \arrayrulecolor{color1}%
  137. \setlength\arrayrulewidth{\separatorrulewidth}%
  138. \noindent%
  139. \begin{tabular}[t]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}|@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
  140. \@moderncvstrut{4pt}{16pt} &%
  141. \begin{list}{\bibliographyitemlabel}{%
  142. \setlength{\topsep}{0pt}%
  143. \setlength{\partopsep}{0pt}%
  144. \setlength{\labelwidth}{0pt}%
  145. \setlength{\itemsep}{0pt}%
  146. \setlength{\parskip}{0pt}%
  147. \ifthenelse{\equal{\bibliographyitemlabel}{}}%
  148. {\setlength{\labelsep}{0pt}}%
  149. {\setlength{\labelsep}{\separatorcolumnwidth}}%
  150. \leftmargin\labelwidth%
  151. \advance\leftmargin\labelsep%
  152. \@openbib@code%
  153. \usecounter{enumiv}%
  154. \let\p@enumiv\@empty%
  155. \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  156. \sloppy%
  157. \clubpenalty4000%\@clubpenalty \clubpenalty%
  158. \widowpenalty4000%
  159. \sfcode`\.\@m%
  160. \sfcode `\=1000\relax}%
  161. {%
  162. \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
  163. \end{list}%
  164. \\[.5ex]%
  165. \end{tabular}%
  166. \par\@aftersectionfalse\ignorespaces}
  167. %-------------------------------------------------------------------------------
  168. % letter style definition
  169. %-------------------------------------------------------------------------------
  170. % commands
  171. \renewcommand*{\recomputeletterbodylengths}{%
  172. \recomputecvbodylengths%
  173. \setlength{\parskip}{6\p@}}
  174. \renewcommand*{\makeletterclosing}{
  175. \@closing\\[3em]%
  176. {\bfseries \@firstname~\@lastname}%
  177. \ifthenelse{\isundefined{\@enclosure}}{}{%
  178. \\%
  179. \vfill%
  180. {\color{color2}\itshape\enclname: \@enclosure}}}
  181. \endinput
  182. %% end of file `moderncvbodyv.sty'.