ulyngs / oxforddown

Template for writing an Oxford University thesis in R Markdown; uses the OxThesis LaTeX template and was inspired by thesisdown.
https://ulyngs.github.io/oxforddown/
MIT License
220 stars 81 forks source link

Table of contents preventing the LaTeX from compiling for PDF output #74

Closed mtthwborg closed 1 year ago

mtthwborg commented 1 year ago

The table of contents is returning a error message that prevents PDF output (although Word works and has a table of contents):

! Incomplete \iffalse; all text was ignored after line 279. 
<inserted text> 
                \fi 
l.279

Line 279 in _main.tex is the line immediately before the \flushbottom that precedes \tableofcontents. I am able to prevent this by either by changing table-of_contents to true or commenting out the following lines in template.tex, which in turn prevents the table of contents from loading

$if(table-of-contents)$
\tableofcontents
$endif$

However, I would love to include a table of contents in the PDF version. I would be grateful for any help with solving this.

I did make some additions to the LaTeX templates template.tex and ociamthesis.clsc and the index.Rmd metadata in order to add more pages to the front-matter output. However, I cannot determine how they are related to the table of contents error, and moving the table of contents before or behind these extra pages makes no difference. The table of contents sections in all the aforementioned files were unchanged. Turning toc-link-page-numbers, lof, lot and options such as show-abstract-in-toc to false do not prevent the error.

I have copied and pasted the mini tables section in template.tex for reference (unchanged apart from comments):

%%%%% MINI TABLES
% This lays the groundwork for per-chapter, mini tables of contents. Comment the following line
% (and remove \minitoc from the chapter files) if you don't want this. Un-comment either of the
% next two lines if you want a per-chapter list of figures or tables.
$if(remove-mini-toc)$$else$\dominitoc$endif$ % include a mini table of contents
$if(add-mini-lof)$
  \dominilof  % include a mini list of figures
$endif$
$if(add-mini-lot)$
  \dominilot  % include a mini list of tables
$endif$

\flushbottom % Aligns bottom of text of each page. It generally makes things look better.

% This is where the whole-document ToC appears: MB: CURRENTLY PREVENTS PDF OUTPUT: ! Incomplete \iffalse; all text was ignored after line
$if(table-of-contents)$
\tableofcontents
$endif$

$if(lof)$ % Generate a list of figures if requested
\listoffigures
    \mtcaddchapter % \mtcaddchapter is needed when adding a non-chapter (but chapter-like) entity to avoid confusing minitoc
$endif$

$if(lot)$ % Generate a list of tables if requested
\listoftables
  \mtcaddchapter
$endif$

I have also included one of the additions to template.tex below for reference, which is located after the abstract and adds a keywords section:

%%%%% KEYWORDS
$if(keywords)$

$if(show-keywords-in-toc)$
\addcontentsline{toc}{chapter}{$if(keywords-heading)$$keywords-heading$$else$Keywords$endif$}
\renewcommand{\numberstyleacks}{plain}
\renewcommand{\numberstyleabstract}{plain}
$endif$

\renewcommand{\keywordstitle}{$if(keywords-heading)$$keywords-heading$$else$Keywords$endif$}
\begin{keywords}
    $keywords$
\end{keywords}

$endif$

Which is accompanied by a corresponding section in ociamthesis.cls:

% KEYWORDS (MB insert)
\newcommand{\keywordstitle}{Keywords} % need to create title here, but will be replaced latter
\newenvironment{keywords}%
{ \begin{alwayssingle}\chapter*{\keywordstitle}
  \thispagestyle{\numberstyleacks}
    \pagestyle{\numberstyleacks}
    \setlength{\baselineskip}{\frontmatterbaselineskip}
}
{\end{alwayssingle}}

And this section in the index.Rmd metadata:

keywords-heading: "Keywords"
keywords: |
  `r paste(readLines("front-matter/_keywords.Rmd", warn=F), collapse = "\n  ")`
show-keywords-in-toc: true

The other additions are similar to the keywords insertion.

ulyngs commented 1 year ago

If you knit an unmodified clone of the GitHub repository to PDF, does the table of contents work?

mtthwborg commented 1 year ago

Yes the unmodified version table of content works without issue.

ulyngs commented 1 year ago

Try adding your changes to the unmodified clone one at a time and see which one breaks the table of contents

mtthwborg commented 1 year ago

Found the solution. The issue is that these new sections cannot have headings, which seems to interfere with the generation of table contents. This also applies for the other sections before the main thesis, such as the abstract and acknowledgements.

ulyngs commented 1 year ago

Not entirely sure which new sections you mean specifically, but glad you found a solution! Let me know if there are any action points for stuff that would need to change in oxforddown to accommodate your use case