Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to have the entire last line in a box, but when I compile, it only boxes the first equation and doesn't even print the second equation. Does anyone know how to fix this?

Here's my MWE.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document}

\begin{alignat*}{3}
    \left| x \right. & \left. - 2 \right| & &=1 &\\
    x - 2 &= 1& &\text{ or } & x - 2 &= -1\\
    \Aboxed{x &= 3& &\text{ or }& x &= 1}
\end{alignat*}

\end{document}

I was going to include an image of what it produces, but it won't let me since I'm a new user. :)

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

It possible to create a box of the correct width to span across the entries in the last row manually:

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
\begin{document}

\begin{alignat*}{3}
  \left| x \right. & \left. - 2 \right| & &=1 &\\
  x - 2 &= 1& &\text{ or } & x - 2 &= -1\\
  \rlap{\kern\dimexpr-\fboxsep-\fboxrule\relax\fbox{\phantom{$x=3\text{ or\ \ }x - 2 = 1$}}}% Phantom box
  x &= 3& &\text{ or }& x &= 1
\end{alignat*}

\end{document}​

The approach here is to create a box with fake (or \phantom) content that matches the output generated via alignat*. Minor \kerning allows for appropriate placement due to \fbox separation (\fboxsep) and rule width (\fboxrule).

share|improve this answer
1  
Werner, thank you. I'd prefer something less "manual-formatty", but this works! –  Keila Sep 10 '12 at 22:24
    
@Keila: Less manual could require an overlay using something like tikz. –  Werner Sep 10 '12 at 22:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.