In your preamble
\DeclareSIUnit\century{century}
\DeclareSIUnit\year{yr}
See the siunitx
manual (v2.1 series), Section 4.5, page 12.
Reading the siunitx
manual (→ 5.15 “Symbols”, pp. 62/63) one can find two ways to achieve this:
- Redefinition of
\SIUnitSymbolDegree
, -Arcminute
and -Arcsecond
- Using the options
text-
/math-degree
, -arcminute
and -arcsecond
(→ Table 43, p. 63)
For both cases applies:
The new macro \ra
takes two arguments:
- one optional that gets passed to
\ang
and
- one mandatory (the angle itself).
All “arc format” options (angle-symbol-over-decimal
, arc-separator
, …) can be given to \ra
, too.
Solution 1
\newcommand*{\ra}[2][]{{% extra pair of braces to keep the \def-intion local!
\def\SIUnitSymbolDegree{\textsuperscript{h}}%
\def\SIUnitSymbolArcminute{\textsuperscript{m}}%
\def\SIUnitSymbolArcsecond{\textsuperscript{s}}%
\ang[#1]{#2}}%
}
Solution 2
\newcommand*{\ra}[2][]{%
\ang[
math-degree=\textsuperscript{h},
text-degree=\textsuperscript{h},
math-arcminute=\textsuperscript{m},
text-arcminute=\textsuperscript{m},
math-arcsecond=\textsuperscript{s},
text-arcsecond=\textsuperscript{s},
#1]{#2}%
}
Code
\documentclass{article}
\usepackage{siunitx}
\newcommand*{\ra}[2][]{{% extra pair of braces for solution 1, doesn't hurt for solution 2
% \def\SIUnitSymbolDegree{\textsuperscript{h}}% Solution 1
% \def\SIUnitSymbolArcminute{\textsuperscript{m}}% Solution 1
% \def\SIUnitSymbolArcsecond{\textsuperscript{s}}% Solution 1
\ang[
math-degree=\textsuperscript{h}, % Solution 2
text-degree=\textsuperscript{h}, % Solution 2
math-arcminute=\textsuperscript{m}, % Solution 2
text-arcminute=\textsuperscript{m}, % Solution 2
math-arcsecond=\textsuperscript{s}, % Solution 2
text-arcsecond=\textsuperscript{s}, % Solution 2
#1]{#2}%
}}
\begin{document}
\ra[angle-symbol-over-decimal]{5.237} \par
\ra{5.237} \par \ra{5;15;6.5} \par \vspace{2ex}
\ang{2.3;3.4;4.5} \par \ra{2.3;3.4;4.5} \par \ang{2.3;3.4;4.5} \par
\ra[angle-symbol-over-decimal,arc-separator=\,]{2.3} \par \vspace{2ex}
$\ra[angle-symbol-over-decimal]{5.237} \quad \ra{5.237} \quad \ra{5;15;6.5}$
\end{document}
Output
Best Answer
Here is something to start with: