# Tight box around siunitx degree

I want the box around the degree symbol to be like the one around the exponent on the x. I thought \mbox{} would do it, but it does not seem to in this case.

## Code:

\documentclass{article}
\usepackage{siunitx}

\let\OldSIUnitSymbolDegree\SIUnitSymbolDegree
\renewcommand{\SIUnitSymbolDegree}{\fboxsep=0pt\fbox{\mbox{\ensuremath{\OldSIUnitSymbolDegree}}}}

\begin{document}

\ang{60} \SI{60}{\degree}

$x^{\fboxsep=0pt\fbox{$\scriptstyle 2$}}$ % <-- want a tight box like this
\end{document}


You'll need to put the box inside the superscript and allow for the kerns, something like

\documentclass{article}
\usepackage{siunitx}

\renewcommand\SIUnitSymbolDegree
{\ensuremath{^{\fboxsep=0pt\fbox{\ensuremath{\kern-\scriptspace\scriptstyle\circ\kern-2\scriptspace}}}}}

\begin{document}

\ang{60} \SI{60}{\degree}

\end{document}

• Any reason why you didn't just use the \OldSIUnitSymbolDegree? – Peter Grill Feb 16 '16 at 11:45
• @PeterGrill Yes: if you trace that definition through it has the superscript inside it, coming out to {}^{\circ} if you've not altered it. That won't work for what you want. – Joseph Wright Feb 16 '16 at 11:53