5

If I try to build the following document:

\documentclass{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{fancyvrb}
\usepackage{siunitx}
\usepackage{bigfoot}

\begin{document}

    Test.

\end{document}

Latex just throws the error:

LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 15.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 15.
\c__siunitx_mathtt_int=\count327

input stack size=5000]
TeX STOPPED: fatal errors occurred. Check the TeX log file for details

Related questions:

  1. TeX capacity exceeded, input stack size=5000
  2. Error Latex TeX capacity exceeded, sorry [input stack size=5000]
  3. TeX capacity exceeded, sorry [input stack size=5000] after loading "hanging module" in both parent and child documents in LyX Classicthesis
  4. Tex capacity exceeded, sorry [input stack size = 5000]
7

Analysis

Compilation stops when the tokens in \AtBeginDocument are being evaluated. For historical reasons, bigfoot has

\def\FN@allmarks#1{\@elt{#1}%
  \ifnum#1<\count266
    \expandafter\FN@allmarks\expandafter{\number\numexpr#1+\@ne}%
  \fi}

because etex.sty had

\count266=1 % globally allocates \marks classes 1, 2, ...

The bigfoot package has not been updated after LaTeX has incorporated much of etex.sty, including allocation of the extended registers (above 255), but the counter holding the last allocated marks register is not \count266 any longer.

What happens in your case is that \count266 is allocated by siunitx as part of the loading of expl3 and receives the value 16777216, which of course makes too long a loop when \FN@allmarks0 is executed.

Loading fancyvrb after siunitx doesn't trigger the error, but doesn't solve the issue either, because \count266 will hold a value that most likely has nothing to do with the number of allocated marks registers. The LaTeX kernel reserves \count256 for that.

Solution

Patch \FN@allmarks to use the right register.

\documentclass{memoir}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\usepackage{fancyvrb}
\usepackage{siunitx}
\usepackage{bigfoot}
\usepackage{xpatch}

\makeatletter
\xpatchcmd{\FN@allmarks}{266}{256}{}{}
\makeatother

\begin{document}

    Test.

\end{document}
0

If I change the package loading order to:

\usepackage{siunitx}
\usepackage{fancyvrb}
\usepackage{bigfoot}

it gets fixed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.