4

I have noticed that I get errors when trying to box an entire equation in the align environment. I get similar errors if I try to put the entire equation inside big parenthesis using \left( and \right).

I know that the error is stemming from the fact that the alignment marker & is inside these equations (I am using the align environment after all). A possible workaround for the parenthesis case would be to use \Big( and \Big). I'm afraid that doesn't help if I want to box the entire equation.

Another alternative is to stick a separate environment like \begin{equation}\end{equation} where I need the boxed equation but if it is in the middle of an align environment then I have just split my align environment with no way to maintain the alignment marker position.

Does anyone have any experience with this error they'd like to share? Any other workarounds for the case of boxing an entire equation with an alignment marker?

Related to the MWE below, I am trying to box the entire definition of f_{ij} including the left hand side and equal sign. Error occurs because of the & at the first equal sign.

MWE

\documentclass[11pt,letterpaper]{article}
\usepackage{amsmath}

\begin{document}
\begin{align*}
a &= b + c\\
d_{ij} &= e + f_{ij}\\
\boxed{f_{ij} &= \begin{cases} % I want to box this entire equation
1 & \text{if} \quad i = j\\
0 & \text{if} \quad i \neq j\\
\end{cases}}\\
d_{ii} &= e + f_{ii} = e + 1
\end{align*}
\end{document}
JStrahl
  • 129
Nukesub
  • 607
  • Please make your code into a (non-)compilable document so we can all share your error. It is hard to help without code to reproduce the problem – cfr Sep 12 '17 at 02:52
  • What do you mean by 'boxed'? You seem to want to surround it with delimiters, but the code suggest you want to use cases. – cfr Sep 12 '17 at 02:55
  • Sorry for not being clearer. I mean I want to be able to add a \boxed{} around the entire equation. – Nukesub Sep 12 '17 at 02:58
  • Small update. I thought I had found a solution when I discovered \Aboxed{} from the mathtools package but that does not appear to work either. – Nukesub Sep 12 '17 at 03:08
  • Oh. Sorry. I only figured out how to be large brackets around it \left( ... \right) (with or without cases). But I guess that's not what you meant. – cfr Sep 12 '17 at 03:09
  • It seems to work equally well with boxed. I think I don't understand the question still. What are you trying to put the boxed around? I would assume the entire cases environment, but that's not a problem, so you must mean something else. – cfr Sep 12 '17 at 03:12
  • Never mind. I reloaded the page and now I have your updated question, so it is clear now. – cfr Sep 12 '17 at 03:13
  • I guess the code below isn't what you want, but I'm not sure why. (I'll delete it in a little bit, when you've had a chance to look - it isn't easy to illustrate in a comment.) – cfr Sep 12 '17 at 03:22
  • I think we posted our solutions at about the exact same time. I didn't have a chance to look at it very long before you deleted it but I appreciate your time anyways. Thank you! – Nukesub Sep 12 '17 at 03:26
  • Just after I wrote the comment above, I saw you'd posted a solution which seems much more correct, so I deleted mine as I thought it would just confuse things. (I just used an explicit space in place of the & inside the cases environment e.g. 0 \quad ... \\ 1 \quad ..., but your strategy lets you keep the alignment inside as you'd normally have it.) – cfr Sep 12 '17 at 03:28

1 Answers1

4

I believe I have determined a workaround.

You can use \Aboxed{} from the mathtools package to wrap an entire equation in an align environment. You can use \Aboxed{} with \begin{cases} as well but you have to surround the \begin{cases}\end{cases} with a pair of {} as shown below. Source (How can I \Aboxed a Matrix?)

\documentclass[11pt,letterpaper]{article}
\usepackage{amsmath}
\usepackage{mathtools}

\begin{document} \begin{align} a &= b + c\ d_{ij} &= e + f_{ij}\ \Aboxed{ f_{ij} &= {\begin{cases} % I want to box this entire equation 1 & \text{if} \quad i = j\ 0 & \text{if} \quad i \neq j\ \end{cases}} }\ d_{ii} &= e + f_{ii} = e + 1 \end{align} \end{document}

enter image description here

John D
  • 213
Nukesub
  • 607