是否可以在段落的特定位置强制换行,但前提是这不会增加总行数?
我尝试使用\penalty
不同的值,发现即使换行符的总数相同,-10000 也总是强制换行,而 -9999 不会启用换行符。
这是一个可能的测试文档:
\documentclass{article}
\newcommand\X[1]{
\penalty-9999 % please break here if you need to break somewhere
\textbf{(#1)}
}
\begin{document}
\begin{minipage}{5cm}
Which number?
\X{A} 5
\X{B} 7
\X{C} 4
\X{D} 3
\end{minipage}
\end{document}
答案1
\documentclass{article}
\newcommand\X[1]{% keep egreg happy
\unskip % remove any space before this command, so we add our own
\hskip 0pt plus .2\hsize % end line up to 20% short
\penalty-50 % please break here if you need to break somewhere
\hskip 0pt plus -.2\hsize\relax % cancel skip if don't break
\space % and do normal space
\textbf{(#1)}% as above
}
\begin{document}
\begin{minipage}{5cm}
Which number?
\X{A} 5
\X{B} 7
\X{C} 4
\X{D} 3
\end{minipage}
\end{document}