With the MWE below, I experience some problem. As shown, the MWE compiles fine. If I change from book to beamer, I receive the "TeX capacity exceeded" error. If I comment out either nag or babel, it compiles fine again. What is going on here?

\RequirePackage[l2tabu, orthodox]{nag}      % Require syntax analyzis

\usepackage{xkeyval}    % Allow to use key-value pairs in arguments of macros
\usepackage{listingsutf8}   % Use program listings


%%%Usage \MESourceFile[keys]{source file}{caption}{label}
        \setkeys{MEMacros}{language={[ANSI]C},options={}, ,#1}% 
                \lstinputlisting[language={\ME@language},\ME@options,label=#4, name=#4]{#2}}


    \MESourceFileNew[language={[ANSI]C}, options={numbers=left}


#include <stdio.h>

int main()
    printf("hello, world\n");
  • Avoid nag; it does worse than it would solve. In any case, it should be loaded before \documentclass.
    – egreg
    May 25, 2015 at 19:59
  • @egreg Hmm. The intended functionality is OK. Thanks for the hint.
    – katang
    May 25, 2015 at 20:01
  • In this case, nag hangs at the evaluation of caption, probably because it doesn't understand the redefinition made by beamer. I find nag useless in general even if it works.
    – egreg
    May 25, 2015 at 20:07

1 Answer 1


The problem is in interaction with the magyar option: this is what I get if I add \errorcontextlines=100 to the example file

\nag@@warning@xliii  ->\nag@captioncheck 
\@@magyar@orig@label ->\nag@@warning@xliii 
\@@magyar@labelb #1->\@@magyar@orig@label 
                                          {#1}\begingroup \c@page \@m \edef ...

\@@magyar@labelb #1->\@@magyar@orig@label {#1}
                                              \begingroup \c@page \@m \edef ...

\@@magyar@labelb #1->\@@magyar@orig@label {#1}
                                              \begingroup \c@page \@m \edef ...

So the problem is in how the label is checked in the case of listings and in the interaction with the redefinitions that both magyar.ldf and beamer do on \label.

I don't think there is a sensible way for solving this conflict; following all the juggles performed by magyar.ldf is very complicated.

The best is to forget about nag.

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.