I asked a similar question today except it was targeted at one particular line inside the align* environment. Now I want to enclose two lines. The failed attempt below makes my intention clear:
\begin{align*}
\ce{K_a $\times$ K_b} &= \ce{K_w}\\
-\log(\ce{K_a $\times$ K_b}) &= -\log\ce{K_w}\\
-( \log(\ce{K_a}) + \log(\ce{K_b}) ) &= -\log\ce{K_w} & \text{(Using log law for LHS.)} \\
- \log(\ce{K_a}) - \log(\ce{K_b}) &= -\log\ce{K_w}\\
\fbox{
\begin{minipage}{\textwidth}
\ce{pK_a} + \ce{pK_b} &= \ce{pK_w}\\
&=14.00 \text{ (at \SI{25}{\celsius})}\\
\end{minpage}
}
\end{align*}
\Aboxed from mathtools pkg was a great solution, you didn't have to specify mandatory parameters and it was as simple as Aboxed{ } - alas it only works for single line boxes.
As for \Aboxed I don't want to be asked how wide the box should be - it should be automatically determined.
As usual, I prefer predefined solutions, and less obstrusive code to achieve the desired effect. The less clutter the better.
P.S. By the way, this manual seems to suggest \mbox, and anologously \fbox ought to draw frames around the enclosed content. Previously I could not get \mbox to display visible frames...







\mboxwas never designed to draw frames. – egreg Oct 02 '11 at 14:27minipage- does anyone know why it's still not working? I'd like to try and get it to work the way above since the solutions below are far too advanced for me for the time being... – ptrcao Oct 02 '11 at 17:17alignenvironment and the internal plumbings of(La)TeX. That's a bit of black magic for me too. :) – Count Zero Oct 02 '11 at 20:26alignenvironment into two parts, one that is going to be framed and the other that is not. Then you can put the 'framable' content into a\parboxand frame the\parbox. But here again, you must specify manually the width of the box. NOTE: I deliberately didn't post this as an answer, because it's just too ugly... – Count Zero Oct 02 '11 at 21:03empheq. Reading the documentation, it is clear to me that it is way more difficult to achieve what you want with that one than with the answers already given. Trust me, I've been in a similar bind when I had to typeset some ugly colored frame around section titles (I had to follow a strict template). Thetitlesecpackage did the trick, but I spent a week until I figured it out. I guess I'm still pretty far from being a (La)TeX wizzard... – Count Zero Oct 03 '11 at 19:58