tags:

views:

56

answers:

2

I have a verbatim environment containing computer output as text. This text is sematically made of two sections, each section being separated from the other by an empty line.

The number of sections and their content is known, so I don't need to parse the text, but the line between the sections is very important (as it gives semantics to the "text").

Each segment is made of multiple lines. How could I write (1) and (2) on the left handside at the centre of each segment?

Sample output:

        hello world
(1)     out there
        how are you?

        I am
        fine
(2)     thanks
        and
        you?

The numbers (1) and (2) MUST NOT be inside the environment, they must be outside, and on the left, not as marginpar.

I suspect it comes down to putting a \box{} or something in front of the words "out" and "thanks" and moving them to the left by a negative amount. But I don't know how to achieve that.

+1  A: 

Perhaps use minipage:

\renewcommand{\labelenumi}{(\arabic{enumi})}
\begin{enumerate}
\item
\begin{minipage}[c]{1in}
\begin{verbatim}
hello world
out there
how are you?
\end{verbatim}
\end{minipage}

\item
\begin{minipage}[c]{1in}
\begin{verbatim}
I am
fine
thanks
and
you?
\end{verbatim}
\end{minipage}
\end{enumerate}
unutbu
A: 

I have managed to do it the way I wanted and still keep the semantics of a single verbatim environment like this:

\usepackage{fancyvrb}
\makeatletter
\newcommand{\nl}[1]{\hbox to\z@{%
    \hss (#1) \kern3pt}}
\makeatother

And the usage:

\begin{Verbatim}[commandchars=\\\{\}]
HTTP/1.1 200 OK
Server: Apache/2.2.3 (Red Hat)
Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT
ETag: "b300b4-1b6-4059a80bfd280"            
\nl{1}Accept-Ranges: bytes                        
Content-Type: text/html; charset=UTF-8      
Connection: Keep-Alive                      
Date: Tue, 15 Dec 2009 11:52:46 GMT         
Age: 2528                                   
Content-Length: 438

<HTML>
<HEAD>
  <TITLE>Example Web Page</TITLE>
</HEAD>                          
<body>                           
\nl{2}<p>You have reached this web page by typing &quot;example.com&quot;,
&quot;example.net&quot;,                                            
  or &quot;example.org&quot; into your web browser.</p>             
<p>These domain names are reserved for use in documentation and are not available 
  for registration. See <a href="http://www.rfc-editor.org/rfc/rfc2606.txt"&gt;RFC   
  2606</a>, Section 3.</p>                                                        
</BODY>                                                                           
</HTML>
\end{Verbatim}
Flavius