josephwright/siunitx

inline-per-mode = symbol not working in combination with matplotlib \mathdefault

Closed this issue · 3 comments

The option inline-per-mode = symbol is not working, if it is used in combination with the matplotlib workaround or official guideline to define \mathdefault.

As discussed in this issue matplotlib issue #27907, it is necessary to define the command \mathdefault and it is recommended to do this via \def\mathdefault#1{#1}\everymath=\expandafter{\the\everymath\displaystyle}. But this does unfortunately break the function of the inline-per-mode = symbol option. I am not sure where the problem lies or how to avoid this.

Here is a MWE:

\documentclass{scrreport}

\def\mathdefault#1{#1}\everymath=\expandafter{\the\everymath\displaystyle}

\usepackage{siunitx}
\sisetup{
    display-per-mode = fraction ,
    inline-per-mode = symbol,     
}        

\begin{document}
\qty{15,9084}{\watt\per\square\meter} 

\(\qty{15,9084}{\watt\per\square\meter}\)   

\begin{equation}
    \qty{15,9084}{\watt\per\square\meter}
\end{equation}

\end{document}    

To be expected: you've made all maths display style so siunitx is matching.

This is the method proposed by matplotlib. Is there a way to define \mathdefault as required but not break the normal displaystyle?

Sorry, I've no idea what matplotlib is up to here, but it's definitely not an siunitx issue - you are requesting displaystyle so that's what you are getting.