如何在包含 alltt 的框架类环境的顶部图形行中间插入一个小标题?

如何在包含 alltt 的框架类环境的顶部图形行中间插入一个小标题?

我需要一个环境来

  1. 使用行尾控制来布局文本行(如诗歌),
  2. 字距和字间距适当,
  3. 在可以跨页面的框架内,
  4. 这样就可以在框架顶部图形行的中间插入一个小标题,
  5. 并且排版命令仍然可以通过某种机制使用。

我一直在使用以下方法:

\newenvironment{QUOTE}[1]
{%
\ifthenelse{\equal{#1}{}}%
{\def\sss{$\vdots$}}%
{\def\sss{#1}}%  
\Verbatim[label=\sss, frame=single, commandchars=@\{\}]}
{\endVerbatim}

例如:

\begin{QUOTE}{75.1}
As the lion in our teargarten remembers the nenuphars of his Nile 
 @emph{( shall Ariuz forget Arioun}
   @emph{or Boghas the baregams of the Marmarazalles from Marmeniere? )} it may be, 
 tots wearsense full
  a naggin in twentyg have sigilposted what in our brievingbust,
  @underline{the besieged} bedreamt @underline{him} stil and solely of @underline{those lililiths} 
  undeveiled which had undone him, gone for age, 
 and knew not the watchful treachers at his wake, and theirs to stay. 
Fooi, fooi, chamermissies! Zeepyzoepy, larcenlads! Zijnzijn Zijnzijn!
\end{QUOTE}

在此处输入图片描述

问题出在需求 2 上。使用 verbatim 时,字距调整和单词间距看起来很糟糕!不过,我使用 verbatim 的框架功能创建了一个框架,并在顶行中放置了标题。

我可以使用framed具有内部alltt环境的环境来解决除第 4 个要求之外的所有要求:

\newenvironment{QUOTENEW}[1]
{%
\ifthenelse{\equal{#1}{}}%
{\def\sss{$\vdots$}}%
{\def\sss{#1}}%  
\begin{framed}\begin{alltt}\normalfont}
{\end{alltt}\end{framed}}

例如:

\begin{QUOTENEW}{75.1}
As the lion in our teargarten remembers the nenuphars of his Nile 
 \emph{( shall Ariuz forget Arioun}
  \emph{or Boghas the baregams of the Marmarazalles from Marmeniere? )} it may be, 
 tots wearsense full
  a naggin in twentyg have sigilposted what in our brievingbust,
  \underline{the besieged} bedreamt \underline{him} stil and solely of \underline{those lililiths} 
  undeveiled which had undone him, gone for age, 
 and knew not the watchful treachers at his wake, and theirs to stay. 
Fooi, fooi, chamermissies! Zeepyzoepy, larcenlads! Zijnzijn Zijnzijn!
\end{QUOTENEW}

在此处输入图片描述

因此我的问题可以归结为以下内容。

  • 如何在框架环境(与逐字环境一样)的顶部图形行中间插入一个小标题?

或者。

  • 我怎样才能实现上述1.至5.?

如果不需要更换,则加分每一个以换行符标记结束的行。

答案1

我使用tcolorbox包创建了一个盒子,然后在 中使用了这个盒子QUOTE。这是结果图,显示它确实是可破坏的并且可以跨越多页:

在此处输入图片描述

以下是 MWE:

\documentclass{article}
\usepackage{ifthen}
\usepackage{framed}
\usepackage{alltt}
\usepackage[most]{tcolorbox}

\newtcolorbox{quotebox}[1]{hbox boxed title,sharp corners,boxrule=1pt,
enhanced,breakable,attach boxed title to top center=
{yshift=-3mm,yshifttext=-1mm},colback=white,
boxed title style={size=small,colback=white,colframe=white},coltitle=black,
title={#1}}


\newenvironment{QUOTE}[1]
{%
\ifthenelse{\equal{#1}{}}%
{\def\sss{$\vdots$}}%
{\def\sss{#1}}%  
\begin{quotebox}{#1}\begin{alltt}\normalfont}
{\end{alltt}\end{quotebox}}

\usepackage{lipsum}

\begin{document}

\begin{QUOTE}{75.1}
As the lion in our teargarten remembers the nenuphars of his Nile 
 \emph{( shall Ariuz forget Arioun}
  \emph{or Boghas the baregams of the Marmarazalles from Marmeniere? )} it may be, 
 tots wearsense full
  a naggin in twentyg have sigilposted what in our brievingbust,
  \underline{the besieged} bedreamt \underline{him} stil and solely of \underline{those lililiths} 
  undeveiled which had undone him, gone for age, 
 and knew not the watchful treachers at his wake, and theirs to stay. 
Fooi, fooi, chamermissies! Zeepyzoepy, larcenlads! Zijnzijn Zijnzijn!

\lipsum

\end{QUOTE}


\end{document}

由于有此breakable选项,tcolorbox可以跨越多个页面。请注意文档说:

/tcb/breakable=true|false|无限制

  • false:将 tcolorbox 设置为牢不可破。

  • true:将 tcolorbox 从一页拆分到另一页。上部和下部的最大总高度约为 65536pt(约 2300cm 或约 90 页)

  • unlimited:可破坏框总高度不受限制的实验代码。对于长度超过 300 页(或更短)的框,必须增加编译器内存。

相关内容