3

For a PhD thesis cover template in our university, there is some code as follow:

%%% Jury member n1 (Président) %%%
\newcommand{\jurynameA}{M. Cabot}
\newcommand{\juryadressA}{Someplace}
\newcommand{\jurygradeA}{Somerank}
\newcommand{\juryroleA}{Président du jury}
%%% Jury member n2 (Rapporteur) %%%
\newcommand{\jurynameB}{M. Blonde}
\newcommand{\juryadressB}{Anotherplace}
\newcommand{\jurygradeB}{Anotherrank}
\newcommand{\juryroleB}{Rapporteur} % 
%%% Jury member n3 (Rapporteur) %%%
\newcommand{\jurynameC}{M. Blue}
\newcommand{\juryadressC}{Someotherplace}
\newcommand{\jurygradeC}{Someotherrank}
\newcommand{\juryroleC}{Rapporteur}
%%% Jury member n4 (Examinateur) %%%
\newcommand{\jurynameD}{M. Brown}
\newcommand{\juryadressD}{Yetanotherplace}
\newcommand{\jurygradeD}{Yetanotherrank}
\newcommand{\juryroleD}{Examinateur}
%%% Jury member n5 (Examinateur) %%%
\newcommand{\jurynameE}{M. Orange}
\newcommand{\juryadressE}{Onemoreplace}
\newcommand{\jurygradeE}{One more rank}
\newcommand{\juryroleE}{Examinateur}
%%% Jury member n6 (Directeur) %%%
\newcommand{\jurynameF}{M. Pink}
\newcommand{\juryadressF}{Yourplace}
\newcommand{\jurygradeF}{HDR}
\newcommand{\juryroleF}{Directeur de thèse}
%%% Jury member n7 (Co-Directeur) %%%
\newcommand{\jurynameG}{M. White}
\newcommand{\juryadressG}{Yourotherplace}
\newcommand{\jurygradeG}{HDR?}
\newcommand{\juryroleG}{Co-Directeur de thèse}
\begin{tabular}{lll}

    \textsc{\jurynameA}  & \jurygradeA & (\juryroleA) \\
    \null  & \textit{\juryadressA} & \\

    \textsc{\jurynameB}  & \jurygradeB & (\juryroleB) \\
    \null  & \textit{\juryadressB} & \\

    \textsc{\jurynameC}  & \jurygradeC & (\juryroleC) \\
    \null  & \textit{\juryadressC} & \\

    \textsc{\jurynameD}  & \jurygradeD & (\juryroleD) \\
    \null  & \textit{\juryadressD} & \\

    \textsc{\jurynameE}  & \jurygradeE & (\juryroleE) \\
    \null  & \textit{\juryadressE} & \\

    \textsc{\jurynameF}  & \jurygradeF & (\juryroleF) \\
    \null  & \textit{\juryadressF} & \\

    \textsc{\jurynameG}  & \jurygradeG & (\juryroleG) \\
    \null  & \textit{\juryadressG} & \\

\end{tabular}

I was wondering if it would be possible to input data more easily (something like \addmember{M. Pink}{Yourplace}{HDR}{Directeur de thèse}), and then have the table generated automatically without worrying about the number of jury members (some people may have 4 members, some up to 8).

In Python for instance, I would have used a list of dict (or just of lists if I did not care about semantics), each dict describing a jury member, and would have iterated over that list to write the table. Is it possible to do something like that with LaTeX?

  • pgfplotstable allows you to typeset a table from a dataset you load. – marmot Feb 28 at 0:18
4

Here's one way to do it using standard LaTeX methods from etoolbox and pgffor.

\documentclass{article}
\usepackage{pgffor,etoolbox,array}
\newcounter{members}
\newcommand{\addmember}[4]{%
\ifnum\value{members}=8
    \typeout{Warning: your committee has too many members! Extra members ignored.}
\else
    \stepcounter{members}
    \csgdef{juryname\themembers}{#1}
    \csgdef{juryadress\themembers}{#2}
    \csgdef{jurygrade\themembers}{#3}
    \csgdef{juryrole\themembers}{#4}
\fi
}
\newcommand{\thecommitee}{}
\makeatletter
\newcommand{\makecommittee}{%
\foreach \x in {1,...,\value{members}}{
\protected@xappto{\thecommittee}{%
\csuse{juryname\x} &
\csuse{jurygrade\x} &
(\csuse{juryrole\x})\tabularnewline
&\itshape\csuse{juryadress\x} &\tabularnewline
}
}
\begin{tabular}{>{\scshape}lll}
\thecommittee
\end{tabular}
}
\makeatother
\begin{document}
\addmember{M. Cabot}{Montréal}{PhD}{Président du jury}
\addmember{M. Blonde}{Trois Rivières}{PhD}{Rapporteur}
\addmember{M. Brun}{Québec}{PhD}{Examinateur}
\addmember{M. Vert}{Paris}{PhD}{Examinateur}
\addmember{M. Gris}{Montréal}{PhD}{Directeur de thèse}
\makecommittee
\end{document}

output of code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.