无法在新环境中使用 \begin{lstlisting}

无法在新环境中使用 \begin{lstlisting}

如果我将其包含在我的文档中:

\begin{lstlisting}
testing
\end{lstlisting}

它按预期编译和渲染。但是,如果我尝试将其提取到新环境中,则会出现以下情况:

\newenvironment{codeblock}{\begin{lstlisting}}{\end{lstlisting}}

然后像这样使用它:

\begin{codeblock}
testing
\end{codeblock}

我无法再编译:

! Emergency stop
!  ==> Fatal error occurred, no output PDF file produced!
Transcript written on main.log.
Collected error summary (may duplicate other messages):
  pdflatex: Command for 'pdflatex' gave return code 1
      Refer to 'main.log' for details
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.
=== TeX engine is 'pdfTeX'
Latexmk: Errors, so I did not complete making targets

完整日志是在这个要点中

有人能给我指出正确的方向吗?

相关内容