4

The question is in the title: How do I put a box around a part of a formula?

Consider the case in which I want to put a box around the second line of the following equation:

\begin{equation}
\begin{split}
f(x) &=\sqrt{a^2+x^2}+\\
&+\sqrt{b^2+x^2}
\end{split}
\end{equation}
2
  • try \Aboxed{...} provided by the mathools package. Jan 24, 2019 at 15:43
  • If the equation part does not include the & then try boxed{...} provided by amsmath Jan 24, 2019 at 15:47

1 Answer 1

4

Here are some options, using \fbox, \boxed and \Aboxed, depending on what you have access to:

enter image description here

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{align*}
  f(x) &= \sqrt{a^2 + x^2}  \\
       & + \sqrt{b^2 + x^2} \\[2\jot]
  f(x) &= \sqrt{a^2 + x^2}  \\
       & \fbox{${}+ \sqrt{b^2 + x^2}$} \\[2\jot]
  f(x) &= \sqrt{a^2 + x^2}
    \hspace{\dimexpr\fboxsep+\fboxrule}
    \makebox[0pt][r]{\fbox{\phantom{$f(x) = \sqrt{a^2 + x^2}$}}} \\
       & + \sqrt{b^2 + x^2} \\
  \Aboxed{f(x) &= \sqrt{a^2 + x^2}} \\
  f(x) &= \sqrt{a^2 + x^2} \\
       & \boxed{{}+ \sqrt{a^2 + x^2}}
\end{align*}

\end{document}

\Aboxed is able to manage spanning an alignment &. However, you can overprint an \fbox (or \boxed) to achieve the same effect.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .