12

When I use mathpazo and siunitx (version 2.3h) together, if I use \pi inside the numerical argument to \SI, it will show up in the output as "ß".

\documentclass{article}
\usepackage{mathpazo, siunitx}
\begin{document}
    $\pi + \SI{\pi}{\ohm}$
\end{document}

Produces:

wrong output

But when I don't use mathpazo:

correct output

Why does this happen and how can I fix it?

10

As others have observed, the issue here is the way the mathpazo treats \pi. I would go with

\documentclass{article}
\usepackage{mathpazo, siunitx}
\protected\def\numpi{\text{\ensuremath{\pi}}}
\sisetup{input-symbols = \numpi}
\begin{document}
    $\pi + \SI{\numpi}{\ohm}$
\end{document}

The idea here is that this approach forces the use of the 'standard' font for \pi in all cases (it's safe in both math and text mode). There are reasons that siunitx uses \mathrm rather than \mathnormal as the standard math mode font: try

\documentclass{article}
\begin{document}
    $\mathnormal{123}$
\end{document}

to see why!

  • 3
    Thank you! That all makes sense, except for why mathpazo treats \pi weirdly inside mathrm in the first place in the first place... – jtbandes Oct 30 '11 at 22:12
8

The following rectifies your problem:

  • \pi without siunitx or mathpazo is defined as \mathchar"119;
  • \pi under only siunitx remains the same (\mathchar"119);
  • \pi under only mathpazo is defined as \mathchar"7119.

Since siunitx does not touch the definition of \pi and the load order does not correct for this, redefining \pi works:

enter image description here

\documentclass{article}
\usepackage{siunitx,mathpazo}
\begin{document}
  $\pi + \SI{\pi}{\ohm}$ \par
  \renewcommand{\pi}{\mathchar"119}% Revert to original mathchar definition for \pi
  $\pi + \SI{\pi}{\ohm}$ \par
\end{document}
  • Why does the output differ between math mode and inside the \SI command, with both siunitx and mathpazo? – jtbandes Oct 30 '11 at 18:50
  • @jtbandes: I am not sure. Perhaps @JosephWright (siunitx maintainer) has some insight on this. This has been raised on chat. – Werner Oct 30 '11 at 20:30
  • If used regularly inside \frac{}{} (not as part of \SI), \pi does not appear, nor does the subsequent character. I don't know why this happens, but it can be fixed (as I'm sure you would guess) by adding \relax after \mathchar"119 in the definition. – erik Dec 6 '16 at 22:21
8

The problem is that mathpazo defines \pi as \mathalpha, that is it adds "7000 to its code and that siunitx uses by default \mathrm in the arguments of \SI:

\sisetup{number-math-rm=\mathnormal}

would be wrong; use

\SI[number-math-rm=\mathnormal]{\pi}{\ohm}
0

Sorry for my previous wrong answer. Here is a tested code. It looks more concise.

\documentclass{article}
\usepackage{mathpazo, siunitx}
\begin{document}
    $\pi + \SI[mode=text]{\pi}{\ohm}$

    $\pi + \SI{\pi}{\ohm}$

    $\pi + \SI[mode=math]{\pi}{\ohm}$
\end{document}

enter image description here

Note: The code will not work if you replace the '\pi' inside the numerical argument by other non-numeric symbols like 'p'.

  • 2
    The link doesn't work for me. Besides \mathit{\pi} seems unlikely to work in \SI (unless one turns number parsing off). – Phelype Oleinik May 3 at 15:21

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.