Wednesday, January 13, 2010

Changing the Size of Delimiters in Multline Environment

This is my first real problem with LaTeX. For long equations the multline enviroment works well to break them over two or more lines.

Lets say I want y=2+\frac{1}{1+\frac{1}{x}} displayed over two lines like

y=2
+1/(1+1/x)

then i would use (this example is too short an equation so LaTeX will spread it out too far, but the concept still applies)
\begin{multline}
2 \\ +\frac{1}{1+\frac{1}{x}}
\end{multline}

But lets say I want y=(2+\frac{1}{1+\frac{1}{x}})^{1/2} displayed over two lines like
y=(2
+1/(1+1/x))^{1/2}

I can use the \left( 'my equation' \right. and \left. 'my equation' \right) to close parentheses and manually break the equation like

\begin{multline}
\left( 2 \right.
\\
+\frac{1}{1+\frac{1}{2}} \left. \right)^{1/2}
\end{multline}

But if the height of the equation is the same for each line then this command will not match the size of the parenthesis.

to fix this problem use the \vphantom{} command. This command calculates the correct size for anything in the braces and hides the output - therefore the dual layer fraction will be used to match the size of the parentheses without displaying the extra terms. The easiest way is to just copy the offending terms into the braces and be done with it like

\begin{multline}
\left( \vphantom{+\frac{1}{1+\frac{1}{2}}}
2 \right.
\\
\left. +\frac{1}{1+\frac{1}{2}} \right)^{1/2}
\end{multline}

its sloppy and brutish to do it this way, but it works. A big WTF goes out to the multline command for not taking care of this automatically!

All the credit for this info has to be given to dnemoc who posted a shorter response to this question here. Thanks, that problem was really pissing me off!

1 comment:

Anonymous said...
This comment has been removed by a blog administrator.