I know there is a command like \degreeCelsius in siunitx. But I do not know how to define something like \degreeKelvin (in a title like this). using \qty{300}{\degree\Kelvin} will add too many spaces.
Asked
Active
Viewed 184 times
2
Joseph Wright
- 259,911
- 34
- 706
- 1,036
Ryan
- 135
1 Answers
4
The general case of declaring a new unit is covered by Defining new unit (year, century) in siunitx. Here, the degree symbol is slightly tricky. Assuming you are not using unicode-math then a definition that matches that for \degreeCelsius would be
\DeclareSIUnit \degreekelvin
{\ifmmode{}^{\circ}\else\textdegree\fi K}
(Other than Celsius, unit names are not capitalised.)
If you are loading unicode-math, then
\DeclareSIUnit\degreekelvin{°K}
should work.
However, for a 'one off' case like this, I'd be tempted just to use literal unit input
\qty{300}{{}^{\circ} K}
(or similar): you don't need all of the unit processing, you can be sure of math vs text mode, etc.
Joseph Wright
- 259,911
- 34
- 706
- 1,036
-
Thank you, I have
unicode-mathloaded, and it works for me! BTW, your answer has an extra three backticks. – Ryan Aug 23 '23 at 05:55
\DeclareSIUnit{\degreeKelvin}{\ensuremath{{}^\circ}K}could be a start. – Qrrbrbirlbel Aug 23 '23 at 01:22°K. – Ryan Aug 23 '23 at 01:51°Kor define\def\degreeKelvin{°K}and write\degreeKelvin. – wipet Aug 23 '23 at 06:51