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:

f(x) &=\sqrt{a^2+x^2}+\\
  • 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

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

enter image description here




  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}
    \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}}


\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.