GarenSidonius / ASU-Dissertation-Template

LaTeX Template for Typesetting Arizona State University Dissertations and Theses
73 stars 35 forks source link

Adding caption to any figure breaks all references #35

Closed ErikPoppleton closed 2 years ago

ErikPoppleton commented 2 years ago

First off, thank you for creating this template it has been fantastic for getting my dissertation written.

It was working great until I started adding figures to my document. If I add a figure with a caption, the whole document either fails to compile or it compiles with no bibliography and all references are shown by their bibTeX reference name rather than as formatted citations.

Here is the figure I am trying to add:

\begin{figure}
\begin{center}
    \includegraphics[width=0.5\textwidth]{src/reality/figures1/oxdna_annot.png}
    %\caption{text here}
    \label{fig_oxDNA}
\end{center}
\end{figure}

which works fine if I comment out the caption, however if I include the caption, suddenly when compiling it alternates between failing to compile and compiling with no references. Please advise, thank you!

ErikPoppleton commented 2 years ago

It looks like this has something to do with the "titlecaps" package. If I remove that package from the template references and captions work as intended.

GarenSidonius commented 2 years ago

Here's an example figure from the sample document:

\begin{figure}
\includegraphics[width=\maxwidth{\textwidth}]{src/sample/antidorcas.jpg}
\caption{Antidorcas marsupialis, male}
\label{figure\arabic{figurecounter}}
\legend{\emph{Source}: \iftoggle{usebiblatex}{\textcite{krishnappa_adult_2012}}{\citet{krishnappa_adult_2012}}}% See: https://upload.wikimedia.org/wikipedia/commons/8/89/Antidorcas_marsupialis%2C_male_%28Etosha%2C_2012%29.jpg
\legend{\emph{Note}: Here is a note that is especially long to show what happens when it extends to more than one line.}
\end{figure}

But it doesn't look like yours is meaningfully different. How are you building the document?

ErikPoppleton commented 2 years ago

I'm building the document using Overleaf.

I notice from this blog post on the previous version of the template:

Another problem is that macros in text sent to \titlecap are likely to break. In the above example, all captions are sent to \titlecap. Users might want to refer to another figure or table in a caption (e.g., with the \ref command) or put a citation in a caption (e.g., with \cite). But these macros will break if they’re sent to \titlecap. (By the way, I am not scolding the package author here. Capitalization in LaTeX is tricky, and when text gets sent to a macro for capitalization, odd things can happen.)

which might have something to do with it, though in that example there I don't have any citations in the caption.

GarenSidonius commented 2 years ago

Hi @ErikPoppleton , would recommend to try building using the Docker workflow described in the README for this.

ErikPoppleton commented 2 years ago

I have been trying for hours but I cannot get it to compile in the Docker container, I needed to change the font because as it currently is it incorrectly formats the title so I needed to find a font where my entire file would fit on a single line (Verdana 10 pt works). However if I download Verdana to my working directory and add the following lines to .github/actions/latexmk/Dockerfile

# install verdana font
COPY verdana-font-family/* ./
RUN mkdir -p /usr/share/fonts/verdana-font-family
RUN install -m644 *.ttf /usr/share/fonts/verdana-font-family

It still cannot find the fonts. Nor can it find them if I manually install the fonts by accessing the Docker image via bash.

Here are the lines in my .tex file:

  \setmainfont{verdana}[           %<Set the main font; make sure the font is correct
                                        %   for the font size (See ASU Style Guide)
    Path          = /usr/share/fonts/verdana-font-family/,
    Extension     = .ttf ,
    UprightFont   = *-regular ,
    ItalicFont    = *-italic ,
    BoldFont      = *-bold ,
]
ErikPoppleton commented 2 years ago

I should say that I just manually made all my headings and titles titlecase and managed to get everything up to formatting specifications except the problem I submitted in #36 by compiling on Overleaf which doesn't have a problem with the fonts.

GarenSidonius commented 2 years ago

Hi @ErikPoppleton ,

I have been trying for hours but I cannot get it to compile in the Docker container

Does that mean that the Docker workflow does not work at all? In other words, the following commands did not produce a PDF:

./build.sh
./latexmk.sh -pdf -xelatex dissertation_template_latex_sample.tex

Or does that mean that your particular dissertation would not build using the Docker workflow?

The Docker workflow works for the sample dissertation (dissertation_template_latex_sample.tex) for me locally and on GitHub CI (see the "sample" under the Artifacts heading on https://github.com/GarenSidonius/ASU-Dissertation-Template/actions/runs/2558820663 ).


It looks like using local fonts works, as well. For a working example, see commit 8f83608fa58cb0fa6b033a6ba12806fee7b42046 and the associated CI run ( https://github.com/GarenSidonius/ASU-Dissertation-Template/actions/runs/2561007796 ). The PDF builds and can be downloaded under the Artifacts section.

It might be worth updating the templates to use local font files because that's a common thing for users to do. But I don't want to run into legal problems for redistributing font files. If there's an OFL version of one of the allowed fonts, I might update the template to use that.


If you're not building the document with the Docker workflow, it's hard to say what's going wrong with captions. Best guess is that there are differences in the environment or dependencies between the Docker workflow and Overleaf. But the Docker workflow is what is supported here since there are too many other environments for building PDFs to support.

GarenSidonius commented 2 years ago

Closing as stale