Latex 新命令
我想定义一个像这样的新命令
\newcommand{\bob}[1]{\excerpt \begin{lstlisting} {#1} \end{lstlisting}}
,然后像这样使用它,
\bob{abcd}
但我在乳胶中收到以下错误。
text dropped after begin of listing latex
编辑:
我尝试了以下操作
\newcommand{\boy}[1] {{%
\begin{Verbatim} %
{ #1 } %
\end{Verbatim} }}
,当我尝试使用它时仍然收到错误。
\boy{abc}
I would like to define a new command like this
\newcommand{\bob}[1]{\excerpt \begin{lstlisting} {#1} \end{lstlisting}}
and then use it like this
\bob{abcd}
but i get the following error in latex.
text dropped after begin of listing latex
EDIT:
I tried the following
\newcommand{\boy}[1] {{%
\begin{Verbatim} %
{ #1 } %
\end{Verbatim} }}
And I still get an error when I try to use it.
\boy{abc}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许您正在寻找
\newenvironment
宏。在这种情况下,您将像这样使用它
,稍后再使用
Perhaps you are looking for the
\newenvironment
macro.In this case you would use it like this
and later
{listing}
环境特殊而神奇;它不能在这样的命令中使用。按照 dmckee 的描述更改为\newenvironment
设置应该可行。如果您无法做到这一点,请查看fancyvrb
包。The
{listing}
environment is special and magical; it can't be used inside a command like that. Changing to a\newenvironment
setup as described by dmckee should work. If you can't make that work, check out thefancyvrb
package.尝试列表包的 lstnewenvironment。
Try the lstnewenvironment of the listings package.