2

I am using the MIT Thesis templates to write my thesis. I have created my own document class (that reflects the needs of the university I'm studying at) based on the mitthesis.cls version. Since it is possible to have more than one supervisor, the MIT class implements a vbox for storing the list of supervisors and a command to add them. The main problem I'm having is that I can't figure out how to horizontally center the vbox containing the supervisor list. It is always displayed aligned to the left margin. The code below is what I'm working with.

\supervisor{First Supervisor}   <= add 1st supervisor
\supervisor{Second Supervisor}  <= add 2nd supervisor
[...]
% store the supervisor list in a box
\newbox\@titlesupervisor
% since there can be more than one supervisor,
% we build the box for the titlepage
% as the user makes multiple calls
% to \supervisor
\def\supervisor#1{\setbox\@titlesupervisor\vbox
  {\unvbox\@titlesupervisor \vskip 10pt
   \def\baselinestretch{1}\large
   {#1}
  }
}
[...]
% Print the supervisor list after the heading, author, etc.
\textbf{Supervisor(s)}\par
\unvbox\@titlesupervisor
\vfill

I don't fully understand what \unvbox does, but I think it has something to do with vertical margin expansion to fit the text because if I remove the last \unvbox, the first supervisor disappears in the pdf.

Another problem I have is that I can't figure out is how to determine the number of entries in the supervisor list so I can decide whether to print "Supervisor" singularly or plurally? Do I need to implement a counter in the add command or can I get the number somehow from the supervisor#1 or titlesupervisor variables?

1
  • By using that code, you just get paragraphs, so lines as wide as the \hsize, so there's no hope of “centering” them.
    – egreg
    Dec 29 '15 at 11:51
2

I'd go with a different strategy:

\let\@titlesupervisor\@empty % initialize
\newif\if@supervisors
\def\supervisor#1{%
  \ifx\@titlesupervisor\@empty
    % do nothing, it's the first
  \else
    \@supervisorstrue % more than one supervisor
  \fi
  \g@addto@macro\@titlesupervisor{#1\\}%
}

[...]
% Print the supervisor list after the heading, author, etc.
\begin{center}
  \if@supervisors
    \textbf{Supervisors}
  \else
    \textbf{Supervisor}
  \fi
  \begin{tabular}{@{}l@{}}
  \@titlesupervisor
  \end{tabular}
\end{center}
2
  • The supervisor list is left justified. How would I center align within the list?
    – gone
    Dec 29 '15 at 12:23
  • Fixed it by using {tabular}{@{}c@{}}. Later I found that I didn't need tabular at all; just needed to place a \\ after \@titlesupervisor. I did need to put a \par inbetween the 'Supervisor' label and the list.
    – gone
    Dec 29 '15 at 16:42

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.