0

I'm attempting to venture into some more advanced LaTeX by creating a custom thesis class for my university studies, as the existing examples are somewhat outdated and not to spec with the current style guides. As an additional aspect, I added some options that allow me to somewhat change the wording of the titlepage based on whether or not I'm using the class for a personal project or a formal dissertation.

I'm running into an issue with the redefinition of \maketitle where the \end statement of the center environment is cut off and bleeds into the document at large.

main.tex:

\documentclass[project]{diythesis}

\title{Construction of a Difficult, Error-Prone LaTeX Thesis Class}
\author{Not Another Author}
\degreeName{Bachelor of Science}
\majorName{Unknown Studies}
\date{August 2022}

\begin{document}
    \maketitle

    \section{Introduction}
    
    blah blah blah
\end{document}

diythesis.cls:

% --------------------------------------------------------------------------- %
% Configure basic class information and options.                              %
% --------------------------------------------------------------------------- %
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{diythesis}[2022/08/16]
\RequirePackage{etoolbox}
\newtoggle{project}
\newtoggle{thesis}
\newtoggle{strict}
\DeclareOption{project}{\toggletrue{project}\togglefalse{thesis}}
\DeclareOption{thesis}{\toggletrue{thesis}\togglefalse{project}}
\DeclareOption{strict}{\toggletrue{strict}}
\ProcessOptions\relax
\LoadClass[12pt,titlepage,twoside]{report}

\RequirePackage{fontspec,geometry,fancyhdr,afterpage,graphicx}
\RequirePackage{amsmath,amssymb,amsbsy}
\RequirePackage{dcolumn,tocloft}

% --------------------------------------------------------------------------- %
% Configure basic page geometry and XeLaTeX font options.                     %
% --------------------------------------------------------------------------- %
\geometry{
    top    = 1.00in,
    left   = 1.25in,
    right  = 1.25in,
    bottom = 1.00in
}
\setmainfont{Times New Roman}
\setsansfont{Arial}
\setmonofont{Courier New}
\newcommand{\doublespace} {
  \renewcommand{\baselinestretch}{1.66}\small\normalsize
}
\newcommand{\oneandhalfspace} {
  \renewcommand{\baselinestretch}{1.24}\small\normalsize
}
\newcommand{\singlespace} {
  \renewcommand{\baselinestretch}{0.9}\small\normalsize
}

% --------------------------------------------------------------------------- %
% Redefine the titlepage per the graduate school formatting manual.           %
% Add additional options and commands to allow the configuration of the       %
% titlepage as a self-study project rather than a required dissertation.      %
% --------------------------------------------------------------------------- %
\newlength{\fiveblanklines}\setlength{\fiveblanklines}{0.7 in}
\newlength{\tenblanklines}\setlength{\tenblanklines}{1.5 in}

\makeatletter

\newcommand{\defensemonth}[1]{\renewcommand{\@defensemonth}{#1}}
\newcommand{\@defensemonth}{\tt$\backslash$\string defensemonth}
\newcommand{\gradmonth}[1]{\renewcommand{\@gradmonth}{#1}}
\newcommand{\@gradmonth}{\tt$\backslash$\string gradmonth}
\newcommand{\gradyear}[1]{\renewcommand{\@gradyear}{#1}}
\newcommand{\@gradyear}{\tt$\backslash$\string gradyear}
\newcommand{\chair}[1]{\renewcommand{\@chair}{#1}}
\newcommand{\@chair}{\tt$\backslash$\string chair}
\newcommand{\memberOne}[1]{\renewcommand{\@memberOne}{#1}}
\newcommand{\@memberOne}{\tt$\backslash$\string memberOne}
\newcommand{\memberTwo}[1]{\renewcommand{\@memberTwo}{#1}}
\newcommand{\@memberTwo}{\tt$\backslash$\string memberTwo}
\newcommand{\memberThree}[1]{\renewcommand{\@memberThree}{#1}}
\newcommand{\@memberThree}{\tt$\backslash$\string memberThree}
\newcommand{\memberFour}[1]{\renewcommand{\@memberFour}{#1}}
\newcommand{\@memberFour}{\tt$\backslash$\string memberFour}
\newcommand{\degreeName}[1]{\renewcommand{\@degreeName}{#1}}
\newcommand{\@degreeName}{\tt$\backslash$\string degreeName}
\newcommand{\majorName}[1]{\renewcommand{\@majorName}{#1}}
\newcommand{\@majorName}{\tt$\backslash$\string majorName}
\newcommand{\paperType}[1]{\renewcommand{\@paperType}{#1}}
\newcommand{\@paperType}{\tt$\backslash$\string paperType}

\renewcommand{\maketitle}{
    \doublespace
    \begin{center}
        {\MakeUppercase\@title} \\ by \\ \@author \\
        \vspace{\fiveblanklines}
        \iftoggle{thesis}{
            A \@paperType Presented in Partial Fulfillment \\
            of the Requirement for the Degree \\
            \@degreeName \\
        }
        \iftoggle{project}{
            An Investigatory Project Supplementing the Studies\\
            of the \@degreeName Degree in \\
            \@majorName \\
        }
    \end{center}
    \clearpage
}

\makeatother

The error occurs between lines 75-92 where \maketitle is redefined. The particular error reported by XeLaTeX is, in typical, cryptic LaTeX fashion, "\begin{center} on input line 10 ended by \end{document}". I'm not sure quite how to proceed given that the \end{center} statement can clearly be seen on line 90.

3
  • you are mis-using \iftoggle it is \iftoggle{name}{yes}{no} so \end is being taken as the no argument. So the latex message is pretty clear and accurate Aug 16, 2022 at 21:47
  • unrelated but don't use \makeat... in a class file, also \newcommand{\@degreeName}{\tt$\backslash$\string degreeName} all look very odd, \tt should not be used in any documnent written after 1993, but you are not scoping it so this would make the rest of the document tt. You are applying \string to d whch does nothing useful. perhaps \newcommand{\@degreeName}{\texttt{\string\degreeName}} Aug 16, 2022 at 21:53
  • @DavidCarlisle correcting the \iftoggle fixed the issue - with respect to the \newcommand declarations, I'm in the process of adapting an older class file, so those declarations are as found in the original.
    – ecfedele
    Aug 16, 2022 at 22:00

1 Answer 1

0

You are mis-using \iftoggle it is

\iftoggle{name}{yes}{no}

so \end is being taken as the no argument. So the latex message is pretty clear and accurate in this case.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .