[comp.text.tex] Screen dump as Figure

randy@oetl.UUCP (Randy O'Meara) (04/07/90)

NOTE:  vtscreen.sty appears at the end of this article.

    In an earlier posting I asked:
>
>	The LaTex manual states that ``A verbatim or verbatim*
>	environment may not appear in the argument of any command.''
>
>	Why?
>	
>	I'd like to inhale (ascii) screen dumps from a computer
>	console, enclose them in boxes, and label them as figures.  

    Thanks to the following people for taking the time to respond via email:
	Joe Pallas <pallas@Neon.Stanford.EDU>
	Douglas Miller <munnari!csv.viccol.edu.au!DOUGCC>
	raymond@bosco.Berkeley.EDU (Raymond Chen)
	Victor Eijkhout <lstc!sci.kun.nl!eykhout>

    I tried responding to each of you personally, but mail failed for two.
    Since others have asked me to post the results of my query, I will do so.

    The reason that \verbatim may not appear in the argument of a
    command is:  (From raymond@math.berkeley.edu)

	Because the verbatim mode changes catcodes, and TeX
	stamps catcodes on characters the moment they are read.
	So when TeX reads the arguments to a command that contains 
	verbatim text, TeX doesn't know it yet (it doesn't analyze
	the contents of the argument) so they get stamped with the
	wrong catcode.

    My deepest appreciation goes to Douglas Miller who sent me the
    following vtscreen.sty and example of usage:
    
       \documentstyle[vtscreen]{article}
	
       \begin{document}
	
       \begin{figure}
       \caption{Some numbers}
       \begin{VTscreen}{\columns=80\lines=25}
       123456789012345678901234567890123456789012345678901234
       56789012345678901234567890
       123456789012345678901234567890123456789012345678
       90123456789012345678901234567890
       \end{VTscreen}
       \end{figure}
	
       \begin{figure}
       \caption{TABLE.COM}
       \begin{VTscreen}{\columns=80\lines=25}
       \input{table.com}
       \end{VTscreen}
       \end{figure}
       
       \end{document}

	% VTSCREEN.STY
	% the following definitions enable use of the command \curfontsize for
	% obtaining the current font size.
	\def\@vpt{\def\curfontsize{5pt}}
	\def\@vipt{\def\curfontsize{6pt}}
	\def\@viipt{\def\curfontsize{7pt}}
	\def\@viiipt{\def\curfontsize{8pt}}
	\def\@ixpt{\def\curfontsize{9pt}}
	\def\@xpt{\def\curfontsize{10pt}}
	\def\@xipt{\def\curfontsize{11pt}}
	\def\@xiipt{\def\curfontsize{12pt}}
	\def\@xivpt{\def\curfontsize{14pt}}
	\def\@xiipt{\def\curfontsize{17pt}}
	\def\@xxpt{\def\curfontsize{20pt}}
	\def\@xxvpt{\def\curfontsize{25pt}}

	\def\@semiverbatim{%
	   \tt\baselineskip=\curfontsize
	   \parindent\z@\parfillskip\@flushglue\parskip\z@%
	   \obeylines\catcode``=13\@noligs
	   \catcode`\$=12 \catcode`\&=12 \catcode`\#=12%
	   \catcode`\%=12 \catcode`\~=12
	   % \catcode`\_=12 \catcode`\^=12 % Not necessary as they are active
	   \frenchspacing\@vobeyspaces}

	\def\VTscreenboxaction{}
	\newdimen\VTscreenv
	\newdimen\VTscreenh
	\newbox\VTscreenbox%
	\newenvironment{VTscreen}[1]{\bgroup
	   \scriptsize % default
	   \def\key##1{%
	      \dimen0=0.5\baselineskip
	      \fboxsep=0.1\baselineskip
	      \@key{\vpt\sf ##1}}%
	   \newcount\columns\columns=50 % default
	   \newcount\lines\lines=16 % default
	   #1%
	   \@tempswafalse
	   \def\par{\if@tempswa\strut\endgraf\fi\@tempswatrue}
	   \@semiverbatim
	   \setbox\strutbox=\hbox{\vrule height 0.7\baselineskip
	      depth 0.3\baselineskip width 0pt}
	   \VTscreenv=\curfontsize
	      \multiply\VTscreenv by \lines
	      \VTscreenh=0.5em\multiply\VTscreenh by \columns%
	   \VTscreenboxaction
	   \global\setbox\VTscreenbox=\vtop to \VTscreenv\bgroup
	      \hsize=\VTscreenh\textwidth=\hsize
	      }%
	   {\vfil
	   \egroup\egroup
	   \fboxsep=0pt\fbox{\raisebox{1.5ex}{\vtop{\vspace{.5ex}
	   \hbox{\hspace{0.55ex}\box\VTscreenbox\hspace{0.55ex}}\vspace{0.50ex}}}}}%

-- 
Randy O'Meara		randy@oetl.Scf.Lockheed.Com
(408) 425-6249		...{pyramid,leadsv,lstc}!oetl!randy