I'm trying to make a class for a cv document. As part of that document, there will be a table that contains all the education information. What I'm trying to achieve is to have some sort of template that specifies what one of these blocks of information looks like, and then have a macro that instantiates one of those blocks with the relevant data. My current attempt is trying to use pgfkeys
to handle passing the data into the macro. A stripped down version of the class looks like this:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{cv}
\LoadClass[10pt,a4paper]{article}
\RequirePackage{tabularx}
\RequirePackage{calc}
\RequirePackage{xparse}
\makeatletter
\protected\def\z#1{\pdfsavepos\write\@auxout{\gdef\string\tpos#1{\the\pdflastxpos}}}%
\def\foo#1#2{\ifcsname tpos#1\endcsname\the\dimexpr\csname tpos#2\endcsname sp -\dimexpr\csname tpos#1\endcsname sp\relax\fi}
\makeatother
\RequirePackage{pgfkeys}
\pgfkeys{
/education/.is family, /education,
title/.estore in=\educationtitle,
programme/.estore in=\educationprogramme,
notes/.estore in=\educationnotes,
notes/.default={},
institute/.estore in=\educationinstitute,
thesisheader/.estore in=\educationthesisheader,
thesisheader/.default=Thesis:,
thesistitle/.estore in=\educationthesistitle,
selectedcourses/.estore in=\educationselectedcourses,
selectedcourses/.default={},
dates/.estore in=\educationdates,
}
\newenvironment{education}{
\setlength{\tabcolsep}{5pt}
\setlength{\extrarowheight}{0pt}
\begin{tabular}{!{\z{a}}r!{\z{b}}p{(\textwidth-\foo{a}{b})-\tabcolsep}}
}{
\end{tabular}
}
\NewDocumentCommand{\educationitem}{o}{
\pgfkeys{/education,notes,selectedcourses,thesisheader,#1}
\educationdates{} & \textbf{\educationtitle{}} \\
& \educationprogramme{} \\
& \educationnotes{} \\
& \textit{\educationinstitute{}} \\
\educationthesisheader{} & \educationthesistitle{} \\
Selected courses: & \educationselectedcourses{} \\
}
(There is some special stuff going on with the width of the columns, such that the second column fills out the remaining available width. I took this from some other answer here some time ago.)
I would ideally then use the class something like this:
\documentclass{cv}
\begin{document}
\begin{education}
\educationitem[
title={Master of Science},
programme={Some programme},
notes={Some notes about the degree},
institute={Some institute},
dates={2014--2017},
thesistitle={The title of the thesis},
selectedcourses={Some list of courses that might get pretty long, filling out the usable space of the row.},
]{}
\educationitem[
title={Bachelor of Science},
programme={Some other programme},
notes={Some more notes about the degree},
institute={Some other institute},
dates={2011--2014},
thesisheader={Honours thesis:},
thesistitle={The title of the thesis},
selectedcourses={Some list of courses that might get pretty long, filling out the usable space of the row.},
]{}
\end{education}
\end{document}
This should hopefully yield a table looking like this:
Unfortunately, instead I get an Undefined control sequence
error on usage of the \educationitem
macro. I just asked a question about this, but I simplified the situation a bit too much, leading to answers that don't work for my actual intent. (The XY-problem strikes again...)
So here's my real question: how can I construct a macro that can be used roughly as above to give the result I want? Solutions using pgfkeys
are slightly preferred, but I'm not particularly attached to what I have so far. Hopefully I've supplied the correct amount of information this time!