[texworks] turning on or off portions of .tex output

Philip TAYLOR (Webmaster, Ret'd) P.Taylor at Rhul.Ac.Uk
Tue Aug 2 10:59:03 CEST 2011


<Steve.Gadbois at musowls.org> wrote :

> I have a TeX document for which I wish to be able to turn “on” or
> “off” selected portions of text in the typeset result, without
> painstakingly changing the .tex file each time.  (Thus, for example,
> I do NOT wish to comment out certain lines, with %, only to undo,
> redo, etc. later.)  Of course, I am willing to insert appropriate
> markers or delimiters in the .tex file once, and then somehow
> externally “flip a switch” to either print or not print the selected
> portion(s).  Ideally, I’d even like to be able to turn on or off
> within  {$  $}  or within  {$$  $$} .  Is anyone aware of a method?
> Thanks.

> My application is a class handout for which I wish to have both a
> complete version as well as an outline version to hand out to
> students, with key elements (e.g., proofs) omitted because they will
> be filled in during class (in an attempt to keep students fully
> engaged).  Since the handout will constantly evolve, I don’t want to
> keep and constantly update parallel versions.

This sounds to me like a fairly simple exercise in TeX (rather
than in TeXworks); you will need something along the lines of
the following :

	\newif \ifshewkeyelements
	\shewkeyelementstrue % or false

	\ifshewkeyelements
		This is a proof
	\fi
	...
	\ifshewkeyelements
		This is another proof
	\fi

All that is then necessary is to adjust the contents
of line two to read either \shewkeyelementstrue or
\shewkeyelementsfalse as desired for a particular
document run.  Of course, you may run into situations
where this causes problems, but it is certainly worth
trying to see if it is satisfactory with your existing
material.

Philip Taylor



More information about the texworks mailing list