I want to generate a list of technical abbreviations and acronyms that I use. Currently, I'm defining all acronyms with a macro I have designed. Now, I want the macro to call another macro, called \addtototaa, each time it is called, which adds the abbreviation to a table. This other macro is defined as

    \renewrobustcmd{\TableoftaaBody}{\OldContent #1 & #2 \\}}

And then I have the two additional macros

\newrobustcmd{\tableoftaa}[0]{\begin{longtabu}{l X}\TableoftaaBody\end{longtabu}}

where \TableoftaaBody acts as a storage container for the table contents and \tableoftaa prints the table. But when I try to compile the document I get

TeX capacity exceeded, sorry [input stack size=5000] \tableoftaa

if I call \tableoftaa (but not otherwise). Why do I get this error? I read on this blog post that this message can appear if you have an infinite recursive loop (I guess the function calls are put on the stack and that's why it's eaten up). Have I defined a recursive function here somewhere? By the way, \addtototaa is called 31 times before \tableoftaa is called, because that's how many acronyoms and abbreviations I have defined, and the two arguments I send to \addtototaa are always just literals, and no additional macros.

  • 2
    In order to adequately assess "why [you] get this error", it would be best to provide a minimal example that illustrates your usage.
    – Werner
    Commented Aug 17, 2012 at 2:30
  • 2
    Is there a reason to not just use the glossaries package for this?
    – J M
    Commented Aug 17, 2012 at 5:31
  • @JM: I actually tried to use the glossary package, but I couldn't figure out how to use it, not even after having read this guide. The .glo file that was generated was empty, which is strange, since I had used both \makeglossaries, \newglossaryentry and \printglossaries and I also have a normal, working index for which I call makeindex. Also, I dislike the fact that one have to recompile several times just to see the changes you've made, and then all abbreviations where already defined in alphabetic order. Commented Aug 17, 2012 at 13:23
  • @JM: So, do you have any idea of what I might have done wrong, or is it impossible to tell without a code example? Commented Aug 17, 2012 at 15:38

2 Answers 2


You can use the etoolbox package to append content to an existing macro using \gappto (works similar to \g@addto@macro). I've simplified your code snippets so I can make a MWE, but it would most likely be easy to extend to your usage:

enter image description here

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\newcommand{\tableoftaa}{\begin{tabularx}{\textwidth}{l X}\TableoftaaBody\end{tabularx}}

  \gappto\TableoftaaBody{#1 & #2 \\}%
  • Thank you very much, \gappto definitely did the trick. Commented Aug 17, 2012 at 12:59

@Werner has shown how to do what you want, so I'll answer the other question: Yes you have defined an infinite recursive loop.


\renewrobustcmd{\TableoftaaBody}{\OldContent #1 & #2 \\}}

so \TableoftaaBody is eempty then you do


so \OldContent is \let to \TableoftaaBody so is defined empty and \TableoftaaBody is defined to be

\OldContent 1 & 2 \\

Then you go


so \OldContent is \let to \TableoftaaBody so is defined to be \OldContent 1 & 2 \\ (oooops!!!!) and \TableoftaaBody is defined to be

\OldContent 3 & 4 \\

so at this point if you expand \TableoftaaBody the first token you see is \OldContent so that expands but the first token of that expansion is \OldContent again and so you are in an infinite loop. Each time you expand \OldContent you see \OldContent again but push further tokens on the input stream after that, so finally you fill up all available memory.

  • I see. I got the idea to do that from the TeX Wikibook, but I guess the example featured there never intended you to use the same trick twice to extend a macro. Commented Aug 17, 2012 at 13:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .