Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CV LaTeX class
% cvdatabase.cls
% Copyright 2012 David Zaslavsky
% Based on resume.cls, copyright 2005 Daniel Burrows
%
% You may use, modify, and redistribute this file in any way you please, so
% long as this copyright notice is maintained.
% A work in progress
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cvdatabase}
\LoadClassWithOptions{article}
% No page numbers by default.
\pagestyle{empty}
\RequirePackage{etoolbox}
\RequirePackage{calc}
\RequirePackage{ifthen}
\RequirePackage{url}
\RequirePackage{tabularx}
\RequirePackage{tikz}
\RequirePackage{xxcolor}
\RequirePackage{verbatim}
\RequirePackage{xparse}
\RequirePackage{times}
\RequirePackage[T1]{fontenc}
\RequirePackage[tmargin=1in,bmargin=1in]{geometry}
\definecolor{rulestartcolor}{rgb}{0,0,0}
\definecolor{ruleendcolor}{rgb}{0.4,0.4,0.4}
\newlength{\headerbuffer}
\setlength{\headerbuffer}{0pt}
\newlength{\secskip}
\setlength{\secskip}{6pt}
\newlength{\@headerscratch}
\newcommand{\@position}{}
\newcommand{\@institution}{}
\newcommand{\@authorname}{}
\newcommand{\@email}{}
\newcommand{\@streetaddress}{}
\newcommand{\@citystatezip}{}
\newcommand{\@phone}{}
\newcommand{\@webpage}{}
\pgfdeclarehorizontalshading{@pastelshading}{100bp}{
color(0pt)=(red!30!white);
color(25pt)=(red!30!white);
color(35bp)=(orange!30!white);
color(45bp)=(yellow!50!white);
color(55bp)=(green!30!white);
color(65bp)=(blue!20!white);
color(75bp)=(purple!30!white);
color(100bp)=(purple!30!white)
}%
\NewDocumentCommand\pastellogo{}{%
\begin{pgfpicture}
\pgfpathrectanglecorners{\pgfpoint{0mm}{5mm}}{\pgfpoint{25mm}{-3mm}}
\pgfusepath{use as bounding box}
\pgfsetlinewidth{3mm}
\pgfsetcolor{gray!5!white}
\pgfpathcircle{\pgfpoint{-46mm}{11mm}}{35mm}
\pgfusepath{draw}
\pgfsetcolor{gray!15!white}
\pgfsetlinewidth{2mm}
\pgfpathcircle{\pgfpoint{-14mm}{-2mm}}{4mm}
\pgfusepath{draw}
\pgfsetlinewidth{3mm}
\pgfpathcircle{\pgfpoint{11mm}{16mm}}{6mm}
\pgfusepath{draw}
\pgfsetlinewidth{4mm}
\pgfsetcolor{gray!20!white}
\pgfpathcircle{\pgfpoint{0}{2mm}}{10mm}
\pgfusepath{draw}
\begin{pgfscope}
\pgfpathmoveto{\pgfpoint{-8mm}{2mm}}
\pgfpatharc{180}{270}{8mm}
\pgfpathlineto{\pgfpoint{1.5\linewidth}{-6mm}}
\pgfpathlineto{\pgfpoint{1.5\linewidth}{2mm}}
\pgfpathlineto{\pgfpoint{-8mm}{2mm}}
\pgfpathclose
\pgfusepath{clip}
\pgfpathrectangle{\pgfpoint{-24pt}{0pt}}{\pgfpoint{\linewidth}{1.5pt}}
\pgfshadepath{@pastelshading}{0}
\end{pgfscope}
\pgfsetcolor{black}
\pgftext[base,left,y=2mm]{\Large\@authorname}
\pgftext[base,right,y=2mm,x=\linewidth-24pt]{\small\@position{} --- \@institution}
\end{pgfpicture}%
}
\renewcommand{\author}[1]{\renewcommand{\@authorname}{#1}}
\newcommand{\position}[1]{\renewcommand{\@position}{#1}}
\newcommand{\institution}[1]{\renewcommand{\@institution}{#1}}
\newcommand{\email}[1]{\urldef{\@email}{\url}{#1}}
\newcommand{\streetaddress}[1]{\renewcommand{\@streetaddress}{#1}}
\newcommand{\citystatezip}[1]{\renewcommand{\@citystatezip}{#1}}
\newcommand{\phone}[1]{\renewcommand{\@phone}{#1}}
\newcommand{\webpage}[1]{\urldef{\@webpage}{\url}{#1}}
\renewcommand{\maketitle}{{%
\setlength{\@headerscratch}{\linewidth*2/3}%
\noindent \pastellogo%
\vspace{\headerbuffer}%
\hspace{\linewidth}%
\hspace{-\@headerscratch}%
\par\nointerlineskip\noindent%
% Typeset webpage/phone in columns if both are specified, or
% just on the LHS if only one is.
\begin{small}%
\ifthenelse{\equal{\@streetaddress}{} \and \equal{\@citystatezip}{}}{%
% if no address or city/state/zip provided
\ifthenelse{\equal{\@webpage}{}}{%
% if webpage is blank, just typeset phone number
\ifthenelse{\equal{\@phone}{}}{%
}{%
\@phone\par\nointerlineskip\noindent%
}%
}{%
% otherwise
\ifthenelse{\equal{\@phone}{}}{%
% if phone is blank, just typeset webpage
\@webpage\par\nointerlineskip\noindent%
}{%
% otherwise put both in a table
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}%
\@phone & \@webpage%
\end{tabular*}%
\par\nointerlineskip\noindent%
}%
}%
}{%
\ifthenelse{\equal{\@citystatezip}{}}{%
% if only address provided
\ClassError{cvdatabase}{%
No definition for \protect\citystatezip given
}{%
You must provide a city, state, and zip code with \protect\citystatezip
to include an address.
}%
}{%
\ifthenelse{\equal{\@phone}{}}{%
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}%
\@streetaddress & \@webpage \\%
\@citystatezip &
\end{tabular*}%
}{%
\begin{tabular*}{\linewidth}{l@{\extracolsep{\fill}}r}%
\@streetaddress & \@phone \\%
\@citystatezip & \@webpage
\end{tabular*}%
}%
}%
}%
\end{small}
}}
\def\@CurrentSection{}
\def\@CurrentSubsection{}
\def\@CurrentMode{test1}
\NewDocumentCommand\setmode{m}{\def\@CurrentMode{#1}}
\def\@TypesetCurrentSection{%
\expandafter\ifstrequal\expandafter{\@CurrentSection}{}{}{%
\goodbreak\vspace{\secskip}%
\par\nointerlineskip\noindent%
\begin{pgfpicture}
\pgfsetfillcolor{gray!15!white}
\pgfpathrectangle{\pgfpoint{-3.2ex}{-1.5ex}}{\pgfpoint{3ex}{3ex}}
\pgfusepath{fill}
\pgfpathrectangle{\pgfpoint{0ex}{-1.5ex}}{\pgfpoint{\textwidth-3.2ex}{3ex}}
\pgfusepath{fill}
\pgfnode{rectangle}{west}{\color{black}\scshape\@CurrentSection}{sectionnode}{}
\end{pgfpicture}
\gdef\@CurrentSection{}%
\vspace{\headerbuffer}\par\nointerlineskip\noindent%
%\lrule{\linewidth}{0.4pt}%
% \vspace{\headerbuffer}\par\nointerlineskip
}%
}
\def\@TypesetCurrentSubsection{%
\expandafter\ifstrequal\expandafter{\@CurrentSubsection}{}{}{%
\goodbreak\vspace{\secskip}\par\nointerlineskip\vspace{-1em}\small\textsf{\flushleft{\@CurrentSubsection}:}\par%\nointerlineskip%
\gdef\@CurrentSubsection{}%
}%
}
\newbool{outputon}
\booltrue{outputon}
\NewDocumentCommand\@ProcessMode{m m}{
\expandafter\ifstrequal\expandafter{\@CurrentMode}{#2}{% if the given mode is the current mode
\@TypesetCurrentSection% typeset the section header, if any
\@TypesetCurrentSubsection% and the subsection header, if any
#1%
}{\boolfalse{outputon}}%
}
\RenewDocumentCommand{\section}{m}{\gdef\@CurrentSection{#1}\gdef\@CurrentSubsection{}}
\RenewDocumentCommand{\subsection}{m}{\gdef\@CurrentSubsection{#1}}
% General catch-all for either educational or job affiliation.
%
% Usage:
% \affiliation<section>[title]{institution}{years}
\NewDocumentCommand\@affiliation{o m m}{%
\goodbreak\vspace{\secskip}\par\noindent\begin{tabularx}{\linewidth}{Xr}%
{\bfseries #2} & \textit{#3}%
\IfNoValueTF{#1}{}{%
\\ {\mdseries\sffamily\small #1}%
}%
\end{tabularx}%
}
\NewDocumentEnvironment{affiliation}{d<> o m m}{%
\IfNoValueTF{#1}{\booltrue{outputon}}{%
\forcsvlist{\@ProcessMode{\@affiliation[#2]{#3}{#4}}}{#1}%
}%
\notbool{outputon}{\comment}{}
}{%
\notbool{outputon}{\endcomment}{}
}
% Usage:
% \publication{title}{collaborators}{date}
\NewDocumentCommand\@publication{m m m m}{%
\goodbreak\vspace{\secskip}\par\noindent%
\begin{tabularx}{\linewidth}{Xr}%
\textit{#1} & \\%
\ifthenelse{\equal{#2}{}}{}{{\mdseries\small \hspace{1cm} with #2} & \\}%
{\mdseries\small \hspace{1cm} #3} & %
\ifthenelse{\equal{#4}{}}{}{\\ {\mdseries\small \hspace{1cm} #4} & }%
\end{tabularx}%
}%
\NewDocumentCommand\publication{d<> m O{} m O{}}{%
\IfNoValueTF{#1}{\booltrue{outputon}}{\forcsvlist{\@ProcessMode{\@publication{#2}{#3}{#4}{#5}}}{#1}}
}%
\NewDocumentEnvironment{anytext}{d<>}{%
\IfNoValueTF{#1}{\booltrue{outputon}}{%
\forcsvlist{\@ProcessMode{}}{#1}%
}%
\notbool{outputon}{\comment}{}
}{%
\notbool{outputon}{\endcomment}{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment