Closed Aljumaily closed 10 months ago
si={...}
won't ignore font
key, for example si={...}, font=\Large
does affect the font size. It is siunitx
that ignores \itshape
.
By default siunitx
prints output in math mode, and even when configured to print in text mode, by default it uses a static \upshape\mdseries\rmfamily
font setting. See siunitx
package doc (2023-08-03), sec. 4.2 "Printing" for more info.
In example below, siunitx
configuration mode=match, reset-text-shape=false
is added to print output in text mode if the input is in text mode and allow font shape switching. To be complete, you may also want to set reset-text-family=false, reset-text-series=false
.
\documentclass{article}
\usepackage{tabularray}
\usepackage{xcolor}
\UseTblrLibrary{siunitx}
\begin{document}
{
\sisetup{round-mode=places, round-precision=3}
\itshape
% \sisetup{mode=math, reset-text-shape=true} % default setting
\num{10.1} in text mode, $\num{10.2}$ in math mode\par
\sisetup{mode=match} % no effect
\num{10.1} in text mode, $\num{10.2}$ in math mode\par
\sisetup{mode=match, reset-text-shape=false} % now works, in text mode number is in italic
\num{10.1} in text mode, $\num{10.2}$ in math mode\par
}
\begin{tblr}{
hlines, vlines,
column{1}={si={table-format=2.3, round-mode=places, round-precision=3}},
column{2}={font=\itshape},
column{3}={
si={table-format=2.3, round-mode=places, round-precision=3, mode=match, text-font-command=\itshape},
font=\itshape
},
column{4}={font=\itshape},
row{1}={guard, font=\normalfont\bfseries}
}
Formatted & Font changed & Formatted \& Font changed & Expected \\
10.1 & 10.1 & 10.1 & 10.100 \\
20.2 & 20.2 & 20.2 & 20.200 \\
30.3 & 30.3 & 30.3 & 30.300 \\
40.4 & 40.4 & 40.4 & 40.400 \\
\end{tblr}
\end{document}
@muzimuzhi Thank you for the perfect and detailed response!
It seems that combining
si={...}
andfont=...
ignores the font suggestion. The output in the "Expected" column is the desired output.