
我的 LaTeX 檔案中有一個問題,我無法用 google-fu 解決。對於同一錯誤的大多數答案都表示\end{frame}
可能不會縮排。我不使用\end{frame}
。
我的目標
我想定義一個名為「回應」的環境。渲染它包含的文字應該是可選的,這取決於全域參數。為此,我選擇使用“標記”包,因為它的靈活性和易用性。
問題
渲染可選文字有效,隱藏它會引發錯誤。我使用 pdflatex 進行編譯。
\usetag{instructeur}
您可以透過在序言中顯示可選區塊,透過在 中隱藏它\usetag{whatever_else}
。請參閱以下 MWE:
\documentclass[12pt]{exam}
\usepackage{tagging}
\newenvironment{reponse}[0]{\begin{taggedblock}{instructeur}}{\end{taggedblock}}
\usetag{instructeur}
\begin{document}
This is normal text, always displayed.
\begin{reponse}
This text should only be displayed if we do \texttt{\textbackslash usetag\{instructeur\}} in the preamble.
It should disappear if we remove \texttt{instructeur}, but throws and error instead.
\end{reponse}
\end{document}
我應該補充一點,標記本身工作得很好,只有當我將其作為環境的命令begin
時,它才會中斷。end
請不要提供使用不同包的解決方案,例如“answers”。我想使用“標記”,我相信我想要實現的目標是完全可行的。
先致謝!
答案1
@campa 的答案有效。使用\taggedblock{instructeur}
and\endtaggedblock
確實可以毫無錯誤地進行編譯,並產生所需的輸出。
那為什麼官方手冊沒有提及\taggedblock
and\endtaggedblock
文法呢?
手冊發現於CTAN