![列表中的 \hfill 无法正常工作。发生了什么?](https://linux22.com/image/479339/%E5%88%97%E8%A1%A8%E4%B8%AD%E7%9A%84%20%5Chfill%20%E6%97%A0%E6%B3%95%E6%AD%A3%E5%B8%B8%E5%B7%A5%E4%BD%9C%E3%80%82%E5%8F%91%E7%94%9F%E4%BA%86%E4%BB%80%E4%B9%88%EF%BC%9F.png)
\documentclass[a4paper,12pt]{article}
\begin{document}
\begin{enumerate}
\item \begin{enumerate}
\item
\begin{enumerate}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt \hfill [Lorem ipsum]
\item I'm going to relate a time-traveling joke, but you didn't appreciate it. \hfill [Lorem ipsum]
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{document}
输出结果如下:
为什么第二个 [Lorem ipsum] 被拆分了,尽管该项目的措辞较少?
答案1
如果您先移除放错位置的\item
,它就会按我预期的方式工作。
\documentclass[a4paper,12pt]{article}
\begin{document}
\begin{enumerate}
\item
\begin{enumerate}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt \hfill [Lorem ipsum]
\item I'm going to relate a time-traveling joke, but you didn't appreciate it. \hfill [Lorem ipsum]
\end{enumerate}
\end{enumerate}
\end{document}
编辑如果要进行更高级别的嵌套,我引用 egreg 的评论:
[...] TeX 更倾向于段落倒数第二行没有连字符。 \hfill 使之成为可能。
\documentclass[a4paper,12pt]{article}
\begin{document}
\begin{enumerate}
\item
\begin{enumerate}
\item
\begin{enumerate}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt \hfill [Lorem ipsum]
\item I'm going to relate a time-traveling joke, but you didn't appreciate it. \hfill [Lorem~ipsum]
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{document}
或者看看\linepenalty
。
答案2
来自@Ulrike Fischer 的解释—— https://tex.stackexchange.com/a/16333/197451
输出和 \newcommand\quelle
此外,由于环境没有,第一个\item
应该给你一个错误- 可能你在捕获输出的屏幕截图之前已经编辑掉了第一个- 对吗?enumerate
\begin
item
\documentclass[a4paper,12pt]{article}
\begin{document}
\newcommand\quelle[1]{{%
\unskip\nobreak\hfil\penalty50
\hskip2em\hbox{}\nobreak\hfil\textbf{#1}%
\parfillskip=0pt \finalhyphendemerits=0 \par}}
\begin{enumerate}
\item fg \hfill [lorem ipsum]
\begin{enumerate}
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed
\quelle {[Lorem ipsum]}
\item I'm going to relate a time-traveling joke, but you didn't
appreciate
it. \hfill [Lorem ipsum]
\end{enumerate}
\end{enumerate}
\end{document}