# [texhax] \switch statement

Stephen Hicks sdh33 at cornell.edu
Wed Oct 12 19:53:37 CEST 2011

There are a number of things you might do, depending on how your
project is laid out.  I've seen people who have many files (i.e. one
file per chapter/section) use different "driver" files to include
these chapters - a fullbook.tex driver that brings everything in, a
one chapter driver that pulls in a single chapter (which can be
changed as needed), etc.

If your project is a single file, you could accomplish something
similar with conditionals in the preamble.  I'm less familiar with
LaTeX-style conditionals, but in plain TeX you could define
\newif\chapi \newif\chapii \newif\chapiii \newif\chapiv (etc - note
that numbers don't work in control sequences, hence the roman
numerals), and then wrap your chapters in \ifchapi ... \fi.  You'll
need to write \chapitrue\chapiitrue (etc) at the front as well, and
can change it to \chapiifalse to, e.g., turn off chapter 2.

If you really want a goto (note: goto is generally considered harmful,
but this one is a little more sane), you could write the following:

\def\goto#1{\begingroup\def\go##1#1{\endgroup}\go}

and then write \goto\foo which will just cut out everything up to the
next \foo in the document.  If you want to disable \goto, you could

\def\goto#1{\let#1\relax}

But be very careful of jumping into/out of environments, as it will

Cheers,
steve

On Wed, Oct 12, 2011 at 2:58 AM, Dr A K Hannaby
<keith.hannaby at mathshelp.com> wrote:
> Tug
>
> Is it possible to speed up, for draft viewing purposes, a “build and view”
> in Miktex 2.9 by using some kind of \switch or \goto statement?
>
> That is, without disturbing masses of text, be able to jump over the bits
> you are currently not dealing with.
>
> Dr Keith Hannaby
>
> _______________________________________________
> TeX FAQ: http://www.tex.ac.uk/faq
> Mailing list archives: http://tug.org/pipermail/texhax/