I'm experiencing difficulties trying to use the "Units in Labels" feature of pgfplots (pages 525-528 of the v1.17 manual). It works well in most circumstances except when the prefix is the greek letter "mu" and the "unicode-math" package is used. In this case, no prefix is displayed. I've tested it with various Math typefaces (Libertinus Math, TeX Gyre xx Math, STIX Math, etc.), with identical results.
Here is a MWE with 3 cases (considering only the X axis):
- The first one shows the error: Although the "micro" SI prefix is specified, no "μ" character is shown using LuaLaTeX (using XeLaTeX a "tofu" character is displayed).
- The second plot shows the correct behaviour when a prefix other than "micro" is used.
- The third one shows that it's still possible to use the "x unit prefix" option to manually insert the desired prefix, but this is not an ideal solution.
% !TeX TS-program = lualatex
\documentclass[tikz,border=5pt,convert={density=150x150}]{standalone}
\usepackage{fontspec}
\usepackage{unicode-math}
\setmainfont{Libertinus Serif}
\setmathfont{Libertinus Math}
\usepackage{siunitx}
\usepackage{pgfplots}
\usepgfplotslibrary{units}
\begin{document}
% Example 1: Greek letter mu doesn't get displayed as a prefix
\begin{tikzpicture}
\begin{axis}[
width=.5\textwidth,
xlabel=$t$, x unit=s, change x base, x SI prefix=micro,
ylabel=$v_g$, y unit=V,
]
\addplot coordinates {(0,0) (100e-6,1) (200e-6,0.5) (300e-6,0.5)};
\end{axis}
\end{tikzpicture}
% Example 2: No problem with "millis" or other non-greek prefix
\begin{tikzpicture}
\begin{axis}[
width=.5\textwidth,
xlabel=$t$, x unit=s, change x base, x SI prefix=milli,
ylabel=$v_g$, y unit=V,
]
\addplot coordinates {(0,0) (100e-6,1) (200e-6,0.5) (300e-6,0.5)};
\end{axis}
\end{tikzpicture}
% Example 3: manually set prefix
\begin{tikzpicture}
\begin{axis}[
width=.5\textwidth,
xlabel=$t$, x unit=s, change x base, x SI prefix=micro,
x unit prefix=μ, % $\mu$ doesn't work
ylabel=$v_g$, y unit=V,
]
\addplot coordinates {(0,0) (100e-6,1) (200e-6,0.5) (300e-6,0.5)};
\end{axis}
\end{tikzpicture}
\end{document}
Finally, if I comment out the "\usepackage{unicode-math}" and the corresponding "\setmathfont" everything works as expected (although the math font is Computer Modern, of course):
The question is: It's a bug or am I doing something wrong?
\usepackage[mathrm=sym]{unicode-math}
. From tex.stackexchange.com/a/570634/161015unit code/.code 2 args={\symrm{#1#2}},