![棺材中的橡胶长度并与段落底部基线对齐](https://linux22.com/image/334731/%E6%A3%BA%E6%9D%90%E4%B8%AD%E7%9A%84%E6%A9%A1%E8%83%B6%E9%95%BF%E5%BA%A6%E5%B9%B6%E4%B8%8E%E6%AE%B5%E8%90%BD%E5%BA%95%E9%83%A8%E5%9F%BA%E7%BA%BF%E5%AF%B9%E9%BD%90.png)
我想要获得特定的布局,如下所示:在一行中的某个点,我想“切换到段落模式”(就像 aparbox
所做的那样),然后在其他某个点,我想恢复到正常的全宽排版。就我而言,我的想法是使用 获得类似目录的外观dotfill
,但我想这个问题也代表常规文本。
使用该xcoffins
包我得到了这个部分解决方案(下面的 MNWE),它在代码方面既不是很优雅,在结果方面也不正确:
我的问题(上图箭头所示):
- 这是正确的™方法吗?
- 我希望“点填充”一直到右边距。使用两个
\dotfill
命令似乎可行,但结果看起来不太正确(参见图片,两个点填充之间有多余的空间)。有办法解决这个问题吗? - 如何修复棺材下方错误的行间距?在“中心列”,我希望所有行均等分布。
- 有没有更优雅的方式来水平连接两个带有相邻文本的棺材? 在这里,我将其连接起来
bol
并para
留有明确的.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}