我創建了一個Beamer演示文稿,其中有很多示例LaTeX,它必須在逐字環境中進行。我越來越厭倦了打字如何使用逐字環境創建新的Beamer環境?
\begin{example}
\begin{verbatim}
Verbatim Text
\end{verbatim}
\end{example}
我想創建一個新的命令或環境,這將爲我縮短這一點。我也需要這個塊和定理,因爲我也經常使用它們。但是如果我能夠舉出例子,應該很容易翻譯成另一個例子。
我無法使用\ begin {verbatim}創建新的環境或命令,因爲它會切斷命令的其餘部分。於是我轉向使用fancyvrb包,並嘗試以下操作:
\DefineVerbatimEnvironment
{MyVerbatim}{Verbatim}{}
\newcommand{\makeexample}[1]{
\begin{example}
\begin{MyVerbatim}
#1
\end{MyVerbatim}
\end{example}
}
\makeenvironment{VerbExample}{\begin{example}
\begin{MyVerbatim}}{\end{MyVerbatim}\end{example}}
這給了我的\ {makeexample示例文本}命令,而\ {開始} VerbExample ... \結束{} VerbExample環境,但他們都仍然在編譯時出錯。我試圖使用它們的框架看起來像這樣(我在框架上有[脆弱]選項,所以不是這樣)。
\begin{frame}[fragile]
\frametitle{Why Doesn't Verbatim Work?}
\makeexample{Verbatim Text}
\begin{VerbExample}
Verbatim Text
\end{VerbExample}
\end{frame}
我欣賞的答案,但因爲我付出了很多在這些「逐字示例」 LaTeX的代碼,有逃避所有的\ ,{和}字符將比打字更簡單\ begin {example} \ begin {verbatim} ... 謝謝! – 2010-01-24 22:41:17
不客氣。是的,逐字和投影儀往往不會很好。創意解決方案通常不存在。最好的解決方案可能是在文本編輯器中添加快捷方式,例如通過製表符完成。 – 2010-01-24 23:08:37