I am attempting to define a macro that can be used to specify the names of committee members for a thesis/dissertation. I would like to allow the user to specify this command multiple times to add multiple committee members, as can be done in the mitthesis class file.
Looking at the mitthesis class file I got the idea to use a box to combine the calls to the macro. The way they do it is:
% since there can be more than one supervisor,
% we build the appropriate boxes for the titlepage and
% the abstractpage as the user makes multiple calls
% to \supervisor
\newbox\@titlesupervisor \newbox\@abstractsupervisor
\def\supervisor#1#2{\setbox\@titlesupervisor\vbox
{\unvbox\@titlesupervisor \vskip 10pt% plus 1fil minus 1fil
\def\baselinestretch{1}\large
\signature{Certified by}{#1 \\ #2 \\ Thesis Supervisor}}
\setbox\@abstractsupervisor\vbox{\unvbox\@abstractsupervisor
\vskip\baselineskip \def\baselinestretch{1}\@normalsize
\par\noindent Thesis Supervisor: #1 \\ Title: #2}}
From what I've read we could do something similar with a save box so I tried something like this:
% We need to allow for multiple calls to committee
% Therefore start building the committee section of the title page
% Each call to committee should first specify the name as arg 1, and
% then the degree as arg 2
% for instance \committee{John Doe}{Ph.D.}
\newsavebox\@committeebox
\def\committee#1#2{%
\sbox{\@committeebox}{%
\usebox{\@committeebox}\\%
\bfseries
#1, #2%
}%
}
but for some reason this only displays the first committee member that is added.
I tested the idea by adding a
\sbox{\@committeebox}{test}
before the \def in the above example (after the \newsavebox) which works somewhat by adding 'test' to the output before the first specified committee member, although it doesn't move things to a new line like I thought it should (I get testJane Doe, Ph.D. like this but it still doesn't display the other specified committee member.
Can somebody see what is going wrong here or give me a reason this will not work? Obviously I could just use what mitthesis does but I am asking this to try and get a better understanding of the way things are going on.
As a mwe you could have
\documentclass{sample}
\committee{Jane Doe}{MS}
\committee{John Doe}{Ph.D.}
\begin{document}
\maketitle
\end{document}
as your tex file and
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sample}[2016/01/29 Sample]
\DeclareOption*{%
\ClassWarning{sample}{No options permitted}%
}
\ProcessOptions\relax
\LoadClass{report}
\def\maketitle{%
\begin{center}
\usebox{\@committeebox}
\end{center}
}
as your sample.cls file.

mweshould havesampleas document class, nottest;-) – Feb 01 '16 at 19:49