3

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}
  • try \Aboxed{...} provided by the mathools package. – Hafid Boukhoulda Jan 24 at 15:43
  • If the equation part does not include the & then try boxed{...} provided by amsmath – Hafid Boukhoulda Jan 24 at 15:47
3

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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