[Tex/LaTex] Boxed and align

alignboxesmathjax

Remark: The examples in this post are not the real cases, the real one is a web page using MathJax. It seems MathJax has some restrictions about the packages that can be used. In particular, mathtools seems to not be supported.

The following document fails with errors "Missing }"

\documentclass{article}
\usepackage[x11names, rgb]{xcolor}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{document}

\begin{align}
  \boxed{ 2x+y & = 11 } \\
  3x & = 19 - 2y
\end{align}

\end{document}

The problem seems to be the usage of \boxed (if it is removed, the error disappears) inside an align block.

Any solution of this issue or other way to enclose an equation or some terms of an equation when using align blocks?

Note the following doesn't causes any error:

\begin{align}
 \boxed{ 2x+y } & = 11 \\
  3x & = 19 - 2y
\end{align}

Best Answer

Here's a workaround that works with MathJax, but it's not pretty and might need additional tweaking depending on the MathJax implementation you're working with:

$$ 
\begin{align*}
2x+y &= 11 \\ 
3x &= 19 - 2y 
\; \llap{\mathrel{\boxed{\phantom{3x = 19 - 2y}}}}
\end{align*} 
$$

Here's what this would look like on math.stackexchange.com:

enter image description here

Edit: I boxed the wrong line by mistake, but one can accomplish the same thing for any line within an align block.

Related Question