使用帶有引用的語法包時不完整 \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}

在此輸入影像描述

相關內容