2

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.

enter image description here

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

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}
2
  • Any reason why you didn't just use the \OldSIUnitSymbolDegree? 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

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.