请考虑以下示例:
\documentclass{article}
\usepackage{amsmath}
\begin{document}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
\begin{displaymath}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{displaymath}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
\begin{displaymath}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\hspace{0pt minus 1fil}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
\end{displaymath}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
\begin{align*}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\hspace{0pt minus 1fil}
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx\\
cccccccccccccccccccccccccccccccccccccc
\hspace{0pt minus 1fil}
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
\end{align*}
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
This is a really long line of text to show where the margins of the page are.
\end{document}
我想要一个显示风格的数学环境,它允许新行(如align
)并响应无限水平空间的添加(如displaymath
)。
这样的环境存在吗?
答案1
尝试放入
\hbox to \textwidth{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\hss xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\
\hbox to \textwidth{cccccccccccccccccccccccccccccccccccccc
\hss yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}
在align*
环境中。
一些解释:
这不是一个“纯粹主义”的解决方案,因为我将纯 TeX 与 LaTeX 混合在一起,但是它起作用了......
\hbox{}
是用于制作不可破坏的水平框的纯 TeX 命令。它将 {} 之间的所有内容放入一个漂亮的锁定文本框中,就像一个非常大的单个字符。框的宽度通常是内容的自然宽度,但是...\hbox to <dimen>
创建一个被挤压或拉伸的框,以便将宽度设置为<dimen>
。<dimen>
是任何正常的 TeX 长度,例如2in
或36pt
或 在这种情况下\textwidth
(感谢 LaTeX)会扩展到页面上文本的当前宽度。要使这种可拉伸可挤压的特性发挥作用,你必须在放入框中的水平材料中加入一些 TeX“胶水”。在这种情况下,我加入了
\hss
另一段普通的 TeX,它可以扩展到“尽可能多的正胶水或负胶水”。这个名字来自“水平拉伸或收缩”。
因此,每个命令的作用是创建一个与您当前设置的文本宽度完全匹配的框,第一个单词与文本左侧对齐,另一个单词与文本右侧对齐,中间留出大量空间。我认为这正是您想要的。
请注意,“或缩小”位意味着如果两个字足够长,它们仍然会左右齐平,但它们会在中间重叠。