I'm getting the following error when trying to compile a master .tex file:

TeX capacity exceeded, sorry [parameter stack size=10000]

There's some info in the .log file that may be relevant but hasn't helped me much:

ABD: EveryShipout initializing macros
LaTeX Font Info:    Try loading font information for OT1+ztmcm on input line 11

File: ot1ztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OT1/ztmcm.
LaTeX Font Info:    Try loading font information for OML+ztmcm on input line 11

File: omlztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OML/ztmcm.
LaTeX Font Info:    Try loading font information for OMS+ztmcm on input line 11

File: omsztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OMS/ztmcm.
LaTeX Font Info:    Try loading font information for OMX+ztmcm on input line 11

File: omxztmcm.fd 2000/01/03 Fontinst v1.801 font definitions for OMX/ztmcm.
LaTeX Font Info:    Try loading font information for OT1+ptm on input line 11.

File: ot1ptm.fd 2001/06/04 font definitions for OT1/ptm.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <12> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 11.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <9> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 11.
LaTeX Font Info:    Font shape `OT1/ptm/bx/n' in size <7> not available
(Font)              Font shape `OT1/ptm/b/n' tried instead on input line 11.

! TeX capacity exceeded, sorry [parameter stack size=10000].
\@ifnextchar #1#2#3->
                     \let \reserved@d =#1\def \reserved@a {#2}\def \reserved...
l.11 \input{monog_pretextuais.tex}

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.

I have pretty much every LaTeX package installed and updated (including psnfss, collection-fontsextra, etc.), except for a few very Windows-specific packages. I use texlive (tlmgr), as I find the packages in the Ubuntu repository too outdated. I use LaTeXila with latexmk (tex > dvi > ps > pdf) to edit and compile my files. It's very important, for the purposes of my project, for the serif font to be Times New Roman (mathptmx) and the document class to be abntex2, for I need to abide by many ABNT-like standards.

I've attempted to create MWEs.

These are the master file contents:




monog_preambulo.tex contents:

    % -- opções do pacote memoir --
    letter,                                 % estranhamente, Normas do IEL.pdf pag53 recomenda letter
    12pt,                                   % tamanho da fonte
    oneside,                                % para impressão apenas em frente; ver Normas do IEL.pdf pag54
    %openright,                             % capítulos começam em pág ímpar
    oldfontcommands,                        % autoriza certas operações do linguex
    % -- opções do pacote babel --
    english,                                % idioma secundário
    brazil                                  % idioma principal
%\special{papersize=21.59cm,27.94cm}         % tamanho carta
                                            % https://en.wikibooks.org/wiki/LaTeX/Page_Layout

% margens
% note que, conforme Norma do IEL.pdf pag53, se essa monografia exceder 100 páginas,
% todas as margens deverão ser de 3cm.

% encoding
\usepackage[utf8]{inputenc}                 % encoding do texto de input
\usepackage[T1]{fontenc}                    % encoding da fonte usada no output

% fontes
\usepackage{mathptmx}                       % serifada: times new roman; integra o pacote psnfss
\usepackage[scaled=.92]{helvet}             % sans: helvetica
\usepackage{courier}                        % monospace: courier
\usepackage{pifont}                         % dingbats, symbols; integra o pacote psnfss

% desenhos
\usepackage{float}                           % permite ambientes float
\usepackage[section]{placeins}              % evita que floats ultrapassem a seção pretendida
%\usepackage{caption}                       %
\usepackage[absolute]{textpos}              % cria caixas em posições absolutas
\usepackage{graphicx}                       % inclui figuras
\usepackage[dvipsnames]{xcolor}             % controle das cores
%\usepackage{pstricks}                       % faz os desenhos vetorizados
\usepackage{tikz-qtree}                     % árvores sintáticas
\usepackage{tikz-qtree-compat}              % permite \qroof e \1, \0 nos nodes

% lógica
    % comando para a cardinalidade de conjuntos; \abs{2} retorna |2|
    %\let\emptyset\varnothing                % muda a aparência do símbolo do conjunto vazio

% linguística
\usepackage{linguex}                        % exemplos numerados e glosas
\automath                                   % permite árvores dentro dos exemplos do linguex

% comentários e debugging
%\usepackage{lipsum}                        % texto genérico
\usepackage{verbatim}                       % ambientes código e comentário

% dados para a capa e a folha de rosto
\titulo{O t{\'\i}tulo da monografia}
\autor{Daniel Alves da Silva Lopes Diniz}
\orientador[Orientadora:]{Profa. Dra. Ruth Elisabeth Vasconcellos Lopes}
Universidade Estadual de Campinas
Instituto de Estudos da Linguagem
\tipotrabalho{Monografia (gradua{\c c}\~ao)}
\preambulo{Monografia apresentada ao Instituto de Estudos da Linguagem da Universidade Estadual de Campinas como requisito parcial para a obten{\c c}\~ao do t\'\itulo de bacharel em Lingu\'\istica.}

% tipografia
% hyperref deve ser declarado antes de abntex2cite
\setlength{\parindent}{2cm}                 % tamanho da tabulação; ver Normas do IEL.pdf pag53
\setlength{\ABNTEXcitacaorecuo}{4cm}        % recuo para citações longas; ver Normas do IEL.pdf pag40
\setlength{\parskip}{.2cm}                  % espaço entre parágrafos
\usepackage{indentfirst}                    % 1º parágrafo indentado
\usepackage{needspace}                      % bloco de texto ininterruptível
%\usepackage{microtype}                      % justificação melhorada
\raggedbottom                               % evita preenchimento da página
%\usepackage{booktabs}                      % tabelas melhores
%\usepackage{multirow}                      % mesclar células verticalmente
\usepackage{hyperref}                       % links internos
    pdftitle={vers\~ao 3},
    colorlinks      = true,                 % cores em vez de caixas
    urlcolor        = Black,                % links externos
    linkcolor       = Black,                % link internos
    citecolor       = Black                 % citações

% referências bibliográficas
    alf,                                    % autor-data
    %versalete,                             % versalete
    abnt-emphasize = bf,                    % destaques em negrito, e não em itálico
    abnt-etal-list = 3,                     % abrevia autorias maiores que 3 (Normas do IEL.pdf pag22
    %abnt-etal-text = it,                   % escreve o et al., em italico
    %abnt-and-type = &,                     % usa o carater '&' no lugar de 'e' para mais de um autor
    abnt-last-names = abnt,                 % trata sobrenomes "estritamente" conforme a ABNT
    abnt-repeated-author-omit = yes         % autores com mais de uma entrada recebem ______

monog_pretextuais.tex contents:

nothing; that is, even when all its contents are commented out, I still get an error.

I'm getting quite desperate with this error because I need to finish this work somewhat quickly and it doesn't compile anymore.

2 Answers 2


The code below identifies the cause and prevents the infinite loop but unfortunately \protected definitions still expand while handling primitive input file names so the _ will still be misinterpreted.

It seems safest to say that \automath is incompatible with _ in filenames and that \noautomath should be used locally (or better, for the whole document) to disable the feature.

You are in an infinite loop

\@ifnextchar #1#2#3->\let \reserved@d =
                                       #1\def \reserved@a {#2}\def \reserved...

\@ifnextchar #1#2#3->\let \reserved@d =
                                       #1\def \reserved@a {#2}\def \reserved...

\@ifnextchar #1#2#3->\let \reserved@d =
                                       #1\def \reserved@a {#2}\def \reserved...

\@ifnextchar #1#2#3->\let \reserved@d =

One of the packages you load defines _ in a somewhat brave way so it is no longer safe in filenames



The culprit is \automath.

\automath is actually defined in gb4e package (indirectly loaded via linguex).

In the example below I show a safer definition that could be proposed to the package maintainers, it allows _ to be used in filenames and other places without being prefixed with \string


{ % Temporarily change catcodes





If you try the above without the code between {...} then you get the same infinite loop.

  • 2
    – egreg
    Oct 18, 2016 at 21:21
  • @egreg yep just found it Oct 18, 2016 at 21:26
  • Unfortunately I have to use \automath as it is what allows me to put trees drawn with tikz-tree inside linguex examples. So what I did is use \string_ instead of _ in the filenames. It seems that's not the best workaround, but looks good enough (at least the master file is compiling). Thanks a lot! Oct 20, 2016 at 8:32
  • side note: package gb4e makes the caret active already in the preamble. This is doomed to make loading of next packages fail, if they do any serious stuff... (for example filecontents can not be loaded after gb4e).
    – user4686
    Oct 20, 2016 at 15:26
  • in fact, gb4e.sty not only defines but executes \automath...
    – user4686
    Oct 20, 2016 at 17:02

Here is a solution which will avoid you to modify in any way the body of the document. It assumes you always use the recommended by the LaTeX books form: \input {foo} (i.e. with braces, the space is optional).

When I was working on this solution I discovered a big problem with gb4e: it leaves the caret active after its loading already in the preamble !! This is doomed to create problems with loading of other packages. For example filecontents can not be loaded after it.


Anyway, here is a possible approach under the constraint mentioned above.


Hello: c_d^e

% IMPORTANT NOTE. There is something WRONG with gb4e.
% IT MAKES THE CARET ACTIVE !!!!!!!!!!!!!!!!

\typeout{BEFORE: \the\catcode`\^}
\typeout{AFTER: \the\catcode`\^}

% Temporarily change catcodes

% redefine \automath



% patch LaTeX
% but this will not have the characters active during file input
% \let\zzz@iinput\@iinput
% \def\@iinput#1{\zzz@ininputtrue\zzz@iinput{#1}\zzz@ininputfalse}

% thus we proceed rather this way:
\long\def \InputIfFileExists#1#2{\zzz@ininputtrue
    {#2\@addtofilelist{#1}\zzz@ininputfalse\@@input \@filef@und}}



% check this does work:



\input {name_with^underscore^and_caret.tex}



enter image description here

enter image description here

  • the toggle is not reset if we try to input a non-existing file. Thus use it only or existing files. (we can patch more, naturally)
    – user4686
    Oct 20, 2016 at 16:34

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.