[comp.text.tex] Using \iffalse inside a LaTeX environment definition.

erskine@qucis.queensu.CA (Neil Erskine) (07/27/90)

][b
	I have a large number of files written using LaTeX and some
additional macros I wrote.  I sometimes want to suppress certain
parts of them, so I thought to do this by placing some parts in null
environments, as in

\newenvironment{Comments}{}{}
...
\begin{Comments}
Stuff that is sometimes suppressed.
\end{Comments}

I now want to suppress the comments, so I tried

\newenvironment{Comments}{\iffalse}{\fi}

but no dice, TeX (or LaTeX) won't take it.  The first time the
Comments environment is used it complains of a missing \fi.  I suppose
this is one of the standard questions that gets asked here, so don't
flame too loudly; I just want a method that doesn't involve editing
all those files.
				Thanks in advance,
				    Neil

Aside: I tried reading The TeX Book, but this didn't seem to help with
either my problem, or my understanding of how macros get interpreted
or swallowed or digested, or whatever happens to them.

||!][b

duchier@cs.yale.edu (Denys Duchier) (07/27/90)

In article <811@qusuntrd.queensu.CA> erskine@qucis.queensu.CA (Neil Erskine) writes:
 >	   I have a large number of files written using LaTeX and some
 >   additional macros I wrote.  I sometimes want to suppress certain
 >   parts of them, so I thought to do this by placing some parts in null
 >   environments, as in
 >
 >   \newenvironment{Comments}{}{}
 >   ...
 >   \begin{Comments}
 >   Stuff that is sometimes suppressed.
 >   \end{Comments}
 >
 >   I now want to suppress the comments, so I tried
 >
 >   \newenvironment{Comments}{\iffalse}{\fi}
 >[...]

Here comes this question again! :-)

The following ought to do what you want.

{\catcode`\{= 12 \catcode`\}= 12 \catcode`\@=11 
 \catcode`\[=1 \catcode`]=2 
 \catcode`\|=0 \catcode`\\=12 
 |global|long|def|@Comments#1\end{Comments}[|end[Comments]]
 |global|def|Comments[|let|do|@makeother|dospecials|@Comments]]


--Denys

dhosek@sif.claremont.edu (Hosek, Donald A.) (07/28/90)

In article <811@qusuntrd.queensu.CA>, erskine@qucis.queensu.CA (Neil Erskine) writes...
>	I have a large number of files written using LaTeX and some
>additional macros I wrote.  I sometimes want to suppress certain
>parts of them, so I thought to do this by placing some parts in null
>environments, as in

>\newenvironment{Comments}{}{}
>....
>\begin{Comments}
>Stuff that is sometimes suppressed.
>\end{Comments}

>I now want to suppress the comments, so I tried

>\newenvironment{Comments}{\iffalse}{\fi}

>but no dice, TeX (or LaTeX) won't take it.  The first time the
>Comments environment is used it complains of a missing \fi.  I suppose
>this is one of the standard questions that gets asked here, so don't
>flame too loudly; I just want a method that doesn't involve editing
>all those files.

Yes, this is a tricky problem, but there is a convenient way of
solving it given in verbatim.sty (get the file verbatim.readme
from ymir.claremont.edu in [anonymous.tex.inputs.latex-mainz] to
find out what files you will need. mailserv users can send a
message to mailserv@ymir.claremont.edu with the line
SEND [tex.inputs.latex-mainz]verbatim.readme
to get the list of necessary files). [[As an aside, let me point
out that the facilities provided in the latex-mainz directory
will become part of the next version of LaTeX which is why they
have been set aside in their own directory]]

If you have verbatim.sty you can then do something like

\newenvironment{answer}{\comment}{\endcomment} and have anything
between \begin{answer} and \end{answer} ignored. There are also
some very nice extensions of the verbatim environment and the
ability to do a verbatim input of another file.

-dh

---
Don Hosek                         TeX, LaTeX, and Metafont Consulting and
dhosek@ymir.claremont.edu         production work. Free Estimates.
dhosek@ymir.bitnet                
uunet!jarthur!ymir                Phone: 714-625-0147