I'm using the LaTeX-KOMA-template (based on KOMA-script as the name suggests) provided by Karl Voit for writing a thesis. I can compile the main.tex perfectly fine, until I import the syntax package. This happens even if I compile the template 'as is', without any other packages imported. I get the following errors I simply can't wrap my head around:

! Missing \endcsname inserted. \protect l.232 \input{template/declaration_TU_Graz} %% Statutory Declaration The control sequence marked should not appear between \csname and \endcsname.

! Extra \endcsname. \InputIfFileExists ...\csname #1-@alias\endcsname \relax \expandafter \@seco... l.232 \input{template/declaration_TU_Graz} %% Statutory Declaration I'm ignoring this, since I wasn't doing a \csname.

! TeX capacity exceeded, sorry [input stack size=5000]. \@inmathwarn ...latex@warning {Command \protect #1 invalid in math mode}\fi l.232 \input{template/declaration_TU_Graz} %% Statutory Declaration If you really absolutely need more capacity, you can ask a wizard to enlarge me.

How can this happen by simply importing the syntax package?

How to reproduce:

  1. Download LaTeX-KOMA-template and extract it
  2. Typeset main.tex -> It works as expected
  3. Insert \usepackage{syntax} in designated MISC usepackages area of main.tex
  4. Typeset main.tex again -> The error occurs.

System: texmaker 4.4.1 on MacTex-2015 (TeX Live 2015) without any package updates running on OS X Yosemite 10.10.3.

Please let me know if you need any additional information!

  • Welcome to tex.sx! but... can you not make a small test file just using standard koma classes that people have? Your example should not reference external code unless it's absolutely unavoidable. Jun 24, 2015 at 14:48
  • Examples using just standard koma classes compile just fine, unfortunately. I expected the template to be the culprit. Given the problem even persists with the version available in the repository, I figured it to be reproducible quite well. @Bordaigorl found the culprit. Jun 24, 2015 at 15:03
  • 3
    Just do \usepackage[nounderscore]{syntax}
    – egreg
    Jun 24, 2015 at 15:14
  • No it needs the syntax package to show the problem, not just koma script (in fact koma script not needed at all, as the example in the answer shows) you could have generated that test case. The questions on this site last forever but may well not make sense if external links break or get changed, and for security reasons many people will not download files from unknown sources. Jun 24, 2015 at 15:28
  • Well, I didn't really know where the error originated. The answer by @Bordaigorl wasn't this elaborate when it was first published. It obviously had to do with underscores being used in the template. What changing sources are concerned: It sure is a good thing that github is versioned :) Jun 24, 2015 at 15:43

2 Answers 2


The Syntax package redefines the underscore character, so when you use it in filenames it is not read as it is but interpreted as a macro and expanded. Simple solution: avoid underscore in filenames.

Not so pretty solution: capture the original underscore char in a macro before the syntax package changes its meaning (at begin document) and then use the macro instead of the underscore:

\input{bla\UnderScore bla}

A more general solution: revert the meaning of _ (maybe locally) using


This will make _ a normal character again. You can re-activate syntax's redefinition by doing


You can put these two in two macros \makeunderscoreletter and \makeunderscoreactive and use it locally:



\input{bla_bla} % interprets _ as letter

my_variable % uses syntax redefinition

  • Phew... thanks a lot. I gotta say, that was really unintuitive... And the respective template sure uses a lot of underscores. Jun 24, 2015 at 15:01

To expand on the accepted answer, the syntax package also has an optional argument, nounderscore, specifically to fix this problem. Loading the package using \usepackage[nounderscore]{syntax} fixes your problem.

You must log in to answer this question.

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