[Tex/LaTex] Italics using siunitx

italicsiunitx

I have been using \textit for italic text in my work and also used \SI for numbers with units using the siunitx package. There is now an instance where I want the number and unit to be in italics, so I've written:

\textit{\SI[]{8}{\micro\meter}}

But it does not appear in italics. I can't understand from the help documentation which option to use. Any advice? I have not used \sisetup{} in the preamble either.

Best Answer

Simply use \sisetup{detect-all = true}

See the documentation on page 20:

The siunitx package controls the font used to print output independently of the surrounding material. The standard method is to ignore the surroundings entirely, and to use the current body fonts. However, the package can detect and follow surrounding bold, italic and font family changes.

\documentclass{article}
\usepackage{siunitx}

\begin{document}
    \SI{7}{\metre}

    %Change to detect-all = true
    \sisetup{detect-all = true}
    \textit{\SI{7}{\metre}}

    %Change it back to detect-none = true
    \sisetup{detect-none = true}
    \textit{\SI{7}{\metre}}
\end{document} 

enter image description here

The documentation also says on page 83:

The mathematical meaning of units also means that the shape, weight and family are important. Units are supposed to be typeset in an upright, medium weight serif font. Italic, bold and sans serif are all used mathematically to convey other meanings.

Maybe you should think over using italic units

Related Question