1

I have a series of .tex files that are being compiled by lualatex, and this particular .tex file is making Title 4 and all the text in the following .tex files appear bolded after compilation even though they don't have a preceding \textbf or \bf. My assumption was that I was missing a bracket close, but it doesn't appear that way, so I tried removing the very first \textbf so the line reads:

\hspace{1cm}\large{Title 1, \foo}

This broke everything though, and gave me this error: "! Incomplete \ifnum; all text was ignored after line 293." I was able to remove the \textbf from the Title 3 line that did not invoke the foo function though, so my thought was that the problem lies in that function.

A quick google brought me here, but I tried playing around with the %s that I had in my function and couldn't figure out how to make it compile or fix the bolding issue.

I'm really stuck on this and would greatly appreciate any advice!! Thanks in advance!

\documentclass{article}

\newcommand{\insertquarter}{% Q% \ifcase\month\or4\or1\or1\or1\or2\or2\or2\or3\or3\or3\or4\or4\fi }

\newcommand{\lastMonthAlternate}{\ifcase \month\or % December \or January\or February\or March\or % April\or May \or June\or July\or August\or September\or October\or November\fi \hspace{1mm}\number \numexpr\year\ifnum\month=1 -1\fi\relax}

\newcommand{\foo}{% \ifnum\month=1 \insertquarter\ \number\numexpr\year-3\relax\ -- \insertquarter\ \number\numexpr\year-1\relax \else% \ifnum\month\or4\or7\or10 \insertquarter\ \number\numexpr\year-2\relax\ -- \insertquarter\ \number\year \else% \insertquarter\ \number\numexpr\year-2\relax\ -- \lastMonthAlternate \fi% }

\begin{document}

\hspace{1cm}\large\textbf{Title 1, \foo}

\hspace{1cm}\large\textbf{Title 2, \foo}

\hspace{1cm}\large\textbf{Title 3}

\hspace{1cm}\large{Title 4}

\end{document}

Cole MG
  • 145
  • 4

1 Answers1

2

If you try to use your \foo macro outside of the \textbf you can see that you get an error Incomplete \ifnum. This shows that your \foo macro doesn't actually work the way you want it too, because you have a missing \fi. If we add that \fi to the macro then your document works as expected.

\documentclass{article}

\newcommand{\insertquarter}{% Q% \ifcase\month\or4\or1\or1\or1\or2\or2\or2\or3\or3\or3\or4\or4\fi }

\newcommand{\lastMonthAlternate}{\ifcase \month\or % December \or January\or February\or March\or % April\or May \or June\or July\or August\or September\or October\or November\fi \hspace{1mm}\number \numexpr\year\ifnum\month=1 -1\fi\relax}

\newcommand{\foo}{% \ifnum\month=1 \insertquarter\ \number\numexpr\year-3\relax\ -- \insertquarter\ \number\numexpr\year-1\relax \else% \ifnum\month\or4\or7\or10 \insertquarter\ \number\numexpr\year-2\relax\ -- \insertquarter\ \number\year \else% \insertquarter\ \number\numexpr\year-2\relax\ -- \lastMonthAlternate \fi \fi% }

\begin{document}

\hspace{1cm}\large\textbf{Title 1,\foo }

\hspace{1cm}\large{Title 4}

\end{document}

output of code

Alan Munn
  • 218,180