Changeset 222 for cv/moderncv.cls


Ignore:
Timestamp:
Nov 10, 2010, 8:26:26 PM (14 years ago)
Author:
Rick van der Zwet
Message:

Update of CV latex package

File:
1 edited

Legend:

Unmodified
Added
Removed
  • cv/moderncv.cls

    r2 r222  
    11%% start of file `moderncv.cls'.
    2 %% Copyright 2007 Xavier Danaux (xdanaux@gmail.com).
     2%% Copyright 2006-2010 Xavier Danaux (xdanaux@gmail.com).
    33%
    44% This work may be distributed and/or modified under the
     
    1111%-------------------------------------------------------------------------------
    1212\NeedsTeXFormat{LaTeX2e}
    13 \ProvidesClass{moderncv}[2007/05/28 v0.6 modern curriculum vitae document class]
     13\ProvidesClass{moderncv}[2010/08/03 v0.12 modern curriculum vitae document class]
    1414
    1515
     
    6969\DeclareOption{nocolor}{\@colorfalse}
    7070
     71% CJK option
     72%\newif\if@CJK\@CJKfalse
     73%\DeclareOption{CJK}{\@CJKtrue}
     74
    7175% execute default options
    7276\ExecuteOptions{a4paper,11pt,color,final}
     
    8084%                required packages
    8185%-------------------------------------------------------------------------------
    82 % ifthen package
     86% \AtEndPreamble hook (loading tetoolbox instead of defining the macro, as to avoid incompatibilities with etoolbox (and packages relying on it) defining the macro too)
     87\RequirePackage{etoolbox}
     88%\let\@endpreamblehook\@empty
     89%\def\AtEndPreamble{\g@addto@macro\@endpreamblehook}
     90%\let\moderncv@document\document
     91%\def\document{\endgroup\@endpreamblehook\begingroup\moderncv@document}
     92
     93% if... then... else... constructs
    8394\RequirePackage{ifthen}
    8495
    85 % ifpdf package
    86 \RequirePackage{ifpdf}
    87 
    88 % color package
    89 \ifpdf
    90   \RequirePackage[pdftex]{color}
    91 \else
    92   \RequirePackage[dvips]{color}
    93 \fi
    94 
    95 % fontenc package
     96% latex vs pdflatex vs xelatex vs luatex compilation
     97%\RequirePackage{ifpdf}
     98
     99% color
     100\RequirePackage{color}
     101
     102% font encoding
    96103\RequirePackage[T1]{fontenc}
    97104
     
    100107
    101108% latin modern fonts
    102 \AtEndOfClass{%
    103   \if@lmodern
    104     \RequirePackage{lmodern}\fi}
     109\if@lmodern
     110  \RequirePackage{lmodern}\fi
    105111
    106112% symbols like \Telefon, \Mobilefone, \Letter and \Email
     
    120126% hyperrefs
    121127\RequirePackage{url}
    122 \ifpdf
    123   \RequirePackage[pdftex]{hyperref}
    124 \else
    125   \RequirePackage[dvips]{hyperref}\fi
    126 \AtEndOfClass{%
    127   \AtBeginDocument{%
    128     \hypersetup{%
     128\urlstyle{tt}
     129% load hyperred at the end of the preamble to pass options required by loaded packages (like CJK)
     130\AtEndPreamble{
     131  \@ifpackageloaded{CJK}
     132    {\RequirePackage[CJKbookmarks]{hyperref}}
     133    {\RequirePackage[pdftex]{hyperref}}
     134  \AtBeginDocument{
     135    \hypersetup{
    129136      breaklinks,
    130137      baseurl       = http://,
    131138      pdfborder     = 0 0 0,
    132       pdfpagemode   = None,
    133       pdfstartview  = XYZ,
     139      pdfpagemode   = UseNone,% do not show thumbnails or bookmarks on opening
     140%      pdfstartview  = FitH,
    134141      pdfstartpage  = 1,
    135       pdfauthor     = \@firstname~\@familyname,%
    136       pdftitle      = \@title,%
    137       pdfsubject    = \@firstname~\@familyname,%
    138       pdfkeywords   = \@firstname~\@familyname{} curriculum vit\ae{},%
    139       pdfcreator    = \LaTeX{} with `moderncv' package,%
    140       pdfproducer   = \LaTeX}}}
    141 \urlstyle{tt}
    142 
    143 % tables that split across multiple pages
    144 \RequirePackage[]{longtable}
    145 % spacing between sections
    146 \setlength{\LTpre}{\smallskipamount}
    147 \setlength{\LTpost}{\smallskipamount}
    148 \setlength{\LTleft}{0pt}
    149 \setlength{\LTright}{0pt}
     142      pdfcreator    = \LaTeX{} with `moderncv' package,
     143      pdfproducer   = \LaTeX{},
     144      bookmarksopen = true,
     145      pdfauthor     = \@firstname~\@familyname,
     146      pdftitle      = \@title,
     147      pdfsubject    = \@firstname~\@familyname,
     148      pdfkeywords   = \@firstname~\@familyname{} curriculum vit\ae{}}}
     149  \pagenumbering{arabic}% has to be issued after loading hyperref
     150}
    150151
    151152% graphics
    152 \ifpdf
    153   \RequirePackage[pdftex]{graphicx}
    154 \else
    155   \RequirePackage[dvips]{graphicx}\fi
     153\RequirePackage{graphicx}
    156154
    157155% headers and footers
    158 \usepackage{fancyhdr}
    159 \fancypagestyle{plain}{%
     156\RequirePackage{fancyhdr}
     157\fancypagestyle{plain}{
    160158  \renewcommand{\headrulewidth}{0pt}
    161159  \renewcommand{\footrulewidth}{0pt}
     
    178176\setlength\columnsep{10\p@}
    179177\setlength\columnseprule{0\p@}
     178
     179% TO BE TESTED
     180%\setlength\arraycolsep{5\p@}
     181%\setlength\tabcolsep{6\p@}
     182%\setlength\arrayrulewidth{.4\p@}
     183%\setlength\doublerulesep{2\p@}
     184%\setlength\tabbingsep{\labelsep}
     185%\setlength\fboxsep{3\p@}
     186%\setlength\fboxrule{.4\p@}
     187
    180188\pagestyle{empty}
    181 \pagenumbering{arabic}
    182189\raggedbottom
    183190\onecolumn
     
    188195%-------------------------------------------------------------------------------
    189196% symbols used
    190 \providecommand*{\listitemsymbol}{\textbullet}
     197\providecommand*{\listitemsymbol}{\Neutral}%{{\fontencoding{U}\fontfamily{ding}\selectfont\tiny\symbol{'102}}}
    191198\providecommand*{\addresssymbol}{}
    192199\providecommand*{\mobilesymbol}{\Mobilefone}
     
    194201\providecommand*{\faxsymbol}{\FAX}
    195202\providecommand*{\emailsymbol}{\Letter}
     203\providecommand*{\homepagesymbol}{{\Large\ComputerMouse}}
    196204
    197205% colors
     
    230238  \def\@moderncvtheme{#2}
    231239  \def\@moderncvthemeoptions{#1}}
    232 \moderncvtheme{casual}   % default theme
    233 \AtBeginDocument{\RequirePackage[\@moderncvthemeoptions]{moderncvtheme\@moderncvtheme}}
     240\moderncvtheme{casual}% default theme
     241\AtEndPreamble{\RequirePackage[\@moderncvthemeoptions]{moderncvtheme\@moderncvtheme}}
    234242
    235243
     
    245253\renewcommand*{\fax}[1]{\def\@fax{#1}}
    246254\newcommand*{\email}[1]{\def\@email{#1}}
     255\newcommand*{\homepage}[1]{\def\@homepage{#1}}
    247256\newcommand*{\extrainfo}[1]{\def\@extrainfo{#1}}
    248 \newcommand*{\photo}[2][64pt]{\def\@photoheight{#1}\def\@photo{#2}}
     257\def\@photowidth{0pt}
     258\newcommand*{\photo}[2][64pt]{\def\@photowidth{#1}\def\@photo{#2}}
    249259\newcommand*{\quote}[1]{\def\@quote{#1}}
    250260
     
    257267\setlength{\separatorcolumnwidth}{0.025\textwidth}
    258268\newlength{\maincolumnwidth}
    259 \newcommand*{\sethintscolumnlength}[1]{
    260   \setlength{\hintscolumnwidth}{#1}%
    261   \setlength{\maincolumnwidth}{\textwidth}%
    262   \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
    263   \addtolength{\maincolumnwidth}{-\hintscolumnwidth}}
    264 \newcommand*{\sethintscolumntowidth}[1]{
    265   \settowidth{\hintscolumnwidth}{#1}%
    266   \setlength{\maincolumnwidth}{\textwidth}%
    267   \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
    268   \addtolength{\maincolumnwidth}{-\hintscolumnwidth}}
    269269% doubleitem lengths
    270270\newlength{\doubleitemmaincolumnwidth}
     
    272272\newlength{\listitemsymbolwidth}
    273273\settowidth{\listitemsymbolwidth}{\listitemsymbol{}~}
     274\newlength{\listitemmaincolumnwidth}
    274275% listdoubleitem lengths
    275276\newlength{\listdoubleitemmaincolumnwidth}
    276277% recompute all the lengths that depends on the text width
     278\newcommand*{\recomputethemelengths}{}
    277279\newcommand*{\recomputelengths}{%
    278280  \setlength{\quotewidth}{0.65\textwidth}%
    279   \sethintscolumnlength{\hintscolumnwidth}%
     281  % main lenghts
     282  \setlength{\maincolumnwidth}{\textwidth}%
     283  \addtolength{\maincolumnwidth}{-\separatorcolumnwidth}%
     284  \addtolength{\maincolumnwidth}{-\hintscolumnwidth}%
     285  % listitem lengths
     286  \setlength{\listitemmaincolumnwidth}{\maincolumnwidth}%
     287  \addtolength{\listitemmaincolumnwidth}{-\listitemsymbolwidth}%
    280288  % doubleitem lengths
    281289  \setlength{\doubleitemmaincolumnwidth}{\maincolumnwidth}%
     
    288296  \setlength{\listdoubleitemmaincolumnwidth}{0.475\listdoubleitemmaincolumnwidth}%
    289297  % fancyhdr lengths
    290   \renewcommand{\headwidth}{\textwidth}}
    291 \sethintscolumnlength{0.15\textwidth}
     298  \renewcommand{\headwidth}{\textwidth}%
     299  \recomputethemelengths}
     300\setlength{\hintscolumnwidth}{0.15\textwidth}
    292301\recomputelengths
    293302
    294303% makes the cv title
    295 \renewcommand*{\maketitle}{}%
     304%\newcommand*{\maketitle}{}%
     305\title{}% to avoid LaTeX complaining that \maketitle is a called without first a call to \title
    296306
    297307% draws a colored rectangle
     
    299309%\newcommand*{\colorrule}[2][1ex]{{\color{sectionrectanglecolor}{\rule{#2}{#1}}}}
    300310
    301 \newif\if@sectionopen\@sectionopenfalse
    302 \newif\if@firstcvlineofsection\@firstcvlineofsectionfalse % bug if initially set to true...
    303 % usage: \closesection{} to force a section to be closed (and the tabular layout it generates)
    304 \newcommand*{\closesection}{%
    305   \if@sectionopen%
    306     \end{longtable}%
    307 %    \phantomsection% reset the anchor for hyperrefs
    308 %    \par\null%
    309     \@sectionopenfalse\fi}
    310 \AtEndDocument{\closesection{}}
    311 % usage: \section{<title>}, or \emptysection{}
     311% usage: \section{<title>}
    312312\newcommand*{\section}[1]{%
    313   \closesection{}%
    314   \@sectionopentrue%
     313  \vspace*{2.5ex}%
     314  \parbox[m]{\hintscolumnwidth}{\raggedleft\hintfont{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}}}%
    315315  \phantomsection{}% reset the anchor for hyperrefs
    316316  \addcontentsline{toc}{part}{#1}%
    317   \begin{longtable}[l]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    318   {\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}} &\sectionstyle{#1}\\[1ex]%
    319   \@firstcvlineofsectiontrue%
    320   }
    321 \newcommand*{\emptysection}{%
    322   \closesection{}%
    323   \@sectionopentrue%
    324   \begin{longtable}[l]{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
    325   \@firstcvlineofsectiontrue%
    326   }
    327 
    328 % usage (inside section): \subsection{title}
     317  \hspace{\separatorcolumnwidth}%
     318  \parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}%
     319  \par\nobreak\vskip 1ex\@afterheading}% to avoid a pagebreak after the heading
     320% starred variant, which is identical but defined to allow its use (e.g. for natbib compatibility, who uses \section*{} for the bibliography header)
     321\AtEndPreamble{%
     322  \@ifpackageloaded{natbib}
     323    {
     324      \RequirePackage{suffix}
     325      \WithSuffix\newcommand\section*{\section}
     326    }{}
     327}
     328
     329% usage: \subsection{title}
    329330\newcommand*{\subsection}[1]{%
    330   \cvline[0.65em]{}{\subsectionstyle{#1}}}
    331 
    332 % usage (inside section): \cvline{leftmark}{text}
     331  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
     332          \raggedleft\hintfont{} &{\subsectionstyle{#1}}%
     333  \end{tabular}%
     334  \par\nobreak\vskip 0.5ex\@afterheading}% to avoid a pagebreak after the heading
     335%  \phantomsection{}% reset the anchor for hyperrefs
     336%  \addcontentsline{toc}{chapter}{#1}% does not work, the bookmark is placed at the same level as sections (placed themselves at part level to be visible, as hyperref does not allow sections without parents...)
     337
     338% usage: \cvline{margintext}{linetext}
    333339\newcommand*{\cvline}[3][.25em]{%
    334   \if@firstcvlineofsection%
    335     \@firstcvlineofsectionfalse%
    336   \else%
    337     \\[#1]\fi%
    338   \raggedleft\hintfont{#2} &#3}
    339 
    340 % usage (inside section}: \cvdoubleitem{subtitle}{text}{subtitle}{text}
     340  \begin{tabular}{@{}p{\hintscolumnwidth}@{\hspace{\separatorcolumnwidth}}p{\maincolumnwidth}@{}}%
     341          \raggedleft\hintfont{#2} &{#3}%
     342  \end{tabular}\\[#1]}
     343
     344% usage: \cvdoubleitem{subtitle}{text}{subtitle}{text}
    341345\newcommand*{\cvdoubleitem}[4]{%
    342346 \cvline{#1}{\begin{minipage}[t]{\doubleitemmaincolumnwidth}#2\end{minipage}%
     
    344348 \begin{minipage}[t]{\hintscolumnwidth}\raggedleft\hintfont{#3}\end{minipage}\hspace*{\separatorcolumnwidth}\begin{minipage}[t]{\doubleitemmaincolumnwidth}#4\end{minipage}}}
    345349
    346 % usage (inside section): \cvlistitem{point1}
     350% usage: \cvlistitem[symbol]{point1}
    347351\newcommand*{\cvlistitem}[2][\listitemsymbol{}]{%
    348   \cvline[0pt]{}{#1~#2}}
    349 
    350 % usage (inside section): \cvlistdoubleitem{point1}{point2}
     352  \cvline[0pt]{}{#1~\begin{minipage}[t]{\listitemmaincolumnwidth}#2\end{minipage}}}
     353
     354% usage: \cvlistdoubleitem[symbol]{point1}{point2}
    351355\newcommand*{\cvlistdoubleitem}[3][\listitemsymbol{}]{%
    352356  \cvline[0pt]{}{#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
     
    356360    {#1~\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#3\end{minipage}}}}
    357361
    358 % usage : \cventry{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
     362% usage: \cventry{years}{degree/job title}{institution/employer}{localization}{optionnal: grade/...}{optional: comment/job description}
    359363\newcommand*{\cventry}[6]{%
    360364  \cvline{#1}{%
     
    364368    \ifthenelse{\equal{#5}{}}{}{, #5}%
    365369    .%
    366     \ifthenelse{\equal{#6}{}}{}{\newline{}\small#6}
    367     }}%
    368 %  \ifthenelse{\equal{#6}{}}{}{\cvline[0pt]{}{\small#6}}}
     370    \ifx&#6&%
     371      \else{\newline{}\begin{minipage}[t]{\linewidth}\small#6\end{minipage}}\fi%
     372  }}%
    369373
    370374% usage (inside 'language' cvsection environment): \cvlanguage{name}{level}{comment}
     
    376380  \cvdoubleitem{#1}{\small#2}{#3}{\small#4}}
    377381
    378 % usage: \weblink[optional text]{link}
    379 \newcommand*{\weblink}[2][]{%
     382% usage: \link[optional text]{link}
     383\newcommand*{\link}[2][]{%
    380384  \ifthenelse{\equal{#1}{}}%
    381     {\def\@linktext{#2}}%
    382     {\def\@linktext{#1}}%
    383   \href{#2}{\@linktext{}}}
     385    {\href{#2}{#2}}%
     386    {\href{#2}{#1}}}
    384387
    385388% usage: \httplink[optional text]{link}
    386389\newcommand*{\httplink}[2][]{%
    387390  \ifthenelse{\equal{#1}{}}%
    388     {\def\@linktext{#2}}%
    389     {\def\@linktext{#1}}%
    390   \href{http://#2}{\@linktext{}}}
     391    {\href{http://#2}{#2}}%
     392    {\href{http://#2}{#1}}}
    391393
    392394% usage: \emaillink[optional text]{link}
    393395\newcommand*{\emaillink}[2][]{%
    394396  \ifthenelse{\equal{#1}{}}%
    395     {\def\@linktext{#2}}%
    396     {\def\@linktext{#1}}%
    397   \href{mailto:#2}{\@linktext{}}}
     397    {\href{mailto:#2}{#2}}%
     398    {\href{mailto:#2}{#1}}}
    398399
    399400% usage: \nopagenumbers{}
    400401\newif\if@displaypagenumbers\@displaypagenumberstrue
    401402\newcommand*{\nopagenumbers}{\@displaypagenumbersfalse}
     403\AtEndPreamble{%
    402404\AtBeginDocument{%
    403405  \if@displaypagenumbers%
    404406    \@ifundefined{r@lastpage}{}{%
    405407      \ifthenelse{\pageref{lastpage} > 1}{%
    406       \fancypagestyle{plain}{%
    407         \fancyfoot[r]{\addressfont\color{quotecolor}\footnotesize\thepage/\pageref{lastpage}}}%
    408       \pagestyle{plain}}{}}%
    409   \AtEndDocument{\label{lastpage}}%
    410   \fi}
    411 
    412 % thebibliography environment, for use with BibTeX
     408        \fancypagestyle{plain}{%
     409          \fancyfoot[r]{\addressfont\color{quotecolor}\footnotesize\thepage/\pageref{lastpage}}}%
     410        \pagestyle{plain}}{}}%
     411    \AtEndDocument{\label{lastpage}}\else\fi}}
     412
     413% thebibliography environment, for use with BibTeX and possibly multibib
    413414\newcommand{\refname}{Publications}
    414415\newlength{\bibindent}
    415416\setlength{\bibindent}{1.5em}
    416 % trick to force the previous section to close before the thebibliography environment
    417 \let\oldbibliography\bibliography
    418 \renewcommand*{\bibliography}[1]{%
    419   \closesection{}%
    420   \oldbibliography{#1}}
    421417% bibliography item label
    422418\newcommand*{\bibliographyitemlabel}{}% use \@biblabel{\arabic{enumiv}} for BibTeX labels
     419%\newif\if@multibibfirstbib\@multibibfirstbibfalse
     420% bibliography head (section, etc}, depending on whether multibib is used
     421\newcommand*{\bibliographyhead}[1]{\section{#1}}
     422\AtEndPreamble{\@ifpackageloaded{multibib}{\renewcommand*{\bibliographyhead}[1]{\subsection{#1}}}{}}
     423% thebibliography environment definition
    423424\newenvironment{thebibliography}[1]%
    424425  {%
    425     \section{\refname}%
    426     \closesection{}%
    427     \vspace*{-1.65em}%
     426    \bibliographyhead{\refname}%
    428427    \small%
    429428    \begin{list}{\bibliographyitemlabel}%
     
    449448\let\@openbib@code\@empty
    450449
    451 % the classical \today definition
     450% itemize, enumerate and description environment
     451\setlength{\leftmargini}   {1.2em}
     452\leftmargin\leftmargini
     453\setlength{\leftmarginii}  {1em}
     454\setlength{\leftmarginiii} {1.87em}
     455\setlength{\leftmarginiv}  {1.7em}
     456\setlength{\leftmarginv}   {1em}
     457\setlength{\leftmarginvi}  {1em}
     458\setlength{\labelsep}      {.5em}
     459\setlength{\labelwidth}    {\leftmargini}
     460\addtolength{\labelwidth}  {-\labelsep}
     461\@beginparpenalty -\@lowpenalty
     462\@endparpenalty   -\@lowpenalty
     463\@itempenalty     -\@lowpenalty
     464% itemize labels
     465\newcommand\labelitemi{\listitemsymbol{}}
     466\newcommand\labelitemii{{\large\bfseries-}}
     467\newcommand\labelitemiii{\textperiodcentered}%{\textasteriskcentered}
     468\newcommand\labelitemiv{\textperiodcentered}
     469% enumerate labels
     470\renewcommand\theenumi{\@arabic\c@enumi}
     471\renewcommand\theenumii{\@alph\c@enumii}
     472\renewcommand\theenumiii{\@roman\c@enumiii}
     473\renewcommand\theenumiv{\@Alph\c@enumiv}
     474\newcommand\labelenumi{\theenumi.}
     475\newcommand\labelenumii{(\theenumii)}
     476\newcommand\labelenumiii{\theenumiii.}
     477\newcommand\labelenumiv{\theenumiv.}
     478\renewcommand\p@enumii{\theenumi}
     479\renewcommand\p@enumiii{\p@enumii(\theenumii)}
     480\renewcommand\p@enumiv{\p@enumiii\theenumiii}
     481% description label
     482\newcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\bfseries#1}
     483% hooks to adjust spacing (idea by Jakob SchiÞtz; see http://dcwww.camd.dtu.dk/~schiotz/comp/LatexTips/tweaklist.sty)
     484\RequirePackage{tweaklist}% distributed with moderncv, not found on ctan and slightly modified
     485\renewcommand*{\itemhook}{
     486  \setlength{\topsep}{0pt}%
     487  \setlength{\itemsep}{0pt}}
     488\renewcommand*{\enumhook}{\itemhook{}}
     489\renewcommand*{\deschook}{\itemhook{}}
     490
     491% classical \today definition
    452492\def\today{\ifcase\month\or
    453493  January\or February\or March\or April\or May\or June\or
Note: See TracChangeset for help on using the changeset viewer.