# Incomplete \iffalse when using syntax package with a citation

For reasons unknown to me the following minimised latex code produces a

(/opt/local/share/texmf-texlive/tex/latex/mdwtools/syntax.sty) (./text.aux)) ! Incomplete \iffalse; all text was ignored after line 12.

error by pdflatex. Its derived from my document where the trouble started when I tried to add the syntax package:

\documentclass[a4paper,fontsize=12pt,parskip=half,toc=listofnumbered,toc=bib]{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{syntax}

\begin{document}

\begin{quotation}
As a rule of thumb, if you can tell which computer you are using, you are not using a distributed system.
\end{quotation} from \cite{DOS_Tanenbaum}

\end{document}


Is seems it somehow interferes with bibtex, since when I remove the \cite it generates a pdf.

• syntax redefines the underscore, as you are using one in the cite key it breaks. – Ulrike Fischer Feb 28 at 9:50
• WTF, good to know. You are right, post it as an answer and get your mark. – Superlokkus Feb 28 at 9:52
• Ohh nice now I get other errors like ! Missing \endcsname inserted. in the whole document , seems now it interferes with glossary – Superlokkus Feb 28 at 9:56
• Well then don't use the package. It is from 1996, and it is quite improbable that someone will fix the incompabilities. – Ulrike Fischer Feb 28 at 10:00
• – Ulrike Fischer Feb 28 at 10:02

The simplest solution is to do \usepackage[nounderscore]{syntax}. However, you can fix the usage in labels or citations.

\documentclass{article}

\usepackage{syntax}

\makeatletter
\def\@uscore.{%
\ifmmode
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
\sb
{\@usc@re}%
}
\def\@usc@re{%
\ifincsname
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\string_}%
{\textunderscore\@ifnextchar_{}{\usc@builtindischyphen}}%
}
\if@uscore
\AtBeginDocument{%
\catcode\_\active%
\begingroup%
\lccode\~\_%
\lowercase{\endgroup\protected\def~{\@uscore.}}%
}
\fi

\begin{document}

This is an underscore _''; also \cite{DOS_Tanenbaum} and $a_1$

\end{document}
`

• Thank you for your effort, but then the packages creates different issues with the glossaries package. However as the comment from Ulrike Fischer, this fixed this specific issues, so if you want, I check you as accepted. – Superlokkus Feb 28 at 11:54