[comp.text.tex] Answers to two really hard LaTeX puzzles

sjb@cs.toronto.edu (Stephen Bellantoni) (11/14/90)

Thanks to all the people who replied to these puzzles. One of the 
problems is totally solved, the other is mostly solved. 

(1) How to define a "comment" environment.

	Apparently this was discussed on the net recently. The suggestions 
	I received were:

	(a) Imitate the \verbatim environment.

	(b) Use the comment environment in Rainer Sch\"opf's verbatim 
		implementation (TUGboat 11/2,1990)

	(c) Use \bgroup:
		   \def\comment{\bgroup\setbox0=\vbox\bgroup} 
		   \def\endcomment{\egroup\egroup}

	(d) Use "annotation.sty" by Tom Hofmann, wtho@ciba-geigy.ch

    I tried (a) and (d). Both of these worked as described, but they did not
    solve my problem because I wanted to be able to create new comment
    environments at will. I wanted something which would give the same
    functionality as #ifdef in C. Neither the macros described in (a) or in
    (d) can be put directly inside of \def's. After some hacking I came up
    with a nice style which is attached below.

	This style, "version.sty", lets you define any number of comment-type
	environments, and turn them on or off at will. It also properly avoids
	inserting a \space at the place where the comment appeared in the file.


(2) How to print postscript documents "2-up". 
	
	Basically the answer to this is to get a special dvi interpreter. 
	I wasn't able to get one that worked for me --- your mileage may vary.
	Specific suggestions I received were:

	(a) Use the program "psnup" from wuarchive.wustl or simtel20, in 
		unix-c/postscript. This program surrounds your postscript with
		code to redefine certain underlying macros such as initmatrix,
		showpage, etc. It should work for "non-conforming" postscript
		code such as that produced by my dvi2ps. However, it gave an
		error when I spooled it to my Imagen Ultrascript interpreter.
		I assume it works for other postscript devices.
		Ned B., if you're out there: the error was, approximately, 
		"-gpage undefined".
	
	(b) Use the program "mpage" (from the same archive directory as psnup).
		This program apparently accepts non-conforming postscript code
		and claims to print it 4-up. When I tried it I got four nice
		boxes outlining where the text should be, but the text itself
		was full-size, not shrunk. All four pages printed over each other
		on one sheet! Again on the Imagen.
		Boris Aronov <baronov@polyof.poly.edu> reports that mpage is 
		in v09i088 and v09i089 of comp.unix.misc.
	
	(c) Use the "up" perl shell script. This is a perl script which chops
		up your conforming PostScript code and prints each page prefixed 
		by commands which set the coordinates appropriately. It didn't work
		for me because my dvi2ps produces non-conforming code. I got my 
		copy from raymond@math.berkeley.edu (Raymond Chen) --- I'll forward
		it to you if you want.
		Boris Aronov <baronov@polyof.poly.edu> reports that up is 
		in v08i095 of comp.unix.misc.

	(d) Add "a very small amount of code" to your local dvi processor. 
		Variations on this were suggested by Timothy Murphy <tim@maths.tcd.ie>
		and by Jeremy.Gibbons@prg.oxford.ac.uk. 


Here's a list of the people who were kind enough to reply. Thanks!

	jdm5548@diamond.tamu.edu (James Darrell McCauley)
	tim@maths.tcd.ie (Timothy Murphy)
	Harald Hanche-Olsen <hanche@imf.unit.no>
	raymond@math.berkeley.edu (Raymond Chen)
	baronov@polyof.poly.edu (A1 boris aronov (cs) )
	Jeremy.Gibbons@prg.oxford.ac.uk
	wtho@ciba-geigy.ch


Here's the style, "version.sty". Enjoy!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Version control macros. These let you define environments whose contents
% will be optionally added to or deleted from the text when you run LaTeX.
% Usage: place either of the following near the start of your file:
%     \includeversion{NAME}
%     \excludeversion{NAME}
% Here, "NAME" is any name you choose. The first one indicates that text
% between \begin{NAME} and \end{NAME} will be processed in the normal way.
% The second indicates that text between \begin{NAME} and \end{NAME} will
% be totally deleted.
% You can define environments for as many versions as you want. 
% A ``comment'' environment has already been pre-defined for you with 
% \excludeversion{comment}; you can override this using \includeversion.
%
% Example: 
%   \includeversion{abridged}\excludeversion{unabridged}
%   Text for the
%   \begin{abridged} 
%      short
%   \end{abridged}
%   \begin{unabridged}
%      long and really longwinded, opaque and boring
%   \end{unabridged}
%   version of the paper. Punctuation works correctly\begin{unabridged}
%   because sphack is used\end{unabridged}.
%   \begin{comment} This is deleted by default. \end{comment}
%
% Stephen Bellantoni 1990, loosely based on "annotation.sty" by Tom Hofmann.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begingroup
\catcode`@=11\relax%
\catcode`{=12\relax\catcode`}=12\relax%
\catcode`(=1\relax \catcode`)=2\relax%
\gdef\includeversion#1(%
  \expandafter\gdef\csname #1\endcsname%
    ()%
  \expandafter\gdef\csname end#1\endcsname%
    ()%
)%
\gdef\excludeversion#1(%
  \expandafter\gdef\csname #1\endcsname%
    (\@bsphack\catcode`{=12\relax\catcode`}=12\relax\csname #1@NOTE\endcsname)%
  \long\expandafter\gdef\csname #1@NOTE\endcsname ##1\end{#1}%
    (\csname #1END@NOTE\endcsname)%
  \expandafter\gdef\csname #1END@NOTE\endcsname%
    (\@esphack\end(#1))%
)%
\endgroup
\excludeversion{comment}

decouty@irisa.fr (Bertrand Decouty) (11/14/90)

In article <90Nov13.135116edt.102@smoke.cs.toronto.edu> sjb@cs.toronto.edu (Stephen Bellantoni) writes:
| 
| Thanks to all the people who replied to these puzzles. One of the 
| problems is totally solved, the other is mostly solved. 
| 
[...]
| 
| (2) How to print postscript documents "2-up". 
| 	
| 	Basically the answer to this is to get a special dvi interpreter. 
| 	I wasn't able to get one that worked for me --- your mileage may vary.
| 	Specific suggestions I received were:
| 
| 	(a) Use the program "psnup" from wuarchive.wustl or simtel20, in 
[...]	
| 	(b) Use the program "mpage" (from the same archive directory as psnup).
[...]	
| 	(c) Use the "up" perl shell script. This is a perl script which chops
[...]
| 	(d) Add "a very small amount of code" to your local dvi processor. 
| 		Variations on this were suggested by Timothy Murphy <tim@maths.tcd.ie>
| 		and by Jeremy.Gibbons@prg.oxford.ac.uk. 

	(e) use multi! enables you to print 2/4/8/16 (if you still can
read!) on a physical sheet of paper. VERY fine, and it works (with dvips,
mp, enscript). multi is a
shell script which adds before and after your ps file a prologue and a
postlogue. Available, among other sites, at irisa.irisa.fr, cd Postscript.
I have added some options to the shell script and written a man page. 
PS: i am NOT the author of multi, who is 
Ross Cartlidge <rossc@extro.ucc.su.oz.au>. Thanks to him.
| 
[...]
Bertrand Decouty
-- 
[ Bertrand DECOUTY             | EMAIL : decouty@irisa.fr, decouty@irisa.uucp  ]
[ IRISA - INRIA (Atelier)      |         {uunet,mcsun,inria}!irisa!decouty     ]
[ Campus de Beaulieu           | PHONE : +33  99 36 20 00                      ]
[ F-35042 Rennes Cedex - FRANCE| FAX : +33  99 38 38 32 | TELEX: 950473 UNIRISA]

wolf@fb14vax.sbsvax.uucp (Wolfgang Huwig) (11/17/90)

In article <1990Nov14.093033.23993@irisa.fr> decouty@irisa.fr (Bertrand Decouty) writes:

   [...]
	   (e) use multi! enables you to print 2/4/8/16 (if you still can
   read!) on a physical sheet of paper. VERY fine, and it works (with dvips,
   [...]

But you should use it with PostScript fonts. I've used it with dvips and a
laserwriter and the PS version looked quite good even 4 up whereas the
version using TeX fonts already looked ugly 2up (some pixels got simply
lost, e.g. the whole baseline).
Anyone a solution using TeX fonts which is still looking good? (I like CM)

Wolfgang
---
internet: wolf@cs.uni-sb.de