5

I have downloaded the fantastic template for doctoral thesis available in https://www.latextemplates.com/template/masters-doctoral-thesis.

I have used it before I had already adapted the contents for my thesis. However, when I tried to compile it with MiKTeX after the last update I got this problem:

("C:\Users\XXXX\AppData\Local\Programs\MiKTeX 2.9\tex\generic\oberdiek\atbegshi.sty"))
! Missing number, treated as zero.
<to be read again> 
               -
l.81 ...end of thesis title}
                                               % Your thesis title, this...

? 

The problem seems to be within the \thesistitle command. However I have checked the .cls file and I can't see any problem with it. I downloaded the original from LaTeXtemplates and got the same results:

("C:\Users\XXXX\AppData\Local\Programs\MiKTeX 2.9\tex\latex\csquotes\csquotes.cfg"))
! Missing number, treated as zero.
<to be read again> 
               -
l.70 \thesistitle{Thesis Title}
                            % Your thesis title, this is used in the tit...

? 

This is a minimal working example that gives the same error. I couldn't get rid of the class dependency though:

\documentclass[11pt, english, singlespacing, headsepline]{MastersDoctoralThesis}

\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters

\thesistitle{Resilience of wastewater resource recovery to multiple stress conditions} 

\begin{document}
\begin{titlepage}

\HRule \\[0.4cm] % Horizontal line
{\huge \bfseries \ttitle\par}\vspace{0.4cm} % Thesis title
\HRule \\[1.5cm] % Horizontal line

\end{titlepage}
\end{document} 

Crosspost on LaTeX.org

UPDATE: The provisional solution would be to replace the \thetitle command part in the .tex file, with:

\newcommand{\ttitle}{Thesis title}
\makeatletter
\renewcommand{\@title}{Thesis title}
\makeatother
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
Pau
  • 189
  • 2
    Welcome, unfortunately the template is buggy. Are you able to provide a minimal working example that reproduces the given error message? Ideally, it would nit rely on the class itself but using book only. The buggy part needs to be copied from the cls to the main file. – Johannes_B Jul 25 '17 at 12:19
  • Please add \listfiles to the very begining of the main file and add the file list from the log. – Johannes_B Jul 25 '17 at 13:34
  • Hi @Johanes_B, I added \listfiles but didn't see any difference in the TeXworks output. Should it produce a .log file? I only see the ones that came with the example. – Pau Jul 25 '17 at 13:45
  • The log file is the file that includes the errors. – Johannes_B Jul 25 '17 at 13:47
  • By the way: https://github.com/johannesbottcher/MDT-Quick-Manual/blob/master/README.md – Johannes_B Jul 25 '17 at 13:49
  • Is it possible that it is not automatically created? I have no new files after trying to compile and getting the error. – Pau Jul 25 '17 at 13:49
  • It is created, you stated yourself you get an error. The file will be called main.log but maybe your OS is hiding the file ending. – Johannes_B Jul 25 '17 at 13:51
  • Turns out there is a --clean option that needs to be deactivated in preferences, typesetting. Otherwise the .log does not get created. I found it in this entry: https://tex.stackexchange.com/questions/327666/texworks-not-writing-log-or-aux-files. The file is 1600 lines long, any idea where the file list is produced? – Pau Jul 25 '17 at 14:19

4 Answers4

14

The class abuses \DeclareDocumentCommand for defining variables. Anyway, the obvious error is in the second line of

\DeclareDocumentCommand{\thesistitle} { o m }{
        \IfBooleanTF{#1} {\DeclareDocumentCommand{\shorttitle}{ }{#1}
        {\DeclareDocumentCommand{\shorttitle}{}{#2}}}
        \DeclareDocumentCommand{\@title}{ }{#2}
        \DeclareDocumentCommand{\ttitle}{ }{#2}
}

where \IfBooleanTF makes no sense and should be \IfValueTF.

The code should be

\NewDocumentCommand{\thesistitle} { o m }{%
   \IfValueTF{#1}{\def\shorttitle{#1}}{\def\shorttitle{#2}}%
   \def\@title{#2}%
   \def\ttitle{#2}%
}

or, in a slicker way,

\NewDocumentCommand{\thesistitle} { O{#2} m }{%
   \def\shorttitle{#1}%
   \def\@title{#2}%
   \def\ttitle{#2}%
}

You can avoid modifying the class by using in the preamble

\makeatletter
\RenewDocumentCommand{\thesistitle} { O{#2} m }{%
   \def\shorttitle{#1}%
   \def\@title{#2}%
   \def\ttitle{#2}%
}
\makeatother

My preference would go to \def instead of \DeclareDocumentCommand. However, fixing the class would need weeks of work (for example, \null\vfill has no place and the number of unprotected end-of-lines is huge), so I let it go.

egreg
  • 1,121,712
6

The code for the definition of \thesistitle is wrong. It uses \IfBooleanTF to test for the existence of the optional argument. The correct command is \IfValueTF. One can reproduce the error with this document:

\documentclass{article}

\usepackage{xparse}
\begin{document}

%Faulty definition:
\DeclareDocumentCommand{\thesistitle} { o m }{%
    \IfBooleanTF{#1} %replace by \IfValueTF
    {\DeclareDocumentCommand{\shorttitle}{ }{#1}
    {\DeclareDocumentCommand{\shorttitle}{}{#2}}}
}

\thesistitle{some text some text}

\end{document}

This faulty command gives now an error as due to a change in expl3 you no longer can use undefined booleans. The recent error with siunitx (siunitx and fontspec/unicode-math) and mhchem (see egreg explanation at the end of this answer: https://tex.stackexchange.com/a/383077/2388).

Ulrike Fischer
  • 327,261
3

As the code of this template is not really appealing here just a workaround:

\documentclass[11pt, english, singlespacing, headsepline]{MastersDoctoralThesis}

\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters

%\thesistitle{Resilience of wastewater resource recovery to multiple stress conditions} 

\newcommand{\ttitle}{Resilience of wastewater resource recovery to multiple stress conditions}

\begin{document}
\begin{titlepage}

\HRule \\[0.4cm] % Horizontal line
{\huge \bfseries \ttitle\par}\vspace{0.4cm} % Thesis title
\HRule \\[1.5cm] % Horizontal line

\end{titlepage}
\end{document} 
  • The same L3/xparse stuff as a few months ago? – Johannes_B Jul 25 '17 at 13:57
  • @Johannes_B More recent stuff, with texlive updated \approx one week ago, it worked, with the newest update it does not. – samcarter_is_at_topanswers.xyz Jul 25 '17 at 14:01
  • Thanks @samcarter and @Johannes_B for your help, it worked. But apart from creating the command \ttitle, I also had to create the command \@title necessary for the abstract section. Only this command couldn't be created as such (TeX said it was illegal), so I used \atitle instead, and replaced it in the .cls file. – Pau Jul 25 '17 at 14:40
  • 2
    @Pau please do not change the cls file, support for further problems will be much harder. – Johannes_B Jul 25 '17 at 16:40
3

Why the error occurs is explained in other answers. But the simplest solution to the problem seems to be to not even use \thesistitle. It doesn't do anything really useful.

\documentclass[11pt, english, singlespacing, headsepline]{MastersDoctoralThesis}

\usepackage[utf8]{inputenc} % Required for inputting international characters
\usepackage[T1]{fontenc} % Output font encoding for international characters


\begin{document}
\begin{titlepage}

{\centering\huge\bfseries \parbox{.7\textwidth}{\centering Resilience of wastewater resource recovery to multiple stress conditions}\par}\vspace{0.4cm} % Thesis title

\end{titlepage}
\end{document} 

The template was updated to work with recent versions of xparse as well as with older ones. Overleaf still runs TeX Live 2016.

Johannes_B
  • 24,235
  • 10
  • 93
  • 248