josephwright / siunitx

A comprehensive (SI) units package for LaTeX
LaTeX Project Public License v1.3c
359 stars 26 forks source link

Poor formatting of `\kWh` when used in conjunction with `\per` #752

Closed dbitouze closed 2 weeks ago

dbitouze commented 2 weeks ago

The following MCE shows that it is impossible to get right formatting for \kWh, defined as:

\siunitx_declare_unit:Nnn \kWh { \kilo \watt \hour }
  { inter-unit-product = }

when used in conjunction with \per:

\documentclass{article}
\usepackage{siunitx}
\begin{document}
\qty{1}{\kWh}

\qty{1}{\kWh\per\kg}

\qty[inter-unit-product =]{1}{\kWh\per\kg}
\end{document}

image

josephwright commented 2 weeks ago

To-be-expected. The \kWh unit is set up to do the non-standard spacing people tend to want for the unit as-is. However, it's defined as \kilo\watt\hour, so when used in a combination it reverts to the standard spacing. If you want a 'fixed' spacing, you'll need to do

\DeclareSIUnit\kWh{kWh}

or similar so that it's not actually linked to the constituent units.

josephwright commented 2 weeks ago

This is covered in the manual in 'Special considerations for the \kWh unit'.

dbitouze commented 2 weeks ago

This is covered in the manual in 'Special considerations for the \kWh unit'.

Ah,indeed, sorry to not have noticed!