0
我試着定義一個宏,爲我快速創建一個列表環境。該定義看起來就像是:使用lstlisting環境與宏?
% \def \lstlistingcode[#1] { \begin{lstlisting}#1\end{lstlisting} }
從而結束在一個錯誤:
job aborted, no legal \end found
是否有可能宏中使用的環境,如果是 - 怎麼樣?
我試着定義一個宏,爲我快速創建一個列表環境。該定義看起來就像是:使用lstlisting環境與宏?
% \def \lstlistingcode[#1] { \begin{lstlisting}#1\end{lstlisting} }
從而結束在一個錯誤:
job aborted, no legal \end found
是否有可能宏中使用的環境,如果是 - 怎麼樣?
某些環境可以,例如alltt;然而,lstlisting不能,因爲它是如何寫的(它顯然與各種catcode的東西有關)。
使用\ def,你所做的是有點過時; \ newcommand優選:
\ newcommand \ allttcode [1] {\開始{alltt}#1 \ {端alltt}}
...
\ allttcode {測試}