moderncv.cls 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461
  1. %% start of file `moderncv.cls'.
  2. %% Copyright 2007 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. \ProvidesClass{moderncv}[2007/05/28 v0.6 modern curriculum vitae document class]
  12. %-------------------------------------------------------------------------------
  13. % debugging
  14. %-------------------------------------------------------------------------------
  15. \newif\if@DEBUG\@DEBUGfalse
  16. %-------------------------------------------------------------------------------
  17. % class options
  18. %
  19. % (need to be done before the external package loading, for example because
  20. % we need \paperwidth, \paperheight and \@ptsize to be defined before loading
  21. % geometry and fancyhdr)
  22. %-------------------------------------------------------------------------------
  23. % paper size option
  24. \DeclareOption{a4paper}{
  25. \setlength\paperheight{297mm}
  26. \setlength\paperwidth{210mm}}
  27. \DeclareOption{a5paper}{
  28. \setlength\paperheight{210mm}
  29. \setlength\paperwidth{148mm}}
  30. \DeclareOption{b5paper}{
  31. \setlength\paperheight{250mm}
  32. \setlength\paperwidth{176mm}}
  33. \DeclareOption{letterpaper}{
  34. \setlength\paperheight{11in}
  35. \setlength\paperwidth{8.5in}}
  36. \DeclareOption{legalpaper}{
  37. \setlength\paperheight{14in}
  38. \setlength\paperwidth{8.5in}}
  39. \DeclareOption{executivepaper}{
  40. \setlength\paperheight{10.5in}
  41. \setlength\paperwidth{7.25in}}
  42. \DeclareOption{landscape}{
  43. \setlength\@tempdima{\paperheight}
  44. \setlength\paperheight{\paperwidth}
  45. \setlength\paperwidth{\@tempdima}}
  46. % font size options
  47. \newcommand\@ptsize{}
  48. \DeclareOption{10pt}{\renewcommand\@ptsize{0}}
  49. \DeclareOption{11pt}{\renewcommand\@ptsize{1}}
  50. \DeclareOption{12pt}{\renewcommand\@ptsize{2}}
  51. % draft/final option
  52. \DeclareOption{draft}{\setlength\overfullrule{5pt}}
  53. \DeclareOption{final}{\setlength\overfullrule{0pt}}
  54. % nolmodern option
  55. \newif\if@lmodern\@lmoderntrue
  56. \DeclareOption{nolmodern}{\@lmodernfalse}
  57. % nocolor option
  58. \newif\if@color\@colortrue
  59. \DeclareOption{nocolor}{\@colorfalse}
  60. % execute default options
  61. \ExecuteOptions{a4paper,11pt,color,final}
  62. % process given options
  63. \ProcessOptions\relax
  64. \input{size1\@ptsize.clo}
  65. %-------------------------------------------------------------------------------
  66. % required packages
  67. %-------------------------------------------------------------------------------
  68. % ifthen package
  69. \RequirePackage{ifthen}
  70. % ifpdf package
  71. \RequirePackage{ifpdf}
  72. % color package
  73. \ifpdf
  74. \RequirePackage[pdftex]{color}
  75. \else
  76. \RequirePackage[dvips]{color}
  77. \fi
  78. % fontenc package
  79. \RequirePackage[T1]{fontenc}
  80. % scalable Computer Modern fonts
  81. %\usepackage{type1cm}
  82. % latin modern fonts
  83. \AtEndOfClass{%
  84. \if@lmodern
  85. \RequirePackage{lmodern}\fi}
  86. % symbols like \Telefon, \Mobilefone, \Letter and \Email
  87. \RequirePackage{marvosym}
  88. % extended characters of T1 in .ps + other guillemets
  89. %\RequirePackage{ae,aecompl,aeguill}
  90. % page geometry
  91. \addtolength{\oddsidemargin}{-54pt}
  92. \addtolength{\textwidth}{109pt}
  93. \addtolength{\topmargin}{-70pt}
  94. \addtolength{\textheight}{122pt}
  95. \addtolength{\marginparsep}{-5pt}
  96. \addtolength{\marginparwidth}{-10pt}
  97. % hyperrefs
  98. \RequirePackage{url}
  99. \ifpdf
  100. \RequirePackage[pdftex]{hyperref}
  101. \else
  102. \RequirePackage[dvips]{hyperref}\fi
  103. \AtEndOfClass{%
  104. \AtBeginDocument{%
  105. \hypersetup{%
  106. breaklinks,
  107. baseurl = http://,
  108. pdfborder = 0 0 0,
  109. pdfpagemode = None,
  110. pdfstartview = XYZ,
  111. pdfstartpage = 1,
  112. pdfauthor = \@firstname~\@familyname,%
  113. pdftitle = \@title,%
  114. pdfsubject = \@firstname~\@familyname,%
  115. pdfkeywords = \@firstname~\@familyname{} curriculum vit\ae{},%
  116. pdfcreator = \LaTeX{} with `moderncv' package,%
  117. pdfproducer = \LaTeX}}}
  118. \urlstyle{tt}
  119. % tables that split across multiple pages
  120. \RequirePackage[]{longtable}
  121. % spacing between sections
  122. \setlength{\LTpre}{\smallskipamount}
  123. \setlength{\LTpost}{\smallskipamount}
  124. \setlength{\LTleft}{0pt}
  125. \setlength{\LTright}{0pt}
  126. % graphics
  127. \ifpdf
  128. \RequirePackage[pdftex]{graphicx}
  129. \else
  130. \RequirePackage[dvips]{graphicx}\fi
  131. % headers and footers
  132. \usepackage{fancyhdr}
  133. \fancypagestyle{plain}{%
  134. \renewcommand{\headrulewidth}{0pt}
  135. \renewcommand{\footrulewidth}{0pt}
  136. \fancyhf{}}
  137. \pagestyle{plain}
  138. % compatibility package with older versions of moderncv
  139. \RequirePackageWithOptions{moderncvcompatibility}
  140. %-------------------------------------------------------------------------------
  141. % class definition
  142. %-------------------------------------------------------------------------------
  143. % minimal base settings
  144. \setlength\lineskip{1\p@}
  145. \setlength\normallineskip{1\p@}
  146. \renewcommand\baselinestretch{}
  147. \setlength{\parindent}{0pt}
  148. \setlength{\parskip}{0pt}
  149. \setlength\columnsep{10\p@}
  150. \setlength\columnseprule{0\p@}
  151. \pagestyle{empty}
  152. \pagenumbering{arabic}
  153. \raggedbottom
  154. \onecolumn
  155. %-------------------------------------------------------------------------------
  156. % style commands definitions
  157. %-------------------------------------------------------------------------------
  158. % symbols used
  159. \providecommand*{\listitemsymbol}{\textbullet}
  160. \providecommand*{\addresssymbol}{}
  161. \providecommand*{\mobilesymbol}{\Mobilefone}
  162. \providecommand*{\phonesymbol}{\Telefon}
  163. \providecommand*{\faxsymbol}{\FAX}
  164. \providecommand*{\emailsymbol}{\Letter}
  165. % colors
  166. \definecolor{firstnamecolor}{rgb}{0,0,0}
  167. \definecolor{familynamecolor}{rgb}{0,0,0}
  168. \definecolor{titlecolor}{rgb}{0,0,0}
  169. \definecolor{addresscolor}{rgb}{0,0,0}
  170. \definecolor{quotecolor}{rgb}{0,0,0}
  171. \definecolor{sectionrectanglecolor}{rgb}{0,0,0}
  172. \definecolor{sectiontitlecolor}{rgb}{0,0,0}
  173. \definecolor{subsectioncolor}{rgb}{0,0,0}
  174. \definecolor{hintcolor}{rgb}{0,0,0}
  175. % fonts
  176. \providecommand*{\firstnamefont}{}
  177. \providecommand*{\familynamefont}{}
  178. \providecommand*{\titlefont}{}
  179. \providecommand*{\addressfont}{}
  180. \providecommand*{\quotefont}{}
  181. \providecommand*{\sectionfont}{}
  182. \providecommand*{\subsectionfont}{}
  183. \providecommand*{\hintfont}{\small\sffamily}
  184. % styles
  185. \providecommand*{\firstnamestyle}[1]{{\firstnamefont\color{firstnamecolor}#1}}
  186. \providecommand*{\familynamestyle}[1]{{\familynamefont\color{familynamecolor}#1}}
  187. \providecommand*{\titlestyle}[1]{{\titlefont\color{titlecolor}#1}}
  188. \providecommand*{\addresstyle}[1]{{\addressfont\color{addresscolor}#1}}
  189. \providecommand*{\quotestyle}[1]{{\quotefont\color{quotecolor}#1}}
  190. \providecommand*{\sectionstyle}[1]{{\sectionfont\color{sectiontitlecolor}#1}}
  191. \providecommand*{\subsectionstyle}[1]{{\subsectionfont\color{subsectioncolor}#1}}
  192. \providecommand*{\hintstyle}[1]{{\hintfont\color{hintcolor}#1}}
  193. % themes: casual (default), classic, ...
  194. \newcommand*{\moderncvtheme}[2][]{
  195. \def\@moderncvtheme{#2}
  196. \def\@moderncvthemeoptions{#1}}
  197. \moderncvtheme{casual} % default theme
  198. \AtBeginDocument{\RequirePackage[\@moderncvthemeoptions]{moderncvtheme\@moderncvtheme}}
  199. %-------------------------------------------------------------------------------
  200. % structure commands definitions
  201. %-------------------------------------------------------------------------------
  202. \newcommand*{\firstname}[1]{\def\@firstname{#1}}
  203. \newcommand*{\familyname}[1]{\def\@familyname{#1}}
  204. \renewcommand*{\title}[1]{\def\@title{#1}}
  205. \newcommand*{\address}[2]{\def\@addressstreet{#1}\def\@addresscity{#2}}
  206. \newcommand*{\mobile}[1]{\def\@mobile{#1}}
  207. \newcommand*{\phone}[1]{\def\@phone{#1}}
  208. \renewcommand*{\fax}[1]{\def\@fax{#1}}
  209. \newcommand*{\email}[1]{\def\@email{#1}}
  210. \newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}}
  211. \newcommand*{\photo}[2][64pt]{\def\@photoheight{#1}\def\@photo{#2}}
  212. \newcommand*{\quote}[1]{\def\@quote{#1}}
  213. % length used by the moderncv layout
  214. % quote length
  215. \newlength{\quotewidth}
  216. % section lengths
  217. \newlength{\hintscolumnwidth}
  218. \newlength{\separatorcolumnwidth}
  219. \setlength{\separatorcolumnwidth}{0.025\textwidth}
  220. \newlength{\maincolumnwidth}
  221. \newcommand*{\sethintscolumnlength}[1]{
  222. \setlength{\hintscolumnwidth}{#1}%
  223. \setlength{\maincolumnwidth}{\textwidth}%
  224. \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
  225. \addtolength{\maincolumnwidth}{-\hintscolumnwidth}}
  226. \newcommand*{\sethintscolumntowidth}[1]{
  227. \settowidth{\hintscolumnwidth}{#1}%
  228. \setlength{\maincolumnwidth}{\textwidth}%
  229. \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
  230. \addtolength{\maincolumnwidth}{-\hintscolumnwidth}}
  231. % doubleitem lengths
  232. \newlength{\doubleitemmaincolumnwidth}
  233. % listitem lengths
  234. \newlength{\listitemsymbolwidth}
  235. \settowidth{\listitemsymbolwidth}{\listitemsymbol{}~}
  236. % listdoubleitem lengths
  237. \newlength{\listdoubleitemmaincolumnwidth}
  238. % recompute all the lengths that depends on the text width
  239. \newcommand*{\recomputelengths}{%
  240. \setlength{\quotewidth}{0.65\textwidth}%
  241. \sethintscolumnlength{\hintscolumnwidth}%
  242. % doubleitem lengths
  243. \setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth}%
  244. \addtolength{\doubleitemmaincolumnwidth}{-\hintscolumnwidth}%
  245. \addtolength{\doubleitemmaincolumnwidth}{-\separatorcolumnwidth}%
  246. \setlength{\doubleitemmaincolumnwidth}{0.5\doubleitemmaincolumnwidth}%
  247. % listdoubleitem lengths
  248. \setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth}%
  249. \addtolength{\listdoubleitemmaincolumnwidth}{-\listitemsymbolwidth}%
  250. \setlength{\listdoubleitemmaincolumnwidth}{0.475\listdoubleitemmaincolumnwidth}%
  251. % fancyhdr lengths
  252. \renewcommand{\headwidth}{\textwidth}}
  253. \sethintscolumnlength{0.15\textwidth}
  254. \recomputelengths
  255. % makes the cv title
  256. \renewcommand*{\maketitle}{}%
  257. % draws a colored rectangle
  258. % usage: \colorrule[optional height]{width}
  259. %\newcommand*{\colorrule}[2][1ex]{{\color{sectionrectanglecolor}{\rule{#2}{#1}}}}
  260. \newif\if@sectionopen\@sectionopenfalse
  261. \newif\if@firstcvlineofsection\@firstcvlineofsectionfalse % bug if initially set to true...
  262. % usage: \closesection{} to force a section to be closed (and the tabular layout it generates)
  263. \newcommand*{\closesection}{%
  264. \if@sectionopen%
  265. \end{longtable}%
  266. % \phantomsection% reset the anchor for hyperrefs
  267. % \par\null%
  268. \@sectionopenfalse\fi}
  269. \AtEndDocument{\closesection{}}
  270. % usage: \section{<title>}, or \emptysection{}
  271. \newcommand*{\section}[1]{%
  272. \closesection{}%
  273. \@sectionopentrue%
  274. \phantomsection{}% reset the anchor for hyperrefs
  275. \addcontentsline{toc}{part}{#1}%
  276. \begin{longtable}[l]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
  277. {\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}} &\sectionstyle{#1}\\[1ex]%
  278. \@firstcvlineofsectiontrue%
  279. }
  280. \newcommand*{\emptysection}{%
  281. \closesection{}%
  282. \@sectionopentrue%
  283. \begin{longtable}[l]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
  284. \@firstcvlineofsectiontrue%
  285. }
  286. % usage (inside section): \subsection{title}
  287. \newcommand*{\subsection}[1]{%
  288. \cvline[0.65em]{}{\subsectionstyle{#1}}}
  289. % usage (inside section): \cvline{leftmark}{text}
  290. \newcommand*{\cvline}[3][.25em]{%
  291. \if@firstcvlineofsection%
  292. \@firstcvlineofsectionfalse%
  293. \else%
  294. \\[#1]\fi%
  295. \raggedleft\hintfont{#2} &#3}
  296. % usage (inside section}: \cvdoubleitem{subtitle}{text}{subtitle}{text}
  297. \newcommand*{\cvdoubleitem}[4]{%
  298. \cvline{#1}{\begin{minipage}[t]{\doubleitemmaincolumnwidth}#2\end{minipage}%
  299. \hfill%
  300. \begin{minipage}[t]{\hintscolumnwidth}\raggedleft\hintfont{#3}\end{minipage}\hspace*{\separatorcolumnwidth}\begin{minipage}[t]{\doubleitemmaincolumnwidth}#4\end{minipage}}}
  301. % usage (inside section): \cvlistitem{point1}
  302. \newcommand*{\cvlistitem}[2][\listitemsymbol{}]{%
  303. \cvline[0pt]{}{#1~#2}}
  304. % usage (inside section): \cvlistdoubleitem{point1}{point2}
  305. \newcommand*{\cvlistdoubleitem}[3][\listitemsymbol{}]{%
  306. \cvline[0pt]{}{#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
  307. \hfill%
  308. \ifthenelse{\equal{#3}{}}%
  309. {}%
  310. {#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#3\end{minipage}}}}
  311. % usage : \cventry{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
  312. \newcommand*{\cventry}[6]{%
  313. \cvline{#1}{%
  314. {\bfseries#2}%
  315. \ifthenelse{\equal{#3}{}}{}{, {\slshape#3}}%
  316. \ifthenelse{\equal{#4}{}}{}{, #4}%
  317. \ifthenelse{\equal{#5}{}}{}{, #5}%
  318. .%
  319. \ifthenelse{\equal{#6}{}}{}{\newline{}\small#6}
  320. }}%
  321. % \ifthenelse{\equal{#6}{}}{}{\cvline[0pt]{}{\small#6}}}
  322. % usage (inside 'language' cvsection environment): \cvlanguage{name}{level}{comment}
  323. \newcommand*{\cvlanguage}[3]{%
  324. \cvline{#1}{\begin{minipage}[t]{.225\maincolumnwidth}\textbf{#2}\end{minipage}\hfill\begin{minipage}[t]{0.725\maincolumnwidth}\raggedleft\footnotesize\itshape #3\end{minipage}}}
  325. % usage (inside 'computer skills' cvsection environment): \cvcomputer{category}{programs}{category}{programs}
  326. \newcommand*{\cvcomputer}[4]{%
  327. \cvdoubleitem{#1}{\small#2}{#3}{\small#4}}
  328. % usage: \weblink[optional text]{link}
  329. \newcommand*{\weblink}[2][]{%
  330. \ifthenelse{\equal{#1}{}}%
  331. {\def\@linktext{#2}}%
  332. {\def\@linktext{#1}}%
  333. \href{#2}{\@linktext{}}}
  334. % usage: \httplink[optional text]{link}
  335. \newcommand*{\httplink}[2][]{%
  336. \ifthenelse{\equal{#1}{}}%
  337. {\def\@linktext{#2}}%
  338. {\def\@linktext{#1}}%
  339. \href{http://#2}{\@linktext{}}}
  340. % usage: \emaillink[optional text]{link}
  341. \newcommand*{\emaillink}[2][]{%
  342. \ifthenelse{\equal{#1}{}}%
  343. {\def\@linktext{#2}}%
  344. {\def\@linktext{#1}}%
  345. \href{mailto:#2}{\@linktext{}}}
  346. % usage: \nopagenumbers{}
  347. \newif\if@displaypagenumbers\@displaypagenumberstrue
  348. \newcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
  349. \AtBeginDocument{%
  350. \if@displaypagenumbers%
  351. \@ifundefined{r@lastpage}{}{%
  352. \ifthenelse{\pageref{lastpage} > 1}{%
  353. \fancypagestyle{plain}{%
  354. \fancyfoot[r]{\addressfont\color{quotecolor}\footnotesize\thepage/\pageref{lastpage}}}%
  355. \pagestyle{plain}}{}}%
  356. \AtEndDocument{\label{lastpage}}%
  357. \fi}
  358. % thebibliography environment, for use with BibTeX
  359. \newcommand{\refname}{Publications}
  360. \newlength{\bibindent}
  361. \setlength{\bibindent}{1.5em}
  362. % trick to force the previous section to close before the thebibliography environment
  363. \let\oldbibliography\bibliography
  364. \renewcommand*{\bibliography}[1]{%
  365. \closesection{}%
  366. \oldbibliography{#1}}
  367. % bibliography item label
  368. \newcommand*{\bibliographyitemlabel}{}% use \@biblabel{\arabic{enumiv}} for BibTeX labels
  369. \newenvironment{thebibliography}[1]%
  370. {%
  371. \section{\refname}%
  372. \closesection{}%
  373. \vspace*{-1.65em}%
  374. \small%
  375. \begin{list}{\bibliographyitemlabel}%
  376. {%
  377. \setlength{\topsep}{0pt}%
  378. \setlength{\labelwidth}{\hintscolumnwidth}%
  379. \setlength{\labelsep}{\separatorcolumnwidth}%
  380. \leftmargin\labelwidth%
  381. \advance\leftmargin\labelsep%
  382. \@openbib@code%
  383. \usecounter{enumiv}%
  384. \let\p@enumiv\@empty%
  385. \renewcommand\theenumiv{\@arabic\c@enumiv}}%
  386. \sloppy\clubpenalty4000\widowpenalty4000%
  387. % \sfcode`\.\@m%
  388. % \sfcode `\=1000\relax%
  389. }%
  390. {%
  391. \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
  392. \end{list}%
  393. }
  394. \newcommand\newblock{\hskip .11em\@plus.33em\@minus.07em}
  395. \let\@openbib@code\@empty
  396. % the classical \today definition
  397. \def\today{\ifcase\month\or
  398. January\or February\or March\or April\or May\or June\or
  399. July\or August\or September\or October\or November\or December\fi
  400. \space\number\day, \number\year}
  401. \endinput
  402. %% end of file `moderncv.cls'.