Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!spool.mu.edu!munnari.oz.au!brolga!uqcspe!cs.uq.oz.au!king From: king@cs.uq.oz.au (Paul King) Newsgroups: aus.tex,comp.text.tex Subject: Re: ASCII tabs in verbatim sections Keywords: verbatim tabs Message-ID: <468@uqcspe.cs.uq.oz.au> Date: 27 Mar 91 05:23:23 GMT References: <1991Mar27.004537.6481@research.canon.oz.au> Sender: news@cs.uq.oz.au Reply-To: king@cs.uq.oz.au Followup-To: aus.tex Lines: 118 andy@research.canon.oz.au (Andy Newman) writes: >Has anyone made modifications to LaTeX's verbatim handling to process >ASCII tabs in a ``correct'' manner, i.e. tab stops every eight spaces? Here is a style file that should do what you want. It appeared in comp.text.tex (then called comp.text) several years ago: --------------------cut here for tabverb.sty----------------- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Verbatim With Tabbing and Page Breaks % % Written by: % Michael Fine % Distributed Systems Architecture. % September 1987 % % % This environment is similar to the LaTeX verbatim environment but it % interpretes tab characters as usually expected. It has the % additional feature that a CTL-L in the verbatim environment invokes % the LaTeX macro \newpage (thereby giving you some control over page % breaks). % % There is also a command \inputverbatim which can be used to specify % a file to be input and typeset in the verbatim environment. % % This does not and should be made to work correctly for verbatim* as % well. Also, it should probably use a different name. % % Usage: % % \setlength{\tabwidth} % or % \settowidth{\tabwidth}{text} % % default is width of 8 characters of \normalsize\tt % % Then: % \begin{verbatim} % Verbatim text set in \tt font with ^L for page ejects % and ^I for tabs % \end{verbatim} % % or: % \inputverbatim{filename} % input a file of text % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % A version message % \typeout{Tabbing Verbatim Style } \newlength{\tabwidth} \settowidth{\tabwidth}{\normalsize\tt mmmmmmmm} % default is 8 characters of \tt font in \normalsize \begingroup \catcode`\^^I=\active\def^^L{} \gdef\@newverbatim{\@verbatim \def\par{\egroup\@@par\noindent \@tempdima 0pt\hbox\bgroup{}}\obeylines \let\ignorespaces\relax % for \@gobblecr \catcode`\^^I\active \def^^I{\egroup\setbox\@tempboxa\lastbox\@tempdimb \wd\@tempboxa \box\@tempboxa \advance\@tempdima by \@tempdimb \computeskip\penalty10000 \hskip\@tempdimb\advance\@tempdima by \@tempdimb \hbox\bgroup{}}\def^^L{\egroup\setbox\@tempboxa\lastbox \@tempdimb\wd\@tempboxa \ifdim\@tempdimb=0pt\else\box\@tempboxa\fi {\let\par\@@par\newpage}\noindent\hbox\bgroup\@gobblecr}\relax \def\computeskip{\@tempcnta 0\@tempdimb 0pt\loop \ifdim \@tempdimb<\@tempdima \advance\@tempdimb by \tabwidth \advance \@tempcnta1 \repeat \ifdim\@tempdima=\@tempdimb \advance\@tempcnta1\fi \@tempdimb\@tempcnta \tabwidth \advance \@tempdimb by -\@tempdima}} \gdef\verbatim{\@newverbatim\frenchspacing\@vobeyspaces \@xverbatim\noindent\hbox\bgroup\@gobblecr} \gdef\endverbatim{\egroup\setbox\@tempboxa\lastbox \@tempdimb\wd\@tempboxa \ifdim\@tempdimb=0pt\else\box\@tempboxa\fi \let\par\@@par\endtrivlist} % % Now we define \inputverbatim % % This is similar to \verbatim but does not need \@xverbatim trickery % to delimit the begining and end of the verbatim text. \gdef\inputverbatim#1{{\@newverbatim\frenchspacing\@vobeyspaces \noindent\hbox\bgroup\input{#1}\endverbatim}} \endgroup -------------------end of tabverb.sty----------------------- Simply store this somewhere in your TEXINPUTS path or in the subdirectory you are working in and include `tabverb' as a style option in your documentstyle command, e.g.: \documentstyle[11pt,a4large,tabverb]{article} Hope this helps, Paul. ----------- Paul King _--_|\ Dept. of Computer Science, Univ. of Queensland / X Queensland, Australia, 4072 \_.--._/ king@cs.uq.oz.au (ACSNET) v -- Paul King _--_|\ Dept. of Computer Science, Univ. of Queensland / X Queensland, Australia, 4072 \_.--._/ king@cs.uq.oz.au (ACSNET) v