乳胶计算机输出段

发布于 2024-09-01 12:10:58 字数 459 浏览 3 评论 0原文

我有一个包含计算机输出文本的逐字环境。该文本在语义上由两个部分组成,每个部分之间用空行分隔。

部分的数量及其内容是已知的,因此我不需要解析文本,但部分之间的线非常重要(因为它为“文本”提供了语义)。

每个段由多条线组成。我怎样才能在每段中间的左侧写上(1)和(2)?

示例输出:

        hello world
(1)     out there
        how are you?

        I am
        fine
(2)     thanks
        and
        you?

数字 (1) 和 (2) 不得位于环境内部,它们必须位于外部且位于左侧,而不是作为 marginpar。

我怀疑这归结为在“out”和“thanks”前面放置一个 \box{} 或其他东西,并将它们向左移动负数。但我不知道如何实现这一目标。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北城孤痞 2024-09-08 12:10:58

也许使用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}

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}
歌入人心 2024-09-08 12:10:58

我已经设法按照我想要的方式做到这一点,并且仍然保留单个逐字环境的语义,如下所示:

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

以及用法:

\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 "example.com",
"example.net",                                            
  or "example.org" 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}

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 "example.com",
"example.net",                                            
  or "example.org" 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}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文