# Which display-style math environments allow both new lines and respond to additions of infinite horizontal space?

Consider the following example:

\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}


I would like a display-style math environment that allows new lines (like align) and responds to the addition of infinite horizontal space (like displaymath).

Does such an environment exist?

-
\hspace{<length>} seems to work. You have 0pt length so the space is there but just of zero length. Also, you can use \usepackage{showframe} to see the page margins. –  Peter Grill Nov 2 '12 at 18:37
Thanks for checking. I added the word "infinite" to my question. –  Tyson Williams Nov 2 '12 at 18:41
Try putting \hbox to \textwidth{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \hss xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\hbox to \textwidth{cccccccccccccccccccccccccccccccccccccc \hss yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy} in the align* environment. –  Thruston Nov 2 '12 at 18:51
@Thruston That seems to work. Can you make this an answer and explain what the code is doing? –  Tyson Williams Nov 2 '12 at 19:07
@Thruston YES :) I was able to adapt your suggestion to my actual problem. Again, please make this into a answer so I can accept it. –  Tyson Williams Nov 2 '12 at 19:32

Try putting

\hbox to \textwidth{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\hss xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}\\
\hbox to \textwidth{cccccccccccccccccccccccccccccccccccccc
\hss yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy}


in the align* environment.

Some explanations:

1. This is not a "purist" solution because I'm mixing plain TeX with LaTeX but there you go; it works...

2. \hbox{} is the plain TeX command to make an unbreakable horizontal box. It puts everything between the {} into a nice locked up box of text like a very big single character. The width of the box is normally the natural width of the contents, but...

3. \hbox to <dimen> creates a box that is squashed or stretched so that the width is set to <dimen>. The <dimen> is any normal TeX length like 2in or 36pt or in this case \textwidth which (thanks to LaTeX) expands to the current width of the text on the page.

4. To make this stretchy-squashy feature work you have to include some TeX "glue" in the horizontal material that you put in the box. In this case I included \hss which is another bit of plain TeX that expands to "as much positive or negative glue as you need". The name is from "horizontal stretch or shrink".

So what each of these commands does is to create a box that exactly fits in the text width you have currently set with the first word flush left and the other flush right and lots of space in the middle. Which is I think exactly what you wanted.

Note that the "or shrink" bit means that if the two words are sufficiently long they will still be exactly flush left and right, but they will over lap in the middle.

-