我想以描述场景的格式呈现一些信息,然后点填充到右对齐的结果。如果场景+结果会填满这一行,我希望它换到下一行,并用右对齐的结果点填充整行。
我可以用 来实现这一点\makebox
,但这会在框和点填充之间引入不必要的间距,因此它不是连续的点。
梅威瑟:
\documentclass{scrreprt}
\begin{document}
\begin{description}
\item This is some text \dotfill Result
\item This is some text which almost fills a line so dotfill does not produce an output \dotfill Result
\item This is some text which does fill the line and a break occurs but dotfill doesn't dot \dotfill Result
\item I would prefer that if the text fills the line, dotfill fills the next line before the result \makebox[3cm]{\dotfill}\dotfill Result
\end{description}
\end{document}
我尝试了\unskip
和的各种组合\ignorespaces
,但它们都没有给出所需的结果。我可以使用\kern-3pt
空格,但感觉有点不方便。我更希望将解决方案推广到我可以代替 dotfill 使用的命令:
\NewDocumentCommand\myDotfill{}{\makebox[3cm]{\dotfill}\MAGICSPACEKILLER\dotfill}
有人能建议我应该输入什么命令来尝试消除不需要的水平空间吗?
答案1
一种使用最小尺寸 3cm 而不是 0pt 的点填充版本,并避免在换行符处被丢弃
\documentclass{scrreprt}
%\ShowCommand\dotfill
\NewDocumentCommand\mdotfill{}{%
\mbox{}\nobreak\cleaders \hbox to .44em{\hss .\hss }%
%\hfill
\hskip 3cm plus 1filll
\kern 0pt\relax}
\begin{document}
\begin{description}
\item This is some text \dotfill Result
\item This is some text which almost fills a line so dotfill does not produce an output \mdotfill Result
\item This is some text which does fill the line and a break occurs but dotfill doesn't dot \mdotfill Result
\item I would prefer that if the text fills the line, dotfill fills the next line before the result \mdotfill Result
\end{description}
\end{document}
答案2
如果您希望在末尾添加全宽行,请插入\parnopar
前\dotfill
。
\documentclass{scrreprt}
\newcommand{\parnopar}{\parfillskip=0pt\par\parskip=0pt\noindent}
\begin{document}
\begin{description}
\item This is some text \dotfill Result
\item This is some text which almost fills a line so dotfill does not produce an output \dotfill Result
\item This is some text which does fill the line and a break occurs but dotfill doesn't dot \par \dotfill Result
\item I would prefer that if the text fills the line, dotfill fills the next line before the result \parnopar \dotfill Result
\end{description}
\end{document}