Latex tag for making a comment appear or disappear in pdf?

Is it possible to tag sections of your .tex file so that you can make text appear or not?

I have a long document and would like to be able to comment a certain section in each chapter, and produce two different pdfs, one with the comments, and one without.

I read about the \begin{comment} tag in the verbatim package. Is it possible to make this appear if I redefined the comment tag? How is this done?

(On suggestion, migrated this question from StackOverflow: http://stackoverflow.com/questions/3696128/latex-tag-for-making-a-comment-appear-or-disappear-in-pdf)

-

Yes, this is indeed possible, and it’s very simple, too: just redefine the comment environment as follows:

\renewenvironment{comment}{}{}

This will cause the comment text to be included as normal text.

-
That should be \renewenvironment{\comment}{}{} shouldn't it? I think I prefer this solution to mine... –  Seamus Sep 12 '10 at 19:48
Thanks, that's perfect! –  celenius Sep 12 '10 at 19:52
Actually, you don't want the backslash. Never mind. –  Seamus Sep 12 '10 at 19:53

I'd recommend the comment package. You can use it something like this:

\usepackage{comment}
\includecomment{myspecial}

or

\excludecomment{myspecial}

then

\begin{myspecial}
I only want this paragraph in the special version of the output
\end{myspecial}

This will allow you to have multiple variations, should you ever need them. Each \includecomment{...} or \excludecomment{...} defines a new environment {...}. Everything placed in one of these environments can be "turned on or off" by switching between \includecomment and \excludecomment in the preamble.

-

The (relatively new) xcomment package has the ability to selectively typeset existing environments such as the table environment or the tikzpicture environment. Simply place the text

\usepackage{xcomment}
\xcomment{table,tikzpicture}

in the preamble, and then only the table environment and tikzpicture environment will be compiled.

-