4

I would like to globally define the per-mode of siunitx for math environment and displaymath environment separately. Is this somehow possible?

Here is a MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{per-mode=symbol}

\begin{document}
This is an inline equation: $a = \SI{10}{\meter\per\second\squared}$, to show inline behaviour.

And this is the same equation in displaymath environment:
\begin{equation*}
a = \SI{10}{\meter\per\second\squared}
\end{equation*}

\end{document}

This produces: enter image description here

What I would love to do is something like this:

\documentclass{article}

\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{per-mode-math=symbol,
         per-mode-displaymath=fraction}

\begin{document}
This is an inline equation: $a = \SI{10}{\meter\per\second\squared}$, to show inline behaviour.

And this is the same equation in displaymath environment:
\begin{equation*}
a = \SI{10}{\meter\per\second\squared}
\end{equation*}

\end{document}

Which then should produce the following output: enter image description here

  • 2
    Did you see per-mode = symbol-or-fraction in the manual? – Joseph Wright Jul 9 '15 at 13:52
  • @JosephWright: That is exactly what I wanted. Thank you! – Wamseln Jul 9 '15 at 13:56
5

As Joseph Wright pointed out: The solution here is to use \sisetup{per-mode=symbol-or-fraction} as described in the siunitx manual:

Finally, it is possible for the behaviour of the \per function to depend on the prevailing math style. Setting per-mode to symbol-or-fraction will use the symbol setting for in line math, and the fraction setting when used in \displaystyle math.

So for a MWE:

\documentclass{article}

\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{per-mode=symbol-or-fraction}

\begin{document}
This is an inline equation: $a = \SI{10}{\meter\per\second\squared}$, to show inline behaviour.

And this is the same equation in displaymath environment:
\begin{equation*}
a = \SI{10}{\meter\per\second\squared}
\end{equation*}

\end{document}

Which works as expected: enter image description here

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.