我正在尝试想出自己的命令来用点填充水平空间的剩余部分,但我希望这些点相对于文本略微降低。这是我的代码:
\newcommand\ansfill{\raisebox{-.2\baselineskip}{\makebox[\linewidth]{\dotfill}}}
当我的线路上没有任何内容时,这很好用
\ansline
但是当我添加任何东西时都会出现 \hbox 溢出错误,因为来自 \makebox 的框始终是 \linewidth。
例如
Example Text \ansfill
给出了一个 overfull hbox 错误。
我需要一个根据水平空间剩余部分而变化的参数。例如:
\newcommand\ansfill{\raisebox{-.2\baselineskip}{\makebox[\whatever-that-is-left]{\dotfill}}}
谢谢。
答案1
您可以模拟 的定义\dotfill
。我还添加了一个可选参数来设置点的最小宽度。最后一个例子显示了如果没有 会发生什么[8em]
。
\documentclass{article}
\newcommand{\ansfill}[1][0pt]{%
\leavevmode
\leaders
\hbox to 0.44em{\hss\raisebox{-2pt}{.}\hss}%
\hskip #1 plus 1fill
\kern0pt
}
\begin{document}
Here's a question. \ansfill
Here's another longer question for which we need at least eight ems
of space for the answer. \ansfill[8em]
Here's another longer question for which we need at least eight ems
of space for the answer, even though the line would be almost filled up
with text. \ansfill[8em]
Here's another longer question for which we need at least eight ems
of space for the answer, even though the line would be almost filled up
with text. \ansfill % <--- Uh, oh!
\end{document}
答案2
\linegoal
同名包定义的维度在这里可能是正确的:
\documentclass[12pt]{article}
\usepackage{linegoal}
\newcommand\ansfill{\raisebox{-.2\baselineskip}{\makebox[\linegoal]{\dotfill}}}
\begin{document}
This is something \ansfill
\end{document}