I have a problem with \excludecomment
from comment package and a \newcommand
.
The following codes work good, which means, it can generate the desired pdf output.
\documentclass{article}
\usepackage{comment}
\excludecomment{dontshow}
\begin{document}
This is a test.
\begin{dontshow}
test test test
\end{dontshow}
\end{document}
However, if I add the following:
\newcommand{\noshow}[2]{#1=#2 \begin{dontshow}#2=#1\end{dontshow} #1=#2}
\noshow{abc}{def}
It generates an error:
(c:/texlive/2010/texmf-dist/tex/latex/comment/comment.sty
Excluding comment 'comment') Excluding comment 'dontshow' (./test.aux))
Runaway argument?
! File ended while scanning use of \next.
<inserted text>
\par
<*> test.tex
?
How can I use 'comment' in a \newcommand
?
Best Answer
The environments of the
comment
package need to be on their own:AFAIK they don't work in macros like yours because they skip everything verbatim. There you could use if-switches for most content (except for unbalanced if-switches).