棺材中的橡胶长度并与段落底部基线对齐

棺材中的橡胶长度并与段落底部基线对齐

我想要获得特定的布局,如下所示:在一行中的某个点,我想“切换到段落模式”(就像 aparbox所做的那样),然后在其他某个点,我想恢复到正常的全宽排版。就我而言,我的想法是使用 获得类似目录的外观dotfill,但我想这个问题也代表常规文本。

使用该xcoffins包我得到了这个部分解决方案(下面的 MNWE),它在代码方面既不是很优雅,在结果方面也不正确:

结果

我的问题(上图箭头所示):

  1. 这是正确的™方法吗?
  2. 我希望“点填充”一直到右边距。使用两个\dotfill命令似乎可行,但结果看起来不太正确(参见图片,两个点填充之间有多余的空间)。有办法解决这个问题吗?
  3. 如何修复棺材下方错误的行间距?在“中心列”,我希望所有行均等分布。
  4. 有没有更优雅的方式来水平连接两个带有相邻文本的棺材? 在这里,我将其连接起来bolpara留有明确的.5ex间距,但感觉不对(尽管看起来还可以)。

\documentclass{minimal}

\setlength{\parindent}{0pt}

\usepackage{xcoffins}

\begin{document}

\NewCoffin\cont% full-width container
\NewCoffin\para% multiline paragraph
\NewCoffin\bol % beginning of line 
\NewCoffin\eol % end of line

\SetVerticalCoffin\cont{\linewidth}{~}

\SetHorizontalCoffin\bol{In-coffin beginning of line.}

\SetVerticalCoffin\para{15 em}{Dummy text but long enough to span several lines at the specified width\dotfill}

\JoinCoffins \bol[B,r] \para[T,l](.5ex, 0pt)

\JoinCoffins \cont[B,l] \bol

\SetVerticalCoffin \eol {\CoffinWidth\cont - \CoffinWidth\bol}{\dotfill\rule{1ex}{1ex}}

\JoinCoffins \cont[\para-B,\para-r] \eol

A long chunk of text to show how the thing flows with surrounding lines. 
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.

\TypesetCoffin\cont

A long chunk of text to show how the thing flows with surrounding lines. 
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.


\end{document}

答案1

以下是对您的 MWE 进行的两项小调整,可产生所需的结果。

第一个调整是\eol在将棺材连接到棺材上时将其稍微向左移动\cont.22em是用于包含单个点的框的空间的一半\dotfill。根据需要调整它。虽然现在间隙不太明显,但您可能需要稍微大一点的调整才能完美匹配。

\JoinCoffins \cont[\para-B,\para-r] \eol (-.22em,0pt)

第二个调整涉及\strut在最后一行添加\para。我不知道为什么这是必要的,因为我不知道为什么使用棺材(底层expl3函数或xcoffins)会在这里失去垂直间距。

\SetVerticalCoffin\para{15 em}{Dummy text but long enough to span several lines at the specified width \strut\dotfill}

结果如下:

修改后的代码的输出

完整代码:

\documentclass{article}
\setlength{\parindent}{0pt}

\usepackage{xcoffins}

\begin{document}

\NewCoffin\cont% full-width container
\NewCoffin\para% multiline paragraph
\NewCoffin\bol % beginning of line
\NewCoffin\eol % end of line

\SetVerticalCoffin\cont{\linewidth}{~}

\SetHorizontalCoffin\bol{In-coffin beginning of line.}

\SetVerticalCoffin\para{15 em}{Dummy text but long enough to span several lines at the specified width \strut\dotfill}

\JoinCoffins \bol[B,r] \para[T,l](.5ex, 0pt)

\JoinCoffins \cont[B,l] \bol

\SetVerticalCoffin \eol {\CoffinWidth\cont - \CoffinWidth\bol}{\dotfill\rule{1ex}{1ex}}

\JoinCoffins \cont[\para-B,\para-r] \eol (-.22em,0pt)

A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.

\TypesetCoffin\cont

A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.


\end{document}

答案2

不用棺材你也可以做到:

\documentclass{article}

\newenvironment{almostcenter}
 {\par\nobreak
  \leftskip=\dimexpr(\textwidth-15em)/2\relax
  \rightskip=\leftskip
  \parfillskip=-\rightskip
  \noindent\ignorespaces}
 {\unskip\dotfill\par\noindent\ignorespacesafterend}


\begin{document}

A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
\begin{almostcenter}
Dummy text but long enough to span several lines at the specified width
\end{almostcenter}
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.
A long chunk of text to show how the thing flows with surrounding lines.

\end{document}

在此处输入图片描述

相关内容