# How do I align boxed math equations?

The code

 $\boxed{\begin{split} 3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill} \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4 \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill} \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4 \end{split}}$


works.

But the code

 $\begin{split} \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill}} \\ &\text{or} \\ \boxed{3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4} \\ &\text{or} \\ \boxed{3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill}} \\ &\text{or} \\ \boxed{3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4} \end{split}}$


doesn't.

How can I make it work?

• I think you have your examples backwards: the first one that you say works, generates an error. It would be easier to test if you provided complete examples not just fragments. – David Carlisle Oct 17 '16 at 23:54
• Perhaps you're interested in this answer? – Emma Oct 18 '16 at 0:33

Here are some options:

\documentclass{article}

\usepackage{amsmath,eqparbox}

\begin{document}

\boxed{ \begin{aligned} 3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + \text{skill} \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + \text{skill} & \ge 10 + \text{ability} + 4 \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + \text{skill} \\ &\text{or} \\ 3\mathrm{d}6 + \text{ability} + 4 & \ge 10 + \text{ability} + 4 \end{aligned} }

\begin{gather*}
\boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + \text{skill}$}
\eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + \text{skill}$}} \\
\text{or} \\
\boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + \text{skill}$}
\eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + 4$}} \\
\text{or} \\
\boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + 4$}
\eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + \text{skill}$}} \\
\text{or} \\
\boxed{\eqmakebox[LHS][r]{$3\mathrm{d}6 + \text{ability} + 4$}
\eqmakebox[RHS][l]{${}\geq 10 + \text{ability} + 4$}}
\end{gather*}

\newlength{\LHSlong}\newlength{\LHSshort}%
\newlength{\RHSlong}\newlength{\RHSshort}%
\newcommand{\LHSfill}{\hspace*{\dimexpr\LHSlong-\LHSshort}}%
\newcommand{\RHSfill}{\hspace*{\dimexpr\RHSlong-\RHSshort}}%
\settowidth{\LHSlong}{$3\mathrm{d}6 + \text{ability} + \text{skill}$}%
\settowidth{\RHSlong}{${}\geq 10 + \text{ability} + \text{skill}$}%
\settowidth{\LHSshort}{$3\mathrm{d}6 + \text{ability} + 4$}%
\settowidth{\RHSshort}{${}\geq 10 + \text{ability} + 4$}%
\begin{gather*}
\boxed{3\mathrm{d}6 + \text{ability} + \text{skill} \geq 10 + \text{ability} + \text{skill}} \\
\text{or} \\
\boxed{3\mathrm{d}6 + \text{ability} + \text{skill} \geq 10 + \text{ability} + 4} \RHSfill \\
\text{or} \\
\LHSfill\boxed{3\mathrm{d}6 + \text{ability} + 4 \geq 10 + \text{ability} + \text{skill}} \\
\text{or} \\
\LHSfill\boxed{3\mathrm{d}6 + \text{ability} + 4 \geq 10 + \text{ability} + 4}\RHSfill
\end{gather*}

\end{document}


The last option relies on the fact that your constructions seems deterministic with two fixed Left/Right Hand Sides. As such, we're able to measure their widths and use it to correct for the too-short equation sides.