Latex Output Segments

I have a shorthand environment containing computer output as text. This text is semantically made up of two sections, each section separated from the other by a blank line.

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

Each segment consists of several lines. How could I write (1) and (2) on the left side in the center of each segment?

Output example:

        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 to the left, not like a marginpar.

I suspect it boils down to putting \ box {} or something in front of the words "out" and "thank you" and move them to the left by a negative amount. But I don't know how to achieve this.

+2


a source to share


2 answers


I managed to do it the way I wanted and keep the semantics of one verbatim environment like this:

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

      



And 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">RFC   
  2606</a>, Section 3.</p>                                                        
</BODY>                                                                           
</HTML>
\end{Verbatim}

      

0


a source


Maybe 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}

      

+1


a source







All Articles