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

/dev/null as LaTeX environemt: How???

449 views
Skip to first unread message

Uwe Lammers

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
Hi experts,

I can immodestly claim to be quite an experienced TeX user but have not
been able to come up with a satisfactory solution to the following problem:
I want to write a new LaTeX environment which simply ignores everything
that stands between \begin{null} ... \end{null}
[in case you are interested: this is to optionally blank out portions of a
document]. E.g.:

This is some text to appear ...
\begin{null}
Everything in this environment should not appear in the output
...
\end{null}

This is more text to appear ...

\begin{null}
to be ignored
\end{null}
...

The environment is not restricted to contain text only but can
indeed hold tables, figures, etc.

In Knuth's TeXbook, p. 401 there is a trick which seems to do it:

\newenvironment{null}{\output={\setbox0=\box255\deadcycles=0}}%
{\output={}}

but it actually only works for completed pages, i.e., if the
contents of the environment fills a page partially this will appear
in any case.

Any help greatly appreciated
Uwe Lammers (ulam...@astro.estec.esa.nl)

James Kilfiger

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
Uwe Lammers wrote:
>Hi experts,
>
>I can immodestly claim to be quite an experienced TeX user but have not
>been able to come up with a satisfactory solution to the following problem:
>I want to write a new LaTeX environment which simply ignores everything
>that stands between \begin{null} ... \end{null}

Look at comment.sty, or you can use \iffalse...\fi.
These will ignore your text altogether. Otherwise you can use the color
package, redefine the \normalcolor to white, and (provided you haven't
made any colour changes) you will get a big blank space.
HTH
James

Stefan Baums

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
Uwe Lammers <ulam...@astro.estec.esa.nl> writes:

> I want to write a new LaTeX environment which simply ignores everything
> that stands between \begin{null} ... \end{null}

> [in case you are interested: this is to optionally blank out portions of a
> document].

\newcommand{\null}[1]{}

?

Daniel Luecking

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
Uwe Lammers <ulam...@astro.estec.esa.nl> writes:

>Hi experts,

>I can immodestly claim to be quite an experienced TeX user but have not
>been able to come up with a satisfactory solution to the following problem:

>I want to write a new LaTeX environment which simply ignores everything
>that stands between \begin{null} ... \end{null}

There is comment.sty by Victor Eikhout and also verbatim.sty (in the
tools bundle). Use \begin|\end{comment}

A roll-your-own solution is
\newenvironment{null}{\iffalse}{\fi}

--
Dan Luecking Dept. of Mathematical Sciences
luec...@comp.uark.edu University of Arkansas
http://comp.uark.edu/~luecking/ Fayetteville, AR 72101

Heiko Oberdiek

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
On 1 Sep 1999 15:39:05 GMT, luec...@comp.uark.edu (Daniel Luecking)
wrote:

>Uwe Lammers <ulam...@astro.estec.esa.nl> writes:
>>I can immodestly claim to be quite an experienced TeX user but have not
>>been able to come up with a satisfactory solution to the following problem:
>>I want to write a new LaTeX environment which simply ignores everything
>>that stands between \begin{null} ... \end{null}

>[...]


>A roll-your-own solution is
>\newenvironment{null}{\iffalse}{\fi}

* \null is already defined (\hbox{})
* TeX then look ahead for \fi, but it does see \end{null} and
continues looking for the \fi.

Example:
%%% cut %%% test.tex %%% cut %%%
\documentclass{minimal}

\newenvironment{Null}{%
\catcode`\{=12
\catcode`\}=12
\DoNull
}{%
\ignorespacesafterend
}

\begingroup
\catcode`\(=1
\catcode`\)=2
\catcode`\{=12
\catcode`\}=12
\def\x(%
\endgroup
\newcommand\DoNull()
\long\def\DoNull##1\end{Null}(\end(Null))
)
\x

\begin{document}
Hello
\begin{Null}
\begin{center}
\end{center}
Irgendwas
\end{Null}
Welt!
\end{document}
%%% cut %%% test.tex %%% cut %%%

Yours sincerely
Heiko <ober...@ruf.uni-freiburg.de>

Daniel Luecking

unread,
Sep 1, 1999, 3:00:00 AM9/1/99
to
luec...@comp.uark.edu (Daniel Luecking) writes:

>Uwe Lammers <ulam...@astro.estec.esa.nl> writes:

>>Hi experts,

>>I can immodestly claim to be quite an experienced TeX user but have not


>>been able to come up with a satisfactory solution to the following problem:
>>I want to write a new LaTeX environment which simply ignores everything
>>that stands between \begin{null} ... \end{null}

>There is comment.sty by Victor Eikhout and also verbatim.sty (in the

>tools bundle). Use \begin|\end{comment}

>A roll-your-own solution is
>\newenvironment{null}{\iffalse}{\fi}

This was really dumb of me. I am mortified.

I was going to suggest typing \iffalse ...\fi and then
thought, "what the heck, let's make it an environment". Pretty stupid,
since I _do_ know better (really). That's what I get for moving to LaTeX
from plainTeX, I forgot all I once knew.

Jonathan Fine

unread,
Sep 2, 1999, 3:00:00 AM9/2/99
to
Daniel Luecking <luec...@comp.uark.edu> writes

>A roll-your-own solution is
>\newenvironment{null}{\iffalse}{\fi}

I don't think so. TeX will never get to see the \fi, because when it is
skipping tokens (looking for the \fi) it is not expanding macros. So
the \end{null}, that contains the \fi, is skipped, not expanded!

So what you'll get if you use this null environment is that TeX will
give you a missing \fi error at the end of the file!

This is an example for the "steep learning curve" thread elsewhere on
this newsgroup.

Jonathan Fine, Cambridge, UK
Live in the UK? UK TUG AGM, Sunday 12 September, Oxford.

0 new messages