答案1
段落拆分完成后,有两个溢出的框:“hello”和“world”。这些框被重新计算为示例中的宽度 .1in,并且由于 而未报告\hfuzz=2em
。它们被放置在与 相同的位置\hfuzz=0pt
。当然,溢出的框是正确重叠的。
如果你需要将段落中每个单词空间处的行折回,你可以尝试:
\hsize=0pt \noindent \parfillskip=0pt
\leftskip=0pt plus 1fil minus10em
hello world
\bye
这两种解决方案(您的和我的)的问题在于,结果的总宽度(最宽框的测量值)没有计算出来。因此,您需要将此结果右移,\moveright something\vbox{...}
并且必须通过另一种方式计算(或估算)“某个”测量值。
如果您明确需要知道结果的宽度,那么您需要创建一个宏,将文本分成单词并测量最宽的单词。
答案2
以下代码利用\centering
、\justify
和flushright
以相应的方式对齐文本。所提出的问题适合利用\begin{flushright} text \end{flushright}
\documentclass[12pt]{article}
\usepackage{ragged2e} %for use of \justify
\begin{document}
Justified text:
\justify
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used.
Flush right text:
\begin{flushright}
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used.
\end{flushright}
Centered text:
\centering
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used. Some words to be used. Some words to be used. Some words to be used. Some words to be used.
Some words to be used.
\end{document}