[英]Latex \newcommand problem
can someone please tell what I'm doing wrong here? 谁能告诉我这里做错了什么?
\newcommand{\bc}{\small\begin{verbatim}}
\newcommand{\ec}{\normalsize\end{verbatim}}
and then 然后
\bc
1 3 6 7 89 10
22 7 7 45
\ec
but I get 但我明白了
Runaway argument?
^^M1 3 6 7 89 10^^M 22 7 7 45^^M\ec^^M^^M\section{Reading on\ETC.
! File ended while scanning use of \@xverbatim.
<inserted text>
\par
<*> i4c.tex
?
! Emergency stop.
<inserted text>
\par
<*> i4c.tex
I thought it was pretty safe to do that, since most commands are just text substitutions... any hints? 我认为这样做非常安全,因为大多数命令只是文本替换...任何提示?
How \\begin{verbatim}
works. 如何
\\begin{verbatim}
有效。 briefly and roughly. 简要而粗略地说。
\\begin{verbatim}
is expanded to \\verbatim
. \\begin{verbatim}
扩展为\\verbatim
。 \\verbatim
sets category code of each special characters to 12. Now all chars is like digits or puncts. \\verbatim
将每个特殊字符的类别代码设置为12.现在所有字符都像数字或符号。 \\verbatim
sets font, parindent and calls \\@xverbatim
. \\verbatim
设置font,parindent并调用\\@xverbatim
。 \\@xverbatim
catches the end of verbatim using the following trick: \\@xverbatim
使用以下技巧捕获逐字结尾:
\\def\\@xverbatim#1\\end{#1\\end}
Then \\end{verbatim} finishes work. 然后\\ end {verbatim}完成工作。
How newcommand{\\bc}{\\small\\begin{verbatim}}
works. newcommand{\\bc}{\\small\\begin{verbatim}}
工作原理。
\\bс
expands to \\small\\begin{verbatim}
. \\bс
扩展为\\small\\begin{verbatim}
。 \\begin{verbatim}
expands to \\varbatim
. \\begin{verbatim}
扩展为\\varbatim
。 \\varbatim
changes all categories and font. \\varbatim
更改所有类别和字体。 \\verbatim
calls \\@xverbatim
. \\verbatim
调用\\@xverbatim
。 \\@xverbatim
tries to catch your argument using the following trick: \\@xverbatim
尝试使用以下技巧捕捉你的论点:
\\def\\@xverbatim#1\\end{#1\\end}
but it is impossible because of \\@xverbatim
tries to catch \\end
where all letters ( \\
, e
, n
, d
) have the category 12 and 11. But in fact there are only \\ec
exsits. 但这是不可能的,因为
\\@xverbatim
试图捕捉\\end
所有字母( \\
, e
, n
, d
)都有类别12和11.但实际上只有\\ec
exsits。
\\@xverbatim
is trying and trying to find \\end
where backslash ( \\
) has category 12 but.... File ended while scanning use of \\@xverbatim
\\@xverbatim
正在尝试并尝试查找\\end
,其中反斜杠( \\
)有类别12但.... File ended while scanning use of \\@xverbatim
verbatim
是特殊的,它扫描文字 \\end{verbatim}
,因为在\\begin{verbatim}
之后没有执行任何宏替换。
Some environment, such as verbatim
, need to scan in the text ahead to find their end manually. 某些环境(例如
verbatim
)需要在前面的文本中扫描以手动查找它们的结尾。 So unlike “normal” environments, verbatim
needs to find the text \\end{verbatim}
in the input text, verbatim. 因此,与“普通”环境不同,
verbatim
需要在输入文本中找到text \\end{verbatim}
。
In your example, it doesn't (since the input text contains \\ec
instead. 在您的示例中,它没有(因为输入文本包含
\\ec
而不是。
As a workaround, you can instead use the fancyvrb
package that defines a Verbatim
package and allows definition custom verbatim environments. 作为一种变通方法,您可以改为使用定义
Verbatim
包的fancyvrb
包,并允许定义自定义逐字环境。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.