Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want to prevent the content of a custom environment from being shown. I've tried:

\newenvironment{asdf}[3]
{
  %some stuff happens here
  %......
  \begin{comment}
}{
   \end{comment}
}

but this doesn't work.

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

Instead of \begin{comment} and \end{comment}, use \comment and \endcomment. The reason for this is that the \comment command proceeds by searching the text for the beginning of \end{<envname>}, where <envname> is the name of the environment it was called from.

This allows you to call comments from your own environments: \comment will see the end of your environment and know that the extent of the commenting has come to an end. With the code you gave, it would be looking for \end{comment}, never find it since it will never expand \end{asdf}, and continue forever.

(Oddly, this means that you must comment within a LaTeX environment: the pair of commands \comment/\endcomment, written directly into your document, will not work, unlike every other environment! But verbatim text, of which commenting is an example, is very odd all around.)

share|improve this answer
1  
This produces an error: ! File ended while scanning use of \next. <inserted text> \par l.50 \end{frame} –  Chris Dec 6 '10 at 12:27
1  
Found it: I was using \usepackage{comment} instead of \usepackage{verbatim}. Thanks for your help! –  Chris Dec 6 '10 at 12:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.