使用带有引文的语法包时 \iffalse 不完整

使用带有引文的语法包时 \iffalse 不完整

由于我不知道的原因,以下最小化的乳胶代码产生了

(/opt/local/share/texmf-texlive/tex/latex/mdwtools/syntax.sty) (./text.aux)) !不完整的 \iffalse;第 12 行之后的所有文本都被忽略。

pdflatex 的错误。它源自我的文档,当我尝试添加语法包时,问题就开始了:

\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}

它似乎以某种方式干扰了 bibtex,因为当我删除 \cite 时它会生成一个 pdf。

答案1

最简单的解决方案是执行\usepackage[nounderscore]{syntax}。但是,您可以在标签或引用中修复用法。

\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}

在此处输入图片描述

相关内容