Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

excluding large segments of text in LaTeX?

2,188 views
Skip to first unread message

Grant

unread,
Jan 25, 2002, 2:57:22 PM1/25/02
to

Hi - I'd like to find out whether there is a LaTeX command or
environment that allows one to easily exclude a large block of text from
being processed, kind of like the /* and */ delimiters in C. E.g.,

\begin{ignore}
...
\end{ignore}

The alternative of painstakingly prepending every line with '%' (and
later deleting them) seems inefficient and error prone.

Thought this might be a FAQ, but can't find any reference to such a
thing.

thanks,

Grant

Sergio Mendoza

unread,
Jan 25, 2002, 4:38:26 PM1/25/02
to
How about the comment package:

ftp://ftp.dante.de/tex-archive/macros/latex/contrib/other/comment.tar.gz

Sergio.

PS If you use a reasonable good editor: vi (clones: vim or elvis) or
emacs, it should be a piece of cake to insert as many %'s at the
beginning of as many lines as you want...

Harald Hanche-Olsen

unread,
Jan 25, 2002, 4:42:41 PM1/25/02
to
+ Grant <gpe...@aos.wisc.edu>:

| [...] whether there is a LaTeX command or environment that allows


| one to easily exclude a large block of text from being processed

The comment environment in the verbatim package.

Another possibility, which I frequently use, is

\iffalse
...
\fi

--
* Harald Hanche-Olsen <URL:http://www.math.ntnu.no/~hanche/>
- Yes it works in practice - but does it work in theory?

Robin Fairbairns

unread,
Jan 25, 2002, 4:59:03 PM1/25/02
to
Grant <gpe...@aos.wisc.edu> wrote:
>Hi - I'd like to find out whether there is a LaTeX command or
>environment that allows one to easily exclude a large block of text from
>being processed, kind of like the /* and */ delimiters in C.
>
>[...]

>
>Thought this might be a FAQ, but can't find any reference to such a
>thing.

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=conditional
--
Robin Fairbairns, Cambridge -- rf10 at cam dot ac dot uk

Ben Crowell

unread,
Jan 25, 2002, 5:00:05 PM1/25/02
to
\newcommand{ignore}{}{}

Ben Crowell

unread,
Jan 25, 2002, 5:03:20 PM1/25/02
to
Oops, sorry -- my previous post should have said:

\newenvironment{ignore}{}{}

David Kastrup

unread,
Jan 25, 2002, 5:13:51 PM1/25/02
to
ben_c...@hotmail.com (Ben Crowell) writes:

> Oops, sorry -- my previous post should have said:
>
> \newenvironment{ignore}{}{}

Well, if you were longing for public embarrassment, perhaps it should
have said that.

Think about it. Or try it out.

--
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: David....@t-online.de

Robin Fairbairns

unread,
Jan 25, 2002, 6:54:11 PM1/25/02
to
Ben Crowell <ben_c...@hotmail.com> wrote:
>\newcommand{ignore}{}{}

don't try this at home, folks ;-)

the faq answer does mention gobble commands, but dismisses them
because they're inappropriate for large chunks of comment, and prone
to being confused by perfectly reasonable comment text.

Oliver Corff

unread,
Jan 28, 2002, 4:04:02 AM1/28/02
to
David Kastrup <David....@t-online.de> wrote:
:>
:> \newenvironment{ignore}{}{}

: Well, if you were longing for public embarrassment, perhaps it should
: have said that.

Well. He defines an environment "ignore". The definition body is empty,
so nothing happens. The four lines

%
\begin{ignore}
\end{ignore}
%

should produce no text, or do they ?-)

Oliver.
--
Dr. Oliver Corff e-mail: co...@zedat.fu-berlin.de

Jonathan Dentch

unread,
Jan 28, 2002, 10:03:10 AM1/28/02
to
Grant,

Consider placing the large block of text in a separate file. Then use
the \input command to include the large block of text in the main
file. If you don't want to process the large block of text, simply
place a '%' in front of the \input line.

I hope this helps.

Jonathan Dentch

Grant <gpe...@aos.wisc.edu> wrote in message news:<3C51B8A2...@aos.wisc.edu>...

Peter Boettcher

unread,
Jan 28, 2002, 10:15:27 AM1/28/02
to
Grant <gpe...@aos.wisc.edu> writes:

> Hi - I'd like to find out whether there is a LaTeX command or
> environment that allows one to easily exclude a large block of text from
> being processed, kind of like the /* and */ delimiters in C. E.g.,
>
> \begin{ignore}
> ...
> \end{ignore}
>
> The alternative of painstakingly prepending every line with '%' (and
> later deleting them) seems inefficient and error prone.

Do it with your editor? If your editor does not support block
commenting, use a different editor.


--
Peter Boettcher
MIT Lincoln Laboratory
boet...@ll.mit.edu
(781) 981-5275

Christopher Jensen

unread,
Jan 28, 2002, 9:25:24 PM1/28/02
to
The LaTeX Companion mentions that the verbatim package provides a comment
environment.

\usepackage{verbatim}

\begin{comment}
....
\end{comment}

Looks like something your looking for. Hope it helps.

Chris

Michael Barr

unread,
Jan 28, 2002, 9:36:12 PM1/28/02
to
Peter Boettcher <boet...@ll.mit.edu> wrote in message news:<tr665m1...@coyote.llan.ll.mit.edu>...

> Grant <gpe...@aos.wisc.edu> writes:
>
> > Hi - I'd like to find out whether there is a LaTeX command or
> > environment that allows one to easily exclude a large block of text from
> > being processed, kind of like the /* and */ delimiters in C. E.g.,
> >
> > \begin{ignore}
> > ...
> > \end{ignore}
> >
> > The alternative of painstakingly prepending every line with '%' (and
> > later deleting them) seems inefficient and error prone.

I got this from someone and I have used it without difficulty:

\def\comment{\begingroup
\let\do=\makeother \dospecials
\endlinechar`\^^M \catcode`\^^M=12 \xcomment }
{\escapechar=-1 \xdef\endcomment{\string\\endcomment}
}

You start it with \comment and end with \endcomment. I believe that
the \endcomment must appear on a line by itself.

Robin Fairbairns

unread,
Jan 29, 2002, 6:54:46 AM1/29/02
to
Michael Barr <ba...@barrs.org> wrote:
>I got this from someone and I have used it without difficulty:
>
>\def\comment{\begingroup
> \let\do=\makeother \dospecials
> \endlinechar`\^^M \catcode`\^^M=12 \xcomment }
>{\escapechar=-1 \xdef\endcomment{\string\\endcomment}
>}
>
>You start it with \comment and end with \endcomment. I believe that
>the \endcomment must appear on a line by itself.

and \xcomment comes from which package? it looks intriguing stuff,
whatever it is.

Michael Barr

unread,
Jan 30, 2002, 9:03:05 AM1/30/02
to
r...@pallas.cl.cam.ac.uk (Robin Fairbairns) wrote in message news:<a362i6$ltj$1...@pegasus.csx.cam.ac.uk>...

> Michael Barr <ba...@barrs.org> wrote:
> >I got this from someone and I have used it without difficulty:
> >
> >\def\comment{\begingroup
> > \let\do=\makeother \dospecials
> > \endlinechar`\^^M \catcode`\^^M=12 \xcomment }
> >{\escapechar=-1 \xdef\endcomment{\string\\endcomment}
> >}
> >
> >You start it with \comment and end with \endcomment. I believe that
> >the \endcomment must appear on a line by itself.
>
> and \xcomment comes from which package? it looks intriguing stuff,
> whatever it is.

Very sorry; I included only half the code. Here is the full shot:

\def\makeother#1{\catcode`#1=12}
{\catcode`\^^M=12 \endlinechar=-1 %
\gdef\xcomment#1^^M{\def\test{#1}
\ifx\test\endcomment \let\next=\endgroup
\else \let\next=\xcomment \fi
\next}


}
\def\comment{\begingroup
\let\do=\makeother \dospecials
\endlinechar`\^^M \catcode`\^^M=12 \xcomment }
{\escapechar=-1 \xdef\endcomment{\string\\endcomment}
}

I still don't recall who gave me this code. Maybe Donald Arsenau.

Grant

unread,
Feb 1, 2002, 11:27:24 AM2/1/02
to


There was a wide variety of responses to my question. One of them was
exactly what I was looking for, and that was the suggestion to use the
'comment' environment provided by the 'verbatim' package.

Some of the other suggestions, like using an EMACS macro to
"efficiently" insert or delete '%' at the beginning of a series of lines
is what I had already been doing. My main objection to this method is
that if, by chance, a block of text gets reformatted (e.g., Esc-Q in
EMACS), then suddenly you have all your '%' characters embedded at
random locations within the text, rather than at the beginning of the
line where they belong.

Another suggestion, \newenvironment{ignore}{}{}, doesn't look to me
like it should work. Wouldn't

\begin{ignore}

text to ignore

\end{ignore}

just expand to

{}

text to ignore

{}

?


- Grant

Yvon Henel

unread,
Feb 1, 2002, 12:59:23 PM2/1/02
to
Grant a écrit :

> Grant wrote:
>>
[snip]

> Another suggestion, \newenvironment{ignore}{}{}, doesn't look to me
> like it should work. Wouldn't
>
> \begin{ignore}
>
> text to ignore
>
> \end{ignore}
>
> just expand to
>
> {}
>
> text to ignore
>
> {}
>
> ?
>
>
> - Grant
>

Yes.
--
Y.Henel, TeXnicien de surface. (sorry but I cannot translate that (bad) pun)

Rowland McDonnell

unread,
Feb 1, 2002, 4:25:26 PM2/1/02
to
Robin Fairbairns <r...@pallas.cl.cam.ac.uk> wrote:

> Grant <gpe...@aos.wisc.edu> wrote:
> >Hi - I'd like to find out whether there is a LaTeX command or
> >environment that allows one to easily exclude a large block of text from
> >being processed, kind of like the /* and */ delimiters in C.
> >
> >[...]
> >
> >Thought this might be a FAQ, but can't find any reference to such a
> >thing.
>
> http://www.tex.ac.uk/cgi-bin/texfaq2html?label=conditional

Hmm. I whizzed through the FAQ TOC looking for this answer (and note
that I knew the answer was there), and I didn't pick it out. I think a
different title for that section might help, but I can't think of an
greatly improved version of the top of my head.

The best I can come up with is `Conditional inclusion of text' - not
great, is it?

Rowland.

--
Remove the animal for email address: rowland....@dog.physics.org
PGP pub key 0x62DCCA78 Sorry - the spam got to me
http://www.mag-uk.org
UK biker? Join MAG and help keep bureaucracy at bay

Donald Arseneau

unread,
Feb 1, 2002, 7:55:48 PM2/1/02
to
Yvon Henel <Yvon....@wanadoo.fr> writes:

> > Another suggestion, \newenvironment{ignore}{}{}, doesn't look to me
> > like it should work. Wouldn't
> >
> > \begin{ignore}
> > text to ignore
> > \end{ignore}
> >
> > just expand to
> >
> > {}
> > text to ignore
> > {}

> Yes.

No. More like

{
text to ignore
}

(with \begingroup and \endgroup for the braces, plus some
assignments and error checking for proper environment nesting.)

Donald Arseneau as...@triumf.ca


0 new messages