编译“暂停”并需要输入,但没有错误消息

编译“暂停”并需要输入,但没有错误消息

当我尝试使用 编译下面的 MWE 时xelatex,我得到以下结果:

*geometry* detected driver: pdftex
)
*

* 似乎是一个提示:按 ENTER 键

*
(Please type a command or say `\end')
*
(Please type a command or say `\end')
*
(Please type a command or say `\end')
*

.log 文件毫无用处。撇开我的文档中实际的错误不谈,我不明白发生了什么:为什么 LaTeX 会以这种方式暂停而不发出任何错误?

梅威瑟:

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage[no-math]{fontspec}
\usepackage[T1]{fontenc}

\makeatletter

\begingroup
\lccode`\~`\\
\lowercase{\endgroup
\def\vb{%
\par
\parindent\z@
\parskip1\baselineskip plus 2pt\relax
\let\do\@makeother\dospecials%
\let\@xobeysp\space
\catcode`\ \active
\catcode`\\\active
\let~\scanendvb
}}
\def\scanendvb#1#2#3#4#5#6#7{%
\def\x{#1#2#3#4#5#6#7}%
\ifx\x\endvbstr
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\end{vb}}{\char`\\#1#2#3#4#5#6#7}}

\edef\endvbstr{end\string{vb\string}}

\makeatother
\def\endvb{\par}

\newenvironment{almsinp}{\begin{minipage}[t]{0.5\textwidth}\begin{vb}}{\end{vb}\end{minipage}}

\begin{document}
\begin{almsinp}
Definition 2.1.2.
A _metric space_ M = (A, d) consists of a non-empty set A together with a map d : A\times A -> \bfR such that:
    (M1a) d(x, y)\geq 0 for all x, y in A.
    (M1b) d(x, y) = 0 <=>  x = y  for all x, y in A.
    (M2) d(x, y) = d(y, x) for all x, y in A.
    (M3) d(x, y)+d(y, z)\geq d(x, z) for all x, y, z in A.
The elements of A are called the _points_ of the metric space M, and d is called a _metric_ on A. We sometimes also call d the _metric_ of M.
\end{almsinp}
\end{document}

答案1

您不能将vb环境用作另一个命令的参数,因为“逐字”命令总是如此。我建议您添加一个可选参数vb并更改其定义,使其使用minipage。但您必须意识到这将禁止分页符。

\documentclass[a4paper,10pt]{article}
\usepackage[landscape,hmargin={1.2cm,1cm},vmargin=1cm,footskip=7mm]{geometry}
\usepackage[no-math]{fontspec}

\makeatletter

\begingroup
\lccode`\~`\\
\catcode`!\active
\lccode`!=`\^^M
\lowercase{\endgroup
\newcommand\vb[1][\textwidth]{%
\par\noindent\minipage[t]{#1}
\parskip1\baselineskip plus 2pt\relax
\let\do\@makeother\dospecials%
\let\@xobeysp\space
\catcode`\ \active
\catcode`\\\active
\catcode`\^^M\active
\def!{\par\leavevmode}
\let~\scanendvb
}}
\def\scanendvb#1#2#3#4#5#6#7{%
\def\x{#1#2#3#4#5#6#7}%
\ifx\x\endvbstr
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
{\end{vb}}{\char`\\#1#2#3#4#5#6#7}}

\edef\endvbstr{end\string{vb\string}}

\makeatother
\def\endvb{\endminipage}

\begin{document}
\begin{vb}[.5\textwidth]
Definition 2.1.2.
A _metric space_ M = (A, d) consists of a non-empty set A together with a map d : A\times A -> \bfR such that:
    (M1a) d(x, y)\geq 0 for all x, y in A.
    (M1b) d(x, y) = 0 <=>  x = y  for all x, y in A.
    (M2) d(x, y) = d(y, x) for all x, y in A.
    (M3) d(x, y)+d(y, z)\geq d(x, z) for all x, y, z in A.
The elements of A are called the _points_ of the metric space M, and d is called a _metric_ on A. We sometimes also call d the _metric_ of M.
\end{vb}
\end{document}

顺便说一下,这包含了一些变化以便在每行末尾都有换行符。

注意,fontenc使用时fontspec一般不需要加载。

答案2

我遇到了这个问题,只是我忘记了\end{document}结尾。添加它解决了问题。在其他地方找到了这个答案,并将其复制到此处以供将来参考。

相关内容