吞噬(忽略)其中文本的環境

吞噬(忽略)其中文本的環境

我想commentcomment包中複製環境:

\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

相關內容