# Every time there is a LaTeX error, I have to delete my aux file. Counter too large [closed]

I'm writing up my thesis, and every time I make a mistake and cause a compiler error, LaTeX stops working properly until I delete the aux file. It gives the error "Counter Too Large," which looks like

./chap1.tex:1384: LaTeX Error: Counter too large.


I am linking the master tex file. The child tex files are hundreds of thousands of characters and contain all my research, so I'm not providing those.

My document contains a lot of references and footnotes, which may have something to do with it.

For now, I wrote an option into my LaTeX-running script to find and rm all relevant aux files and run LaTeX twice. I'd love to provide an MWE, but I don't have a clue as to how to narrow it down to find the cause.

UPDATE: I am able to produce the error by causing a LaTeX error by putting an end brace in some random place in the document. Also, after running LaTeX four times, the error goes away. The errors are always at the same place, occuring in order (one on one run, another on the next):

line 1384 in chap1.tex, which is inside a paragraph and contains two footnotes:

Let $\gls*{hattheta}\in\left(\arcsin\left(\sqrt{\nicefrac{1.86\,}{Rk_j}}\right),\nicefrac{1}{2}\,\arcsin\left(\nicefrac{k_p\,}{k_s}\right)\right)$ \label{thetahatpage} be some fixed angle satisfying both $\mathfrak{e}_{k_R}(\hat{\theta})=0$\footnote{observe \textcolor{red}{how?} that this indicates that $\mathfrak{e}^j_{k_R}(\theta)=0$ for $\theta\in(0,\hat{\theta})$} and $\tan\hat{\theta}<\frac{3k_p^2}{4\pi k_s^2}$.\footnote{observe that this ensures that \eqref{Eupperbound} holds for $\theta\in\left(0,\hat{\theta}\right)$, allowing us to apply the conclusions of Lemma \ref{Dnotlargelemma}.} We will now prove a result that holds in two situations: \textbf{either} (a) case (i), $h=g$, and $\theta\in\left[\hat{\theta},\nicefrac{\pi}{2}\right)$, \textbf{or} (b) case (i) and $h\in\{\mathcal{L}_jg,\theta_j\mathcal{L}_jg,\mathcal{L}_j^2g,\mathcal{L}_j\theta_j\mathcal{L}_jg\}$ and $\theta\in\left[\hat{\theta},\nicefrac{1}{2}\,\arcsin{\nicefrac{k_p\,}{k_s}}\right)$. The result is as follows:


line 1671 in chap1.tex, which is inside an alignat environment and contains a \numberthis command (which I got from another stackexchange question, see the master tex file for the definition. It's purpose is to number equations that wouldn't otherwise be numbered. I use it to number ranges of equations for which I only explicitly reference the first and last, since I set it so that numbers normally only appear when there is a reference):

\begin{alignat}{1}
\tilde{G}_{11}^j:=\,&\frac{\cos^2\phi}{2\pi}\tilde{H}_0h_1^j-\frac{\cos(2\phi)}{2r\pi}\tilde{H}_1\left[\frac{h_1^j}{\varrho}\right]+\frac{\sin^2\phi}{2\pi}\tilde{H}_0h_2^j+\frac{\cos(2\phi)}{2r\pi}\tilde{H}_1\left[\frac{h_2^j}{\varrho}\right]\label{tildegxxj}\,.\\
\tilde{G}_{21}^j:=\,&\frac{\sin\phi\cos\phi}{2\pi}\tilde{H}_0[h_1^j-h_2^j]-\frac{\sin\phi\cos\phi}{r\pi}\tilde{H}_1\left[\frac{h_1^j-h_2^j}{\varrho}\right]\numberthis\,.\\
\tilde{G}_{31}^j:=\,&\frac{i\cos\phi}{2\pi}\tilde{H}_1h_4^j\numberthis\,.\\ %1671
\tilde{G}_{12}^j:=\,&\frac{\sin\phi\cos\phi}{2\pi}\tilde{H}_0[h_1^j-h_2^j]-\frac{\sin\phi\cos\phi}{r\pi}\tilde{H}_1\left[\frac{h_1^j-h_2^j}{\varrho}\right]\numberthis\,.\\
\tilde{G}_{22}^j:=\,&\frac{\sin^2\phi}{2\pi}\tilde{H}_0h_1^j+\frac{\cos(2\phi)}{2r\pi}\tilde{H}_1\left[\frac{h_1^j}{\varrho}\right]+\frac{\cos^2\phi}{2\pi}\tilde{H}_0h_2^j-\frac{\cos(2\phi)}{2r\pi}\tilde{H}_1\left[\frac{h_2^j}{\varrho}\right]\numberthis\,.\\
\tilde{G}_{32}^j:=\,&\frac{i\sin\phi}{2\pi}\tilde{H}_1h_4^j\numberthis\,.\\
\tilde{G}_{13}^j:=\,&\frac{i\cos\phi}{2\pi}\tilde{H}_1h_3^j\numberthis\,.\\
\tilde{G}_{23}^j:=\,&\frac{i\sin\phi}{2\pi}\tilde{H}_1h_3^j\numberthis\,.\\
\tilde{G}_{33}^j:=\,&\frac{1}{2\pi}\tilde{H}_0h_5^j\label{tildegzzj}\numberthis\,.\\
G^{R,j}_{11}:=\,&\frac{\cos^2\phi}{2\pi}H^R_0h_1^j-\frac{\cos(2\phi)}{2r\pi}H^R_1\left[\frac{h_1^j}{\varrho}\right]+\frac{\sin^2\phi}{2\pi}H^R_0h_2^j+\frac{\cos(2\phi)}{2r\pi}H^R_1\left[\frac{h_2^j}{\varrho}\right]\label{gxxRj1}\numberthis\,.\\
G^{R,j}_{21}:=\,&\frac{\sin\phi\cos\phi}{2\pi}H^R_0[h_1^j-h_2^j]-\frac{\sin\phi\cos\phi}{r\pi}H^R_1\left[\frac{h_1^j-h_2^j}{\varrho}\right]\numberthis\,.\\
G^{R,j}_{31}:=\,&\frac{i\cos\phi}{2\pi}H^R_1h_4^j\numberthis\,.\\
G^{R,j}_{12}:=\,&\frac{\sin\phi\cos\phi}{2\pi}H^R_0[h_1^j-h_2^j]-\frac{\sin\phi\cos\phi}{r\pi}H^R_1\left[\frac{h_1^j-h_2^j}{\varrho}\right]\numberthis\,.\\
G^{R,j}_{22}:=\,&\frac{\sin^2\phi}{2\pi}H^R_0h_1^j+\frac{\cos(2\phi)}{2r\pi}H^R_1\left[\frac{h_1^j}{\varrho}\right]+\frac{\cos^2\phi}{2\pi}H^R_0h_2^j-\frac{\cos(2\phi)}{2r\pi}H^R_1\left[\frac{h_2^j}{\varrho}\right]\numberthis\,.\\
G^{R,j}_{32}:=\,&\frac{i\sin\phi}{2\pi}H^R_1h_4^j\numberthis\,.\\
G^{R,j}_{13}:=\,&\frac{i\cos\phi}{2\pi}H^R_1h_3^j\numberthis\,.\\
G^{R,j}_{23}:=\,&\frac{i\sin\phi}{2\pi}H^R_1h_3^j\numberthis\,.\\
G^{R,j}_{33}:=\,&\frac{1}{2\pi}H^R_0h_5^j\,.\label{gzzRj1}
\end{alignat}


line 2131 of app.tex, which is at the end of an align environment and contains a \footnotetext command:

\begin{align}
\theta_p^2(\nu_{\theta,s})=\,&\left(\nu_{\theta,s}(t)\right)^2-k_p^2\\
=\,&k_s^2\sin^2\theta-k_p^2+\frac{tk_s\cos\theta\sin\theta}{\sqrt{2}}(\alpha_+-i\alpha_-)\\
&+ik_st^2\sin^2\theta+\frac{it^2k_s\sin^2\theta}{2}+\frac{t^2\cos^2\theta}{8}\left(\alpha_+-i\alpha_-\right)^2\\
&+\frac{t^3\sin\theta\cos\theta}{2\sqrt{2}}\left[i\alpha_++\alpha_-\right]-\frac{t^4\sin^2\theta}{4}\footnotemark
\end{align}\footnotetext{\eqref{thetaj1}--\eqref{thetaj4} is analagous to this equation, though it differs by a constant.} %2131


Line 2795 in app.tex, a paragraph containing a \footnote.

 Recalling that $K_m(\zeta):=\frac{e^{-i\zeta}H_{m-1}^{(1)}(\zeta)}{2}$, we have by NIST 10.17.13--15\footnote{and 10.17.1, and the note that 10.7.15 applies to $\mathcal{V}_{z,-i\infty}\left(t^{-l}\right)$ in conjugate sectors} that for $\arg\zeta\in\left[-\nicefrac{\pi}{4},\pi\right]$:


After four runs, sanity returns and it compiles. I have to compile it a second time to get any references to work.

SECOND UPDATE: Here are some logs:

This is the log when the file compiled normally.

This is the log after I intentionally introduced an error.

This is the log the first time after I corrected the error, with the Counter too Large error on line 1384 of chap1.tex.

This is the log the second time after I corrected the error, with the Counter Too Large error on line 1671 of chap1.tex

This is the log the third time after I corrected the error, with the Counter Too Large error on line 2131 of app.tex

This is the log after the fourth Counter Too Large error, when the document successfully compiled again.

I forgot to save the fourth Counter Too Large log with the error on line 2795, but hopefully there is enough information here. If that log is needed, let me know and I'll run the experiment again.

## closed as unclear what you're asking by Troy, Phelype Oleinik, Sebastiano, TeXnician, Stefan PinnowMay 11 '18 at 21:51

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

• Hi, comments are not for intended and not so useful for extended discussion; this conversation has been moved to chat, thanks. – Stefan Kottwitz Jun 11 '17 at 17:27