%% start of file `moderncvstyleoldstyle.sty'.
%% Copyright 2006-2012 Xavier Danaux (xdanaux@gmail.com).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


%-------------------------------------------------------------------------------
%                identification
%-------------------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{moderncvstyleoldstyle}[2012/01/25 v0.17 modern curriculum vitae style: oldstyle]


%-------------------------------------------------------------------------------
%                required packages
%-------------------------------------------------------------------------------


%-------------------------------------------------------------------------------
%                package options
%-------------------------------------------------------------------------------


%-------------------------------------------------------------------------------
%                style definition
%-------------------------------------------------------------------------------
% fonts
\IfFileExists{kurier.sty}
  {\RequirePackage[light,math]{kurier}}
  {}
\renewcommand*{\namefont}{\fontsize{34}{36}\mdseries\upshape}
\renewcommand*{\titlefont}{\LARGE\mdseries\slshape}
\renewcommand*{\addressfont}{\small\mdseries}
\renewcommand*{\quotefont}{\large\itshape}
\renewcommand*{\sectionfont}{\Large\bfseries\upshape}
\renewcommand*{\subsectionfont}{\large\bfseries\itshape}
\renewcommand*{\hintfont}{\bfseries}

% styles
\newcommand*{\namestyle}[1]{{\namefont\textcolor{color0}{#1}}}
\newcommand*{\titlestyle}[1]{{\titlefont\textcolor{color2}{#1}}}
\newcommand*{\addressstyle}[1]{{\addressfont\textcolor{color2}{#1}}}
\newcommand*{\quotestyle}[1]{{\quotefont\textcolor{color1}{#1}}}
\newcommand*{\sectionstyle}[1]{{\sectionfont\textcolor{color1}{#1}}}
\newcommand*{\subsectionstyle}[1]{{\subsectionfont\textcolor{color1}{#1}}}
\newcommand*{\hintstyle}[1]{{\hintfont\textcolor{color0}{#1}}}

% symbols
\renewcommand*{\listitemsymbol}{\labelitemi~}
\renewcommand*{\addresssymbol}{}
\renewcommand*{\mobilesymbol}{\textbf{M}~}
\renewcommand*{\phonesymbol}{\textbf{T}~}
\renewcommand*{\faxsymbol}{\textbf{F}~}
\renewcommand*{\emailsymbol}{\textbf{E}~}
\renewcommand*{\homepagesymbol}{}

% length used
\newlength{\quotewidth}
\newlength{\hintscolumnwidth}
\setlength{\hintscolumnwidth}{0.3\textwidth}%
\newlength{\separatorcolumnwidth}
\setlength{\separatorcolumnwidth}{0.025\textwidth}%
\newlength{\maincolumnwidth}
\newlength{\doubleitemcolumnwidth}
\newlength{\listitemsymbolwidth}
\settowidth{\listitemsymbolwidth}{\listitemsymbol}
\newlength{\listitemmaincolumnwidth}
\newlength{\listdoubleitemmaincolumnwidth}

% recompute all the lengths that depends on the text width
\renewcommand*{\recomputelengths}{%
  \setlength{\quotewidth}{0.65\textwidth}%
  % main lenghts
  \setlength{\maincolumnwidth}{\textwidth-\hintscolumnwidth-\separatorcolumnwidth}%
  % listitem lengths
  \setlength{\listitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth}%
  % doubleitem lengths
  \setlength{\doubleitemcolumnwidth}{\maincolumnwidth-\separatorcolumnwidth}%
  \setlength{\doubleitemcolumnwidth}{0.5\doubleitemcolumnwidth}%
  % listdoubleitem lengths
  \setlength{\listdoubleitemmaincolumnwidth}{\maincolumnwidth-\listitemsymbolwidth-\separatorcolumnwidth-\listitemsymbolwidth}%
  \setlength{\listdoubleitemmaincolumnwidth}{0.5\listdoubleitemmaincolumnwidth}%
  % fancyhdr lengths
  \renewcommand{\headwidth}{\textwidth}}

\newcommand{\makeinfo}[1]{%
  \newbox{\makeinfobox}%
  \savebox{\makeinfobox}{\parbox[b]{\hintscolumnwidth}{\if@DEBUG\rule{20cm}{.1pt}\\\fi#1}}%
  \newlength{\makeinfoheight}%
  \setlength{\makeinfoheight}{\totalheightof{\usebox{\makeinfobox}}}% the total height of the parbox is the sum of its height (\the\ht\makeinfobox) and its depth (\the\dp\makeinfobox); the \totalheightof command is provided by the "calc" package
  \usebox{\makeinfobox}\vspace*{-\makeinfoheight}%
  \newlength{\leftcolumnwidth}%
  \setlength{\leftcolumnwidth}{\hintscolumnwidth+\separatorcolumnwidth}
  \par\nointerlineskip\vspace*{-\parskip}\vspace*{-2.5ex}\leftskip=\leftcolumnwidth\if@DEBUG\rule{20cm}{.1pt}\fi}% the -2.5ex vertical slip is to counter the 2.5ex skip of sections

\newif\if@firstdetailselement\@firstdetailselementtrue
\newcommand*{\maketitledetailsnewline}{
  \if@firstdetailselement%
  \else%
    \\[.2em]\fi%
  \@firstdetailselementfalse%
  \addressfont\color{color2}}
\renewcommand*{\maketitle}{
  % optional picture box
  \newbox{\maketitlepicturebox}%
  \savebox{\maketitlepicturebox}{%
    \ifthenelse{\isundefined{\@photo}}%
    {}%
    {%
      \color{color1}%
      \setlength\fboxrule{\@photoframewidth}%
      \ifdim\@photoframewidth=0pt%
        \setlength{\fboxsep}{0pt}\fi%
      \framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
  % name and title
  \newlength{\maketitlepicturewidth}\settowidth{\maketitlepicturewidth}{\usebox{\maketitlepicturebox}}%
  \newlength{\maketitlenamewidth}\setlength{\maketitlenamewidth}{\textwidth-\maketitlepicturewidth}%
  \begin{minipage}[b]{\maketitlenamewidth}%
    \namestyle{\@firstname\ \@familyname}%
    \ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
  \end{minipage}%
  % optional photo
  \usebox{\maketitlepicturebox}\\[2.5em]%
   % optional quote
  \ifthenelse{\isundefined{\@quote}}%
    {}%
    {{\centering{}\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
  % optional details
  \makeinfo{%
    \ifthenelse{\isundefined{\@addressstreet}}{}{\maketitledetailsnewline\addresssymbol\@addressstreet}%
    \ifthenelse{\isundefined{\@addresscity}}{}{\maketitledetailsnewline\@addresscity}%
    \ifthenelse{\isundefined{\@mobile}}{}{\maketitledetailsnewline\mobilesymbol\@mobile}%
    \ifthenelse{\isundefined{\@phone}}{}{\maketitledetailsnewline\phonesymbol\@phone}%
    \ifthenelse{\isundefined{\@fax}}{}{\maketitledetailsnewline\faxsymbol\@fax}%
    \ifthenelse{\isundefined{\@email}}{}{\maketitledetailsnewline\emailsymbol\emaillink{\@email}}%
    \ifthenelse{\isundefined{\@homepage}}{}{\maketitledetailsnewline\homepagesymbol\httplink{\@homepage}}%
    \ifthenelse{\isundefined{\@extrainfo}}{}{\maketitledetailsnewline\@extrainfo}}}

\renewcommand*{\section}[1]{%
  \par\vspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#1}%
  \parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}%
  \par\nobreak\vskip 1ex\@afterheading}% to avoid a pagebreak after the heading

\newif\@if
\renewcommand*{\subsection}[1]{%
  \par%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{subsection}{#1}%
  \subsectionstyle{#1}%
  \par\nobreak\vskip 0.5ex\@afterheading}% to avoid a pagebreak after the heading

\renewcommand*{\cvitem}[3][.25em]{%
  \ifthenelse{\equal{#2}{}}{}{{\hintfont#2}: }{#3}\\[#1]}

\renewcommand*{\cvdoubleitem}[5][.25em]{%
  \begin{minipage}[t]{\doubleitemcolumnwidth}{\hintfont#2}: #3\end{minipage}%
  \hfill% fill of \separatorcolumnwidth
  \begin{minipage}[t]{\doubleitemcolumnwidth}{\hintfont#4}: #5\end{minipage}\\[#1]}

\renewcommand*{\cvlistitem}[2][.25em]{%
  \cvitem[#1]{}{\listitemsymbol\begin{minipage}[t]{\listitemmaincolumnwidth}#2\end{minipage}}}

\renewcommand*{\cvlistdoubleitem}[3][.25em]{%
  \cvitem[#1]{}{\listitemsymbol\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#2\end{minipage}%
  \hfill% fill of \separatorcolumnwidth
  \ifthenelse{\equal{#3}{}}%
    {}%
    {\listitemsymbol\begin{minipage}[t]{\listdoubleitemmaincolumnwidth}#3\end{minipage}}}}

\newbox{\cventryyearbox}
\newlength{\cventrytitleboxwidth}
\renewcommand*{\cventry}[7][.25em]{%
  \savebox{\cventryyearbox}{%
    \hspace*{2\separatorcolumnwidth}%
    {\hintfont#2}}%
  \setlength{\cventrytitleboxwidth}{\widthof{\usebox{\cventryyearbox}}}%
  \setlength{\cventrytitleboxwidth}{\maincolumnwidth-\cventrytitleboxwidth}%
  \begin{minipage}{\maincolumnwidth}%
    \parbox[t]{\cventrytitleboxwidth}{%
      {\bfseries#3}%
      \ifthenelse{\equal{#4}{}}{}{, {\slshape#4}}%
      \ifthenelse{\equal{#5}{}}{}{, #5}%
      \ifthenelse{\equal{#6}{}}{}{, #6}%
      .}%
    \usebox{\cventryyearbox}%
  \end{minipage}%
  \ifx&#7&%
    \else{%
      \newline{}\begin{minipage}[t]{\maincolumnwidth}\small#7\end{minipage}}\fi%
  \\[#1]}


\newbox{\cvitemwithcommentmainbox}
\newlength{\cvitemwithcommentmainlength}
\newlength{\cvitemwithcommentcommentlength}
\renewcommand*{\cvitemwithcomment}[4][.25em]{%
  \savebox{\cvitemwithcommentmainbox}{\ifthenelse{\equal{#2}{}}{}{{\hintfont#2}: }#3}%
  \setlength{\cvitemwithcommentmainlength}{\widthof{\usebox{\cvitemwithcommentmainbox}}}%
  \setlength{\cvitemwithcommentcommentlength}{\maincolumnwidth-\separatorcolumnwidth-\cvitemwithcommentmainlength}%
  \begin{minipage}[t]{\cvitemwithcommentmainlength}\ifthenelse{\equal{#2}{}}{}{{\hintfont#2}: }#3\end{minipage}%
  \hfill% fill of \separatorcolumnwidth
  \begin{minipage}[t]{\cvitemwithcommentcommentlength}\raggedleft\small\itshape#4\end{minipage}\\[#1]}

\renewenvironment{thebibliography}[1]%
  {%
    \bibliographyhead{\refname}%
    \small%
    \begin{list}{\bibliographyitemlabel}%
      {%
        \setlength{\topsep}{0pt}%
        \setlength{\labelwidth}{\hintscolumnwidth}%
        \setlength{\labelsep}{\separatorcolumnwidth}%
        \leftmargin\labelwidth%
        \advance\leftmargin\labelsep%
        \@openbib@code%
        \usecounter{enumiv}%
        \let\p@enumiv\@empty%
        \renewcommand\theenumiv{\@arabic\c@enumiv}}%
        \sloppy\clubpenalty4000\widowpenalty4000%
%        \sfcode`\.\@m%
%        \sfcode `\=1000\relax%
  }%
  {%
    \def\@noitemerr{\@latex@warning{Empty `thebibliography' environment}}%
    \end{list}%
  }


\endinput


%% end of file `moderncvstyleoldstyle.sty'.
