[comp.text] Boxing problem with LaTeX

sstern@astbe.UUCP (Mister Tvister) (09/25/89)

I would like to hear from LaTeX users who have successfully tackled the
following:

In a report style text recourse is occasionally made to examples, which appear
with the distinctions granted them by \begin{verbatim} ... \end{verbatim}, that
is, in a different font sandwiched between appropriately large slabs of
vertical whitespace.  There are doubtless other methods of letting blocks of
text stand out from their context but "verbatim" (or something equivalent) will
be required in the common event where line filling (because something messy
like a terminal session is being described) must be temporarily suspended.

One should like to further isolate these examples from their surroundings using
boxes.  A boxed example has a line frame around it with narrow blank margins,
inside and outside the frame on all four sides.  The frame will accordingly be
as long as a text line and approximately as high as the block manipulated
internally by the "verbatim" mechanism.

I am no (La)TeX whiz but could also not discern in the LaTeX reference book
any means to accomplish this.  In fact, I didn't even find a convincing TeX
starting point since the most general methods of box drawing seem always to
involve absolute co-ordinates and examples, unless one relegates them to an
unhappy existence as figures in an appendix, are necessarily anchored by
context.

mj@myrias.com (Michal Jaegermann) (09/28/89)

In article <824@astbe.UUCP> sstern@astbe.UUCP (Mister Tvister) writes:
> A boxed example has a line frame around it with narrow blank margins,
> inside and outside the frame on all four sides.  The frame will accordingly be
> as long as a text line and approximately as high as the block manipulated
> internally by the "verbatim" mechanism.

> I am no (La)TeX whiz but could also not discern in the LaTeX reference book
> any means to accomplish this.

% For boxed text in latex you may try the following.  It is not perfect,
% but it is simple and it works.  Of course a use of typewriter font
% caused a lot of underfull \hbox'es, which I choosed to ignore.
% I presume that a similar thing you may do with a minipage.
% 
%     Michal Jaegermann
%     Myrias Research Corportaion
%     mj@myrias.COM
% 
% ================ an example in latex follows ================
 
\documentstyle[12pt]{article}
\begin{document}
\newlength{\boxspan}
\newlength{\oldindnt}
\setlength{\oldindnt}{\parindent}   % save old value
\setlength{\boxspan}{\textwidth}    % width of a box we will create
\addtolength{\boxspan}{-1em}        % decrease it slightly, so frames
                                    % will not stick out to margins
 
\newcommand{\boxit}[1]{
\setlength{\parindent}{0pt}
\framebox[\textwidth]{\parbox{\boxspan}{
\setlength{\parindent}{\oldindnt}\smallskip\par{\tt #1}\smallskip\par
}}} %end of \boxit
% a whole argument to this version of the command will be set in
% a typewriter font - modify to your liking.
 
% this is a fragment of a text authored by my 13 year old son
 
\section{Adventure Background}
 
   Read this at the beginning of the adventure:
 
\bigskip 
 
\boxit{
    It is the season of Gwaeron, or in Westron the season of stirring.
The time when the snow starts to slowly fade away and the bears begin to
wake from their winter slumber.\\
 
\verb+   You are hardy adventurers.+\\
\verb+Well, by now more like really hardy, and bored+\\
\verb+adventurers, after sitting in The Last Inn all winter long!+\\
 
    During the long cold winter days you have listened to many tales.  One of 
them seems very interesting and credible.  It concerns some caves northeast
of here.  Asking the Innkeeper more about the story he confirms it and even 
for a few silvers gives you a set of directions that should lead you to
these caves!
} % end of boxed text
 
    You vowed that the first day the snow was thin enough you would try
to find the caves.  Today is the day!
 
\end{document}
%================

--
	Michal Jaegermann
	Myrias Research Corporation
	Edmonton, Alberta, CANADA
	mj@myrias.COM
	...{uunet,alberta}!myrias!mj