
我想comment
從comment
包中複製環境:
\begin{comment}
Hidden stuff.
\end{comment}
它什麼也不列印,而不是用來%
註解掉東西。
我可以使用命令來完成它,例如\def\comment#1{}
,現在我想將其變成一個環境。
動機是創建一個有條件地完全隱藏文字或對其執行某些操作的環境,例如更改顏色:
\@ifundefined{flag}%
{\newenvironment{flagged}{\it\color{red}(}{)}}%
{\newenvironment{flagged}{\comment\bgroup}{\egroup}}
在第二種情況下,目的是使巨集的文字參數:\comment\bgroup Hidden stuff\egroup
。這不起作用,因為\bgroup\egroup
無法分隔巨集的參數。
\includepackage{comment}
...
{\newenvironment{flagged}{\begin{comment}}{\end{comment}}}
我猜也不起作用,因為該comment
包需要一個文字字串\end{comment}
:
! File ended while scanning use of \next.
這個怎麼做?
答案1
該包提供了一種通過和comment
執行此操作的機制。\specialcomment
\excludecomment