0

The following gets me this error

Package siunitx Error: Duplicate \per

The desired output is N.m/(rad.s-1)

\documentclass{article}
\usepackage{siunitx}
\sisetup{
    load-configurations = abbreviations,
    inter-unit-product = \ensuremath{{\hspace{-0.5ex}}\cdot{\hspace{-0.5ex}}},
    sticky-per,
    per-mode = symbol,
    bracket-unit-denominator,
}
\DeclareSIUnit[per-mode = reciprocal-positive-first]{\radpers}{\radian\per\s}
\begin{document}
    \si{\N\m\per\radpers}
\end{document}
3
  • 1
    Try changing \si{\N\m\per\radpers} to \si{\N\m\per(\radpers)}.
    – Mico
    Dec 10, 2020 at 20:22
  • @Mico The output would be forced into the literal mode as shown here ibb.co/TgBDLCr whithout even the desired result.
    – Diaa
    Dec 10, 2020 at 20:36
  • You've set sticky-per, which means you can only have one \per in the entire unit
    – Joseph Wright
    Dec 11, 2020 at 8:59

2 Answers 2

2

You have set sticky-per, which means that \per is automatically applied to every unit after the first one. You have two \per in \N\m\per\radpers, as this becomes (effectively) \N\m\per\radian\per\s. You would see exactly the same error if you used that input directly. You need to turn off sticky-per.

(I personally do not like sticky-per: it is included in the package only as some users feel this is more 'logical'.)

4
  • I thought that the definition of the declared unit \radpers and its options won't be expanded.
    – Diaa
    Dec 11, 2020 at 9:27
  • @Diaa No, the way things work is units are parsed to give an internal representation, then re-constructed based on the output settings. That's why I said \N\m\per\radpers is 'effectively' \N\m\per\radian\per\s: in reality it's not the same.
    – Joseph Wright
    Dec 11, 2020 at 9:37
  • But if I removed sticky-per, I would get N.m/(rad.s), which means that the option per-mode = reciprocal-positive-first of \DeclareSIUnit has no effect at all. Is it intended to work like this to ignore all the options of \DeclareSIUnit? In other words, when do the options of \DeclareSIUnit affect the declared unit?
    – Diaa
    Dec 11, 2020 at 10:40
  • 1
    @Diaa No, the options always apply to the unit as a whole: as I said, what happens is everything is pared then re-combined. I get the odd question about this, but I've never seen a typeset publication where people use this 'mixed' style of unit presentation.
    – Joseph Wright
    Dec 11, 2020 at 10:54
0

A relevant answer suggested using \raiseto{-1} or \tothe{-1} instead of \per\ with \DeclareSIUnit.

However, I don't know if the error is a result of a wrong syntax or a bug.

enter image description here

\documentclass{article}
\usepackage{siunitx}
\sisetup{
    load-configurations = abbreviations,
    inter-unit-product = \ensuremath{{\hspace{-0.5ex}}\cdot{\hspace{-0.5ex}}},
    sticky-per,
    per-mode = symbol,
    bracket-unit-denominator,
}
\DeclareSIUnit{\radpers}{\radian\s\tothe{-1}}
\begin{document}
    \si{\N\m\per\radpers}
\end{document}

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.