# Hay how do you do a box around an equation in $\LaTeX$?

I just don't know how to do it.

I have seen it in other posts, but I can't find them.

• Poking you to accept one of the answers ;)
– jojeck Mod
Commented Aug 9, 2023 at 8:37
• I hate having to choose between friends. Commented Aug 9, 2023 at 13:57
• Thank you for choosing, next time you need to choose Matt over Peter :)
– jojeck Mod
Commented Aug 18, 2023 at 22:22
• @jojeck , I need you to answer some questions about Royi and Overlord in the other thread. Commented Aug 18, 2023 at 23:18
• See the Math.SE MathJax FAQ, community answer, for the full syntax for an outlined colored box.
– Rob
Commented Nov 25, 2023 at 16:09

$$\fbox{ Like this for text.}$$

\fbox{ Like this for text.}

or

$$\boxed{e^{j\pi} = -1}$$

\boxed{e^{j\pi} = -1}

This sort-of works for colors:

$$\color{red}{\boxed{\color{black}{e^{j\pi} = -1}}}$$

\color{red}{\boxed{\color{black}{e^{j\pi} = -1}}}

for an equation.

• Thanks, Peter. Is there a way to specify the color of the box? Commented Jul 22, 2023 at 15:17
• @robertbristow-johnson That's an attempt...
– Peter K. Mod
Commented Jul 28, 2023 at 0:23
• Thanks. I didn't know about either the \color or \boxed instructions. Commented Jul 28, 2023 at 2:24

In Mathjax you can do something like this (which I used in this post):

\bbox[#f8f1ea, 0.6em, border: 0.15em solid #fd8105]{a^2+b^2=c^2}


Looks like this:

$$\bbox[#f8f1ea, 0.6em, border: 0.15em solid #fd8105]{a^2+b^2=c^2}$$

You can find the documentation here.

• thanks Matt. do you know where I can find this documented? I presume the first word somehow specifies the the color but what does the second word (0.6em) specify? Commented Aug 3, 2023 at 12:39
• @robertbristow-johnson: I added the doc-link at the end of my answer. Commented Aug 3, 2023 at 12:43