Azimuths are often written with a leading zero, e.g. NE as 045°. I am using the siunitx package to format all the other quantities in my document with the \SI macro, e.g.




comes out as 45°. What is the best way to produce 045°, but keeping the useful aspects that siunitx provides, like keeping the value and unit together with a nice spacing?

Edit: I might have figured this one out:

\SI[parse-numbers = false]{045}{\degree}

produces 045°.


1 Answer 1


While \SI[parse-numbers = false]{045}{\degree} works it also turns off all of siunitx's parsing for that entry; to retain parsing try

\SI[minimum-integer-digits = 3]{45}{\degree}

As this is quite long you might like to define a new command \azimuth

\newcommand*{\azimuth}[1]{\SI[minimum-integer-digits = 3]{#1}{\degree}}

and use it \azimuth{45}.

If you want all numbers parsed by siunitx to have at least three integer digits, go with

\sisetup{minimum-integer-digits = 3}

@Torbjørn T. mentioned that siunitx even provides a command for angles aptly named \ang{}. So \ang[minimum-integer-digits = 3]{45} also does what you want.

The following definition of \azimuth always produces three digits for degree, two for minute and second.

\cs_new:Npn \__angle_print:nnn #1#2#3 {
  \IfNoValueF {#1}
    {\SI[minimum-integer-digits = 3]{#1}{\degree}}
  \IfNoValueF {#2}
    {\SI[minimum-integer-digits = 2]{#2}{\arcminute}}
  \IfNoValueF {#3}
    {\SI[minimum-integer-digits = 2]{#3}{\arcsecond}}
\NewDocumentCommand \azimuth { > { \SplitArgument { 2 } { ; } } m } {
  \__angle_print:nnn #1

Compare the output of \azimuth{145;59;59} \azimuth{90;35;17} \azimuth{1;2;3} with siunitx's \ang{145;59;59} \ang{90;35;17} \ang{1;2;3}: enter image description here

  • 4
    As an addition you could mention \ang[minimum-integer-digits=3]{45}. Sep 23, 2013 at 9:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .