moderncv.cls 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. %% start of file `moderncv.cls'.
  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. \ProvidesClass{moderncv}[2015/07/28 v2.0.0 modern curriculum vitae and letter document class]
  12. %-------------------------------------------------------------------------------
  13. % class options
  14. %
  15. % (need to be done before the external package loading, for example because
  16. % we need \paperwidth, \paperheight and \@ptsize to be defined before loading
  17. % geometry and fancyhdr)
  18. %-------------------------------------------------------------------------------
  19. % paper size option
  20. \DeclareOption{a4paper}{
  21. \setlength\paperheight{297mm}
  22. \setlength\paperwidth{210mm}}
  23. \DeclareOption{a5paper}{
  24. \setlength\paperheight{210mm}
  25. \setlength\paperwidth{148mm}}
  26. \DeclareOption{b5paper}{
  27. \setlength\paperheight{250mm}
  28. \setlength\paperwidth{176mm}}
  29. \DeclareOption{letterpaper}{
  30. \setlength\paperheight{11in}
  31. \setlength\paperwidth{8.5in}}
  32. \DeclareOption{legalpaper}{
  33. \setlength\paperheight{14in}
  34. \setlength\paperwidth{8.5in}}
  35. \DeclareOption{executivepaper}{
  36. \setlength\paperheight{10.5in}
  37. \setlength\paperwidth{7.25in}}
  38. \DeclareOption{landscape}{
  39. \setlength\@tempdima{\paperheight}
  40. \setlength\paperheight{\paperwidth}
  41. \setlength\paperwidth{\@tempdima}}
  42. % font size options
  43. \newcommand\@ptsize{}
  44. \DeclareOption{10pt}{\renewcommand\@ptsize{0}}
  45. \DeclareOption{11pt}{\renewcommand\@ptsize{1}}
  46. \DeclareOption{12pt}{\renewcommand\@ptsize{2}}
  47. % font type options
  48. \DeclareOption{sans}{\AtBeginDocument{\renewcommand{\familydefault}{\sfdefault}}}
  49. \DeclareOption{roman}{\AtBeginDocument{\renewcommand{\familydefault}{\rmdefault}}}
  50. % draft/final option
  51. \DeclareOption{draft}{\setlength\overfullrule{5pt}}
  52. \DeclareOption{final}{\setlength\overfullrule{0pt}}
  53. % execute default options
  54. \ExecuteOptions{a4paper,11pt,final}
  55. % process given options
  56. \ProcessOptions\relax
  57. \input{size1\@ptsize.clo}
  58. %-------------------------------------------------------------------------------
  59. % required packages
  60. %-------------------------------------------------------------------------------
  61. % \AtEndPreamble hook (loading etoolbox instead of defining the macro, as to avoid incompatibilities with etoolbox (and packages relying on it) defining the macro too)
  62. \RequirePackage{etoolbox}
  63. %\let\@endpreamblehook\@empty
  64. %\def\AtEndPreamble{\g@addto@macro\@endpreamblehook}
  65. %\let\document@original\document
  66. %\def\document{\endgroup\@endpreamblehook\begingroup\document@original}
  67. % if... then... else... constructs
  68. \RequirePackage{ifthen}
  69. % TODO: move to xifthen and \isempty{<arg>} instead of \equal{<arg>}{}
  70. % color
  71. \RequirePackage[table]{xcolor}
  72. % font loading
  73. \RequirePackage{ifxetex,ifluatex}
  74. \newif\ifxetexorluatex
  75. \ifxetex
  76. \xetexorluatextrue
  77. \else
  78. \ifluatex
  79. \xetexorluatextrue
  80. \else
  81. \xetexorluatexfalse
  82. \fi
  83. \fi
  84. % automatic loading of latin modern fonts
  85. %\ifxetexorluatex
  86. % \RequirePackage{fontspec}
  87. % \defaultfontfeatures{Ligatures=TeX}
  88. % \RequirePackage{unicode-math}
  89. % \setmainfont{Latin Modern}
  90. % \setsansfont{Latin Modern Sans}
  91. % \setmathfont{Latin Modern Math}
  92. %\else
  93. \RequirePackage[T1]{fontenc}
  94. \IfFileExists{lmodern.sty}%
  95. {\RequirePackage{lmodern}}%
  96. {}
  97. %\fi
  98. % hyper links (hyperref is loaded at the end of the preamble to pass options required by loaded packages such as CJK)
  99. \newcommand*\pdfpagemode{UseNone}% do not show thumbnails or bookmarks on opening (on supporting browsers); set \pdfpagemode to "UseOutlines" to show bookmarks
  100. \RequirePackage{url}
  101. \urlstyle{tt}
  102. \AtEndPreamble{
  103. \pagenumbering{arabic}% has to be issued before loading hyperref, as to set \thepage and hence to avoid hyperref issuing a warning and setting pdfpagelabels=false
  104. \RequirePackage[unicode]{hyperref}% unicode is required for unicode pdf metadata
  105. \hypersetup{
  106. breaklinks,
  107. baseurl = http://,
  108. pdfborder = 0 0 0,
  109. pdfpagemode = \pdfpagemode,
  110. pdfstartpage = 1,
  111. pdfcreator = {\LaTeX{} with 'moderncv' package},
  112. % pdfproducer = {\LaTeX{}},% will/should be set automatically to the correct TeX engine used
  113. bookmarksopen = true,
  114. bookmarksdepth= 2,% to show sections and subsections
  115. pdfauthor = {\@firstname{}~\@lastname{}},
  116. pdftitle = {\@firstname{}~\@lastname{}\notblank{\@title}{ -- \@title}{}},
  117. pdfsubject = {Resum\'{e} of \@firstname{}~\@lastname{}},
  118. pdfkeywords = {\@firstname{}~\@lastname{}, curriculum vit\ae{}, resum\'{e}}}}
  119. % graphics
  120. \RequirePackage{graphicx}
  121. % headers and footers
  122. \RequirePackage{fancyhdr}
  123. \fancypagestyle{plain}{
  124. \renewcommand{\headrulewidth}{0pt}
  125. \renewcommand{\footrulewidth}{0pt}
  126. \fancyhf{}}
  127. % page numbers in footer if more than 1 page
  128. \newif\if@displaypagenumbers\@displaypagenumberstrue
  129. \newcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
  130. \AtEndPreamble{%
  131. \AtBeginDocument{%
  132. % fancyhdr length
  133. \renewcommand{\headwidth}{\textwidth}
  134. \if@displaypagenumbers%
  135. \@ifundefined{r@lastpage}{}{%
  136. \ifthenelse{\pageref{lastpage}>1}{%
  137. \newlength{\pagenumberwidth}%
  138. \settowidth{\pagenumberwidth}{\color{color2}\addressfont\itshape\strut\thepage/\pageref{lastpage}}%
  139. \fancypagestyle{plain}{%
  140. \fancyfoot[r]{\parbox[b]{\pagenumberwidth}{\color{color2}\pagenumberfont\strut\thepage/\pageref{lastpage}}}}% the parbox is required to ensure alignment with a possible center footer (e.g., as in the casual style)
  141. \pagestyle{plain}}{}}%
  142. \AtEndDocument{\label{lastpage}}\else\fi}}
  143. \pagestyle{plain}
  144. % reduced list spacing
  145. % package providing hooks into lists
  146. % originally developped by Jakob Schiøtz (see http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/tweaklist.sty)
  147. % modified and distributed with moderncv(not available otherwise on ctan)
  148. \RequirePackage{tweaklist}
  149. \renewcommand*{\itemhook}{%
  150. \@minipagetrue% removes spacing before lists as they use \addvspace, which doesn't add vertical space inside minipages
  151. \@noparlisttrue% removes spacing at end of lists, caused by \par
  152. \setlength{\topsep}{0pt}% normally not required thanks to \@minipagetrue
  153. \setlength{\partopsep}{0pt}% normally not required thanks to \@minipagetrue
  154. \setlength{\parsep}{0pt}% not required when \itemsep and \parskip are set to 0pt (?)
  155. \setlength{\parskip}{0pt}%
  156. \setlength{\itemsep}{0pt}}
  157. \renewcommand*{\enumhook}{\itemhook{}}
  158. \renewcommand*{\deschook}{\itemhook{}}
  159. % lengths calculations
  160. \RequirePackage{calc}
  161. % advanced command arguments (LaTeX 3)
  162. \RequirePackage{xparse}
  163. % TODO (?): replace all \newcommand by \NewDocumentCommand
  164. % micro-typography (e.g., character protrusion, font expansion, hyphenatable letterspacing)
  165. \RequirePackage{microtype}
  166. % stack of key-value elements, used to save personal information
  167. \RequirePackage{moderncvcollection}
  168. % compatibility package with older versions of moderncv
  169. \RequirePackageWithOptions{moderncvcompatibility}
  170. %-------------------------------------------------------------------------------
  171. % class definition
  172. %-------------------------------------------------------------------------------
  173. % minimal base settings
  174. \setlength\lineskip{1\p@}
  175. \setlength\normallineskip{1\p@}
  176. \renewcommand\baselinestretch{}
  177. \setlength{\parindent}{0\p@}
  178. \setlength{\parskip}{0\p@}
  179. \setlength\columnsep{10\p@}
  180. \setlength\columnseprule{0\p@}
  181. \setlength\fboxsep{3\p@}
  182. \setlength\fboxrule{.4\p@}
  183. \setlength\arrayrulewidth{.4\p@}
  184. \setlength\doublerulesep{2\p@}
  185. % not set on purpose
  186. %\setlength\arraycolsep{5\p@}
  187. %\setlength\tabcolsep{6\p@}
  188. %\setlength\tabbingsep{\labelsep}
  189. \raggedbottom
  190. \onecolumn
  191. %-------------------------------------------------------------------------------
  192. % overall design commands definitions
  193. %-------------------------------------------------------------------------------
  194. % elements
  195. %---------
  196. % defines one's name
  197. % usage: \name{<firstname>}{<lastname>}
  198. \newcommand*{\name}[2]{\def\@firstname{#1}\def\@lastname{#2}}
  199. % defines one's title (optional)
  200. % usage: \title{<title>}
  201. \renewcommand*{\title}[1]{\def\@title{#1}}
  202. % defines one's address (optional)
  203. % usage: \address{<street>}{<city>}{<country>}
  204. % where the <city> and <country> arguments can be omitted or provided empty
  205. \NewDocumentCommand{\address}{mG{}G{}}{\def\@addressstreet{#1}\def\@addresscity{#2}\def\@addresscountry{#3}}
  206. % defines one's email (optional)
  207. % usage: \email{<email adress>}
  208. \newcommand*{\email}[1]{\def\@email{#1}}
  209. % defines one's home page (optional)
  210. % usage: \homepage{<url>}
  211. \newcommand*{\homepage}[1]{\def\@homepage{#1}}
  212. % adds a fixed/mobile/fax number to one's personal information (optional)
  213. % usage: \phone[<optional type>]{<number>}
  214. % where <optional type> should be either "fixed" (default), "mobile" or "fax
  215. \collectionnew{phones}
  216. \newcommand*{\phone}[2][fixed]{\collectionadd[#1]{phones}{#2}}
  217. % adds a social link to one's personal information (optional)
  218. % usage: \social[<optional type>][<optional url>]{<account name>}
  219. % where <optional type> should be either "linkedin", "twitter" or "github"
  220. \collectionnew{socials}
  221. \NewDocumentCommand{\social}{O{}O{}m}{%
  222. \ifthenelse{\equal{#2}{}}%
  223. {%
  224. \ifthenelse{\equal{#1}{linkedin}}{\collectionadd[linkedin]{socials}{\protect\httplink[#3]{www.linkedin.com/in/#3}}}{}%
  225. \ifthenelse{\equal{#1}{twitter}} {\collectionadd[twitter]{socials} {\protect\httplink[#3]{www.twitter.com/#3}}} {}%
  226. \ifthenelse{\equal{#1}{github}} {\collectionadd[github]{socials} {\protect\httplink[#3]{www.github.com/#3}}} {}%
  227. }
  228. {\collectionadd[#1]{socials}{\protect\httplink[#3]{#2}}}}
  229. % defines additional personal information (optional)
  230. % usage: \extrainfo{<text>}
  231. \newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}}
  232. % colors
  233. %-------
  234. \definecolor{color0}{rgb}{0,0,0}% main default color, normally left to black
  235. \definecolor{color1}{rgb}{0,0,0}% primary scheme color
  236. \definecolor{color2}{rgb}{0,0,0}% secondary scheme color
  237. \definecolor{color3}{rgb}{0,0,0}% tertiary scheme color
  238. % symbols
  239. %--------
  240. % itemize labels (the struts were added to correct inter-item spacing (works for single line items, until a solution is found for multi-line ones...)
  241. \newcommand*{\labelitemi} {\strut\textcolor{color1}{\large\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
  242. \newcommand*{\labelitemii} {\strut\textcolor{color1}{\large\bfseries-}}
  243. \newcommand*{\labelitemiii} {\strut\textcolor{color1}{\rmfamily\textperiodcentered}}% alternative: \textasteriskcentered; 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
  244. \newcommand*{\labelitemiv} {\labelitemiii}
  245. % enumerate labels
  246. \renewcommand{\theenumi} {\@arabic\c@enumi}
  247. \renewcommand{\theenumii} {\@alph\c@enumii}
  248. \renewcommand{\theenumiii} {\@roman\c@enumiii}
  249. \renewcommand{\theenumiv} {\@Alph\c@enumiv}
  250. % other symbols
  251. \newcommand*{\listitemsymbol} {\labelitemi~}
  252. \newcommand*{\addresssymbol} {}
  253. \newcommand*{\mobilephonesymbol} {}
  254. \newcommand*{\fixedphonesymbol} {}
  255. \newcommand*{\faxphonesymbol} {}
  256. \newcommand*{\emailsymbol} {}
  257. \newcommand*{\homepagesymbol} {}
  258. \newcommand*{\linkedinsocialsymbol}{}
  259. \newcommand*{\twittersocialsymbol} {}
  260. \newcommand*{\githubsocialsymbol} {}
  261. % other
  262. %------
  263. % fonts
  264. \AtBeginDocument{\normalfont\color{color0}}
  265. % strings for internationalisation
  266. \newcommand*{\refname}{Publications}
  267. \newcommand*{\enclname}{Enclosure}
  268. % makes the footer (normally used both for the resume and the letter)
  269. % usage: \makefooter
  270. \newcommand*{\makefooter}{}%
  271. % loads a style variant (a combination of header, body and footer)
  272. % usage: \moderncvstyle{<style variant name>}
  273. \newcommand*{\moderncvstyle}[2][]{
  274. \RequirePackage[#1]{moderncvstyle#2}}
  275. % loads a header variant
  276. % usage: \moderncvhead[<optional head option>]{<header variant number>}
  277. \newcommand*{\moderncvhead}[2][]{
  278. \expandafter\RequirePackage\expandafter[\expandafter#1\expandafter]{\expandafter moderncvhead\romannumeral #2}}
  279. % loads a body variant
  280. % usage: \moderncvbody[<optional body option>]{<body variant number>}
  281. \newcommand*{\moderncvbody}[2][]{
  282. \expandafter\RequirePackage\expandafter[\expandafter#1\expandafter]{\expandafter moderncvbody\romannumeral #2}}
  283. % loads a footer variant
  284. % usage: \moderncvfoot{<footer variant number>}
  285. \newcommand*{\moderncvfoot}[1]{
  286. \expandafter\RequirePackage\expandafter{\expandafter moderncvfoot\romannumeral #1}}
  287. % loads a color scheme
  288. % usage: \moderncvcolor{<color scheme name>}
  289. \newcommand*{\moderncvcolor}[1]{
  290. \RequirePackage{moderncvcolor#1}}
  291. % loads an icons set
  292. % usage: \moderncvicons{<icon set name>}
  293. \newcommand*{\moderncvicons}[1]{
  294. \RequirePackage{moderncvicons#1}}
  295. % recomputes all automatic lengths
  296. \newcommand*{\recomputeheadlengths}{\recomputecvheadlengths}
  297. \newcommand*{\recomputebodylengths}{\recomputecvbodylengths}
  298. \newcommand*{\recomputefootlengths}{\recomputecvfootlengths}
  299. \newcommand*{\recomputelengths}{\recomputecvlengths}
  300. \AtBeginDocument{\recomputelengths{}}
  301. % creates a command if not yet defined
  302. \newcommand*{\@initializecommand}[2]{%
  303. \ifdefined#1
  304. \renewcommand{#1}{#2}%
  305. \else%
  306. \newcommand*{#1}{#2}\fi}
  307. % creates a length if not yet defined
  308. \newcommand*{\@initializelength}[1]{%
  309. \ifdefined#1
  310. \else%
  311. \newlength{#1}\fi%
  312. \setlength{#1}{0pt}}
  313. % creates a box if not yet defined
  314. \newcommand*{\@initializebox}[1]{%
  315. \ifdefined#1
  316. \savebox{#1}{}%
  317. \else%
  318. \newsavebox{#1}\fi}
  319. % creates an if switch if not yet defined
  320. \newcommand*{\@initializeif}[1]{%
  321. % \ifdefined#1% not working due to the nested \if
  322. % \else%
  323. \newif#1%\fi
  324. }
  325. % custom strut for spacing; the first argument is the vertical offset of the strut, the second its total height
  326. \newcommand*{\@moderncvstrut}[2]{%
  327. \rule[-#1]{0pt}{#2}}
  328. %-------------------------------------------------------------------------------
  329. % resume design commands definitions
  330. %-------------------------------------------------------------------------------
  331. % elements
  332. % defines one's picture (optional)
  333. % usage: photo[<picture width>][<picture frame thickness>]{<picture filename>}
  334. \NewDocumentCommand{\photo}{O{64pt}O{0.4pt}m}{\def\@photowidth{#1}\def\@photoframewidth{#2}\def\@photo{#3}}
  335. \newcommand*{\quote}[1]{\def\@quote{#1}}
  336. % fonts
  337. \newcommand*{\namefont}{}
  338. \newcommand*{\titlefont}{}
  339. \newcommand*{\addressfont}{}
  340. \newcommand*{\quotefont}{}
  341. \newcommand*{\sectionfont}{}
  342. \newcommand*{\subsectionfont}{}
  343. \newcommand*{\hintfont}{}
  344. \newcommand*{\pagenumberfont}{\addressfont\itshape}
  345. % fake small caps - cfr http://tex.stackexchange.com/questions/55664/fake-small-caps-with-xetex-fontspec
  346. %\def\fakesc{\bgroup\obeyspaces\fakescaux}
  347. %\def\fakescaux#1{\fakescauxii #1\relax\relax\egroup}
  348. %\def\fakescauxii#1{%
  349. %\ifx\relax#1\else \ifcat#1\@sptoken{} \expandafter\expandafter\expandafter\fakescauxii\else
  350. %\ifnum`#1=\uccode`#1 {\normalsize #1}\else {\footnotesize \uppercase{#1}}\fi \expandafter\expandafter\expandafter\fakescauxii\expandafter\fi\fi}
  351. % styles
  352. \newcommand*{\namestyle}[1]{{\namefont#1}}
  353. \newcommand*{\titlestyle}[1]{{\titlefont#1}}
  354. \newcommand*{\addressstyle}[1]{{\addressfont#1}}
  355. \newcommand*{\quotestyle}[1]{{\quotefont#1}}
  356. \newcommand*{\sectionstyle}[1]{{\sectionfont#1}}
  357. \newcommand*{\subsectionstyle}[1]{{\subsectionfont#1}}
  358. \newcommand*{\hintstyle}[1]{{\hintfont#1}}
  359. \newcommand*{\pagenumberstyle}[1]{{\pagenumberfont#1}}
  360. % recompute all resume lengths
  361. \newcommand*{\recomputecvheadlengths}{}
  362. \newcommand*{\recomputecvbodylengths}{}
  363. \newcommand*{\recomputecvfootlengths}{}
  364. \newcommand*{\recomputecvlengths}{%
  365. \recomputecvheadlengths%
  366. \recomputecvbodylengths%
  367. \recomputecvfootlengths}
  368. % internal maketitle command to issue a new line only when required
  369. \newif\if@firstdetailselement\@firstdetailselementtrue
  370. \newcommand*{\makenewline}[1][0pt]{%
  371. \if@firstdetailselement%
  372. \strut% to ensure baseline alignment, e.g. with when put in the margin vs sections that also contains a \strut
  373. \else%
  374. \\[#1]\fi%
  375. \@firstdetailselementfalse}
  376. % makes the resume title
  377. % usage: \makecvtitle
  378. \newcommand*{\makecvtitle}{%
  379. \makecvhead%
  380. \makecvfoot}
  381. \newcommand*{\makecvhead}{}
  382. \newcommand*{\makecvfoot}{}
  383. % makes a resume section
  384. % usage: \section{<title>}
  385. % identical starred and non-starred variants should be defined for compatibility with other packages (e.g. with natbib, that uses \section*{} for the bibliography header)
  386. \NewDocumentCommand{\section}{sm}{}
  387. % makes a resume subsection
  388. % usage: \subsection{title}
  389. \NewDocumentCommand{\subsection}{sm}{}
  390. % makes a resume line with a header and a corresponding text
  391. % usage: \cvitem[spacing]{header}{text}
  392. \newcommand*{\cvitem}[3][.25em]{}
  393. % makes a resume line 2 headers and their corresponding text
  394. % usage: \cvdoubleitem[spacing]{header1}{text1}{header2}{text2}
  395. \newcommand*{\cvdoubleitem}[5][.25em]{}
  396. % makes a resume line with a list item
  397. % usage: \cvlistitem[label]{item}
  398. \newcommand*{\cvlistitem}[2][\listitemsymbol]{}
  399. % makes a resume line with 2 list items
  400. % usage: \cvlistdoubleitem[label]{item1}{item2}
  401. \newcommand*{\cvlistdoubleitem}[3][\listitemsymbol]{}
  402. % makes a typical resume job / education entry
  403. % usage: \cventry[spacing]{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
  404. \newcommand*{\cventry}[7][.25em]{}
  405. % makes a resume entry with a proficiency comment
  406. % usage: \cvitemwithcomment[spacing]{header}{text}{comment}
  407. \newcommand*{\cvitemwithcomment}[4][.25em]{}
  408. % makes a generic hyperlink
  409. % usage: \link[optional text]{link}
  410. \newcommand*{\link}[2][]{%
  411. \ifthenelse{\equal{#1}{}}%
  412. {\href{#2}{#2}}%
  413. {\href{#2}{#1}}}
  414. % makes a http hyperlink
  415. % usage: \httplink[optional text]{link}
  416. \newcommand*{\httplink}[2][]{%
  417. \ifthenelse{\equal{#1}{}}%
  418. {\href{http://#2}{#2}}%
  419. {\href{http://#2}{#1}}}
  420. % makes an email hyperlink
  421. % usage: \emaillink[optional text]{link}
  422. \newcommand*{\emaillink}[2][]{%
  423. \ifthenelse{\equal{#1}{}}%
  424. {\href{mailto:#2}{#2}}%
  425. {\href{mailto:#2}{#1}}}
  426. % cvcolumns environment, where every column is created through \cvcolumn
  427. % usage: \begin{cvcolumns}
  428. % \cvcolumn[width]{head}{content}
  429. % \cvcolumn[width]{head}{content}
  430. % ...
  431. % \end{cvcolumns}
  432. % where "width" is the width as a fraction of the line length (between 0 and 1), "head" is the column header and "content" its content
  433. \newcounter{cvcolumnscounter}% counter for the number of columns
  434. \newcounter{cvcolumnsautowidthcounter}% counter for the number of columns with no column width provided, and which will then be equally distributed
  435. \newcounter{tmpiteratorcounter}% counter for any temporary purpose (e.g., iterating loops)
  436. \newlength{\cvcolumnsdummywidth}\setlength{\cvcolumnsdummywidth}{1000pt}% dummy width for total width, in order to enable arithmetics (TeX has no float variables, only integer counters or lengths)
  437. \newlength{\cvcolumnswidth}% total width available for head / content
  438. \newlength{\cvcolumnsautowidth}% total width of columns with no explicit width provided
  439. \newlength{\cvcolumnautowidth}% width of one of the columns with no explicit width provided (based on equal distribution of remaining space)
  440. \newif\if@cvcolumns@head@empty% whether or not at least one of the columns has a header
  441. \newenvironment*{cvcolumns}%
  442. {% at environment opening: reset counters, lengths and ifs
  443. \setcounter{cvcolumnscounter}{0}%
  444. \setcounter{cvcolumnsautowidthcounter}{0}%
  445. \setlength{\cvcolumnsautowidth}{\cvcolumnsdummywidth}%
  446. \setlength{\cvcolumnautowidth}{0pt}%
  447. \@cvcolumns@head@emptytrue\ignorespaces}%
  448. {% at environment closing: typeset environment
  449. % compute the width of each cvcolumn, considering a spacing of \separatorcolumnwidth and the columns with set width
  450. \ifnum\thecvcolumnscounter>0%
  451. \setlength{\cvcolumnswidth}{\maincolumnwidth-\value{cvcolumnscounter}\separatorcolumnwidth+\separatorcolumnwidth}%
  452. \setlength{\cvcolumnautowidth}{\cvcolumnswidth*\ratio{\cvcolumnsautowidth}{\cvcolumnsdummywidth}/\value{cvcolumnsautowidthcounter}}\fi%
  453. % pre-aggregate the tabular definition, heading and content (required before creating the tabular, as the tabular environment doesn't like loops --- probably because "&" generates a \endgroup)
  454. % - the tabular definition is the aggregation of the different "\cvcolumn<i>@def" (by default "p{\cvcolumnautowidth}"), separated by "@{\hspace*{\separatorcolumnwidth}}"
  455. % - the tabular heading is the aggregation of the different "\cvcolumn<i>@head", separated by "&"
  456. % - the tabular content is the aggregation of the different "\cvcolumn<i>@content", separated by "&"
  457. % to aggregate the different elements, \protected@edef or \g@addto@macro is required to avoid that \cvcolumns@def, -@head and -@content get expanded in subsequent redefinitions, which would cause errors due to the expansions of \hspace, of \subsectionstyle and possibly of user content/argument such as font commands
  458. \def\cvcolumns@def{}%
  459. \def\cvcolumns@head{}%
  460. \def\cvcolumns@content{}%
  461. \setcounter{tmpiteratorcounter}{0}%
  462. % loop based on \g@addto@macro
  463. \loop\ifnum\thetmpiteratorcounter<\thecvcolumnscounter%
  464. \ifnum\thetmpiteratorcounter=0\else%
  465. \g@addto@macro\cvcolumns@def{@{\hspace*{\separatorcolumnwidth}}}%
  466. \g@addto@macro\cvcolumns@head{&}%
  467. \g@addto@macro\cvcolumns@content{&}\fi%
  468. % \expandafter\g@addto@macro\expandafter\cvcolumns@def\expandafter{\csname cvcolumn\roman{tmpiteratorcounter}@def\endcsname}% % this creates issues with the colortbl" package (loaded by xcolor when passing the "table" option) as the column definitions passed to \begin{tabular} contains \cvcolumn<i>@def references that it doesn't understand; the next 2 lines expand \cvcolumn@def to the point it doesn't
  469. \edef\tmpcvcolumn@def{\csname cvcolumn\roman{tmpiteratorcounter}@def\endcsname}%
  470. \expandafter\g@addto@macro\expandafter\cvcolumns@def\expandafter{\tmpcvcolumn@def}%
  471. \expandafter\g@addto@macro\expandafter\cvcolumns@head\expandafter{\csname cvcolumn\roman{tmpiteratorcounter}@head\endcsname}%
  472. \expandafter\g@addto@macro\expandafter\cvcolumns@content\expandafter{\csname cvcolumn\roman{tmpiteratorcounter}@content\endcsname}%
  473. \stepcounter{tmpiteratorcounter}%
  474. \repeat%
  475. % % same loop based on \protected@edef
  476. % \loop\ifnum\thetmpiteratorcounter<\thecvcolumnscounter%
  477. % \ifnum\thetmpiteratorcounter=0\else%
  478. % \protected@edef\cvcolumns@def{\cvcolumns@def @{\hspace*{\separatorcolumnwidth}}}%
  479. % \protected@edef\cvcolumns@head{\cvcolumns@head &}%
  480. % \protected@edef\cvcolumns@content{\cvcolumns@content &}\fi%
  481. % \expandafter\protected@edef\expandafter\cvcolumns@def\expandafter{\expandafter\cvcolumns@def\expandafter\protect\csname cvcolumn\roman{tmpiteratorcounter}@def\endcsname}%
  482. % \expandafter\protected@edef\expandafter\cvcolumns@head\expandafter{\expandafter\cvcolumns@head\expandafter\protect\csname cvcolumn\roman{tmpiteratorcounter}@head\endcsname}%
  483. % \expandafter\protected@edef\expandafter\cvcolumns@content\expandafter{\expandafter\cvcolumns@content\expandafter\protect\csname cvcolumn\roman{tmpiteratorcounter}@content\endcsname}%
  484. % \stepcounter{tmpiteratorcounter}%
  485. % \repeat%
  486. % create the tabular
  487. \cvitem{}{%
  488. % \begin{tabular}{\cvcolumns@def}% this conflicts with the "colortbl" package (loaded by xcolor when passing the "table" option), and requires the below 2 lines to expand \cvcolumns@def
  489. \def\begincvcolumns{\begin{tabular}[t]}% "[t]" is required for some body styles; the default alignment is "[c]"
  490. \expandafter\begincvcolumns\expandafter{\cvcolumns@def}%
  491. \if@cvcolumns@head@empty\else%
  492. \cvcolumns@head%\\[-.8em]%
  493. % {\color{color1}\rule{\maincolumnwidth}{.25pt}}%
  494. \\\fi%
  495. \cvcolumns@content%
  496. \end{tabular}}}
  497. % cvcolumn command, to create a column inside a cvcolumns environment
  498. % usage: \cvcolumn[width]{head}{content}
  499. % where "width" is the width as a fraction of the line length (between 0 and 1), "head" is the column header and "content" its content ("head" and "content" can contain "\\", "\newline" or any other paragraph command such as "itemize")
  500. \newcommand*{\cvcolumn}[3][\cvcolumnautowidth]{%
  501. % \def\cvcolumn@width{}%
  502. \ifthenelse{\equal{#1}{\cvcolumnautowidth}}%
  503. {% if no width fraction is provided, count this column as auto-adjusted and set its width to \cvcolumnsautowidth
  504. \stepcounter{cvcolumnsautowidthcounter}%
  505. \expandafter\expandafter\expandafter\def\expandafter\csname cvcolumn\roman{cvcolumnscounter}@def\endcsname{p{\cvcolumnautowidth}}%
  506. \expandafter\expandafter\expandafter\def\expandafter\csname cvcolumn\roman{cvcolumnscounter}@head\endcsname{\protect\parbox[b]{\cvcolumnautowidth}{\protect\subsectionstyle{#2}}}}%
  507. {% if a width is provided, set the width of the column to it and decrease the available space for auto-adjusted columns
  508. \addtolength{\cvcolumnsautowidth}{-#1\cvcolumnsdummywidth}%
  509. \expandafter\expandafter\expandafter\def\expandafter\csname cvcolumn\roman{cvcolumnscounter}@def\endcsname{p{#1\cvcolumnswidth}}%
  510. \expandafter\expandafter\expandafter\def\expandafter\csname cvcolumn\roman{cvcolumnscounter}@head\endcsname{\protect\parbox[b]{#1\cvcolumnswidth}{\protect\subsectionstyle{#2}}}}%
  511. \ifthenelse{\equal{#2}{}}{}{\@cvcolumns@head@emptyfalse}%
  512. \expandafter\expandafter\expandafter\def\expandafter\csname cvcolumn\roman{cvcolumnscounter}@content\endcsname{\protect\cvcolumncell{#3}}%
  513. \stepcounter{cvcolumnscounter}%
  514. \ignorespaces}
  515. % internal cvcolumncell command, that enables a cvcolumn cell to contain paragraph commands (lists, newlines, etc)
  516. \newcommand*{\cvcolumncell}[1]{{% put cell inside a group, so that command redefinitions are only local
  517. % roughly restore \\ to its regular definition (outside of tabular)
  518. \renewcommand*{\\}{\newline}%
  519. % enclose the contents of the cell inside a vertical box, to allow paragraph commands
  520. \protect\vtop{#1}}}
  521. % thebibliography environment, for use with BibTeX and possibly multibib
  522. \newlength{\bibindent}
  523. \setlength{\bibindent}{1.5em}
  524. % bibliography item label
  525. \newcommand*{\bibliographyitemlabel}{}% use \@biblabel{\arabic{enumiv}} for BibTeX labels
  526. %\newif\if@multibibfirstbib\@multibibfirstbibfalse
  527. % bibliography head (section, etc}, depending on whether multibib is used
  528. \newcommand*{\bibliographyhead}[1]{\section{#1}}
  529. \AtEndPreamble{\@ifpackageloaded{multibib}{\renewcommand*{\bibliographyhead}[1]{\subsection{#1}}}{}}
  530. % thebibliography environment definition
  531. \newenvironment{thebibliography}[1]{}{}
  532. \newcommand*{\newblock}{\hskip .11em\@plus.33em\@minus.07em}
  533. \let\@openbib@code\@empty
  534. %% fix a bug (hardcoded bib label) in \@bibitem
  535. %\renewcommand\@bibitem[1]{%
  536. % \item\if@filesw \immediate\write\@auxout
  537. % {\string\bibcite{#1}{\theenumiv}}\fi\ignorespaces}% replaced "\the\value{\@listctr}" with "\theenumiv"
  538. % itemize, enumerate and description environment
  539. \setlength{\leftmargini} {1em}
  540. \leftmargin\leftmargini
  541. \setlength{\leftmarginii} {\leftmargini}
  542. \setlength{\leftmarginiii} {\leftmargini}
  543. \setlength{\leftmarginiv} {\leftmargini}
  544. \setlength{\leftmarginv} {\leftmargini}
  545. \setlength{\leftmarginvi} {\leftmargini}
  546. \setlength{\labelsep} {.5em}% this is the distance between the label and the body, but it pushes the label to the left rather than pushing the body to the right (to do the latter, modify \leftmargin(i)
  547. \setlength{\labelwidth} {\leftmargini}% unfortunately, \labelwidth is not defined by item level (i.e. no \labeliwidth, \labeliiwidth, etc)
  548. \addtolength{\labelwidth} {-\labelsep}
  549. \@beginparpenalty -\@lowpenalty
  550. \@endparpenalty -\@lowpenalty
  551. \@itempenalty -\@lowpenalty
  552. \newcommand\labelenumi{\theenumi.}
  553. \newcommand\labelenumii{(\theenumii)}
  554. \newcommand\labelenumiii{\theenumiii.}
  555. \newcommand\labelenumiv{\theenumiv.}
  556. \renewcommand\p@enumii{\theenumi}
  557. \renewcommand\p@enumiii{\p@enumii(\theenumii)}
  558. \renewcommand\p@enumiv{\p@enumiii\theenumiii}
  559. % description label
  560. \newcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\bfseries#1}
  561. % classical \today definition
  562. \def\today{\ifcase\month\or
  563. January\or February\or March\or April\or May\or June\or
  564. July\or August\or September\or October\or November\or December\fi
  565. \space\number\day, \number\year}
  566. %\newcommand{\widthofautobox}[1]{%
  567. % \widthof{\begin{tabular}{@{}l@{}}#1\end{tabular}}}
  568. %\newcommand{\autobox}[2][b]{%
  569. % \parbox[#1]{\widthofautobox{#2}}{#2}}
  570. %-------------------------------------------------------------------------------
  571. % letter design commands definitions
  572. %-------------------------------------------------------------------------------
  573. % elements
  574. \newcommand*{\recipient}[2]{\def\@recipientname{#1}\def\@recipientaddress{#2}}
  575. \renewcommand*{\date}[1]{\def\@date{#1}}\date{\today}
  576. \newcommand*{\opening}[1]{\def\@opening{#1}}
  577. \newcommand*{\closing}[1]{\def\@closing{#1}}
  578. \newcommand*{\enclosure}[2][]{%
  579. % if an optional argument is provided, use it to redefine \enclname
  580. \ifthenelse{\equal{#1}{}}{}{\renewcommand*{\enclname}{#1}}%
  581. \def\@enclosure{#2}}
  582. % recompute all letter lengths
  583. \newcommand*{\recomputeletterheadlengths}{}
  584. \newcommand*{\recomputeletterbodylengths}{}
  585. \newcommand*{\recomputeletterfootlengths}{}
  586. \newcommand*{\recomputeletterlengths}{%
  587. \recomputeletterheadlengths%
  588. \recomputeletterbodylengths%
  589. \recomputeletterfootlengths}
  590. % makes the letter title
  591. % usage: \makelettertitle
  592. \newcommand*{\makelettertitle}{%
  593. \makeletterhead%
  594. \makeletterfoot}
  595. \newcommand*{\makeletterhead}{}
  596. \newcommand*{\makeletterfoot}{}
  597. % makes the letter closing
  598. % usage: \makeletterclosing
  599. \newcommand*{\makeletterclosing}{}
  600. \endinput
  601. %% end of file `moderncv.cls'.