I'm trying center specific cells with tabularray, but I don't see how to override the alignment from siunitx. I want the cells on the second row from the top to be centered, but they are currently aligned at the decimal point.
\documentclass{standalone}
\usepackage{siunitx}
\usepackage{tabularray}
\usepackage{amsmath}
\UseTblrLibrary{booktabs,siunitx,amsmath}
\newcommand{\deltav}[1]{\ensuremath{\Delta V#1}}
\newcommand{\unitE}{\ensuremath{\text{km}^{2}/\text{s}^{2}}}
\providecommand\degrees[1]{\ensuremath{#1^\circ}} % for degrees symbol
\providecommand{\ccc}{\ensuremath{\text{C3}}}
\providecommand{\rla}{\ensuremath{\text{RLA}}}
\providecommand{\dla}{\ensuremath{\text{DLA}}}
\NewColumnType{H}[2]{S[table-format=#1, round-mode=places, round-precision = #2, scientific-notation = true, exponent-mode = fixed, fixed-exponent = 0]}
\NewColumnType{K}{H{6.4f}{4}}
\begin{document}
\begin{booktabs}{
colspec = {c K K K},
row{1} = {font=\bfseries},
cell{1-2}{1-4} = {}{c},
}
\toprule
& \ccc & \rla & \dla \\
Shift & 0.025\, \unitE{} & 0.005\degrees{} & 0.008\degrees{} \\
\midrule
B.T km & 14028.09419155 & 982.72457669 & -13477.32067085 \\
B.R km & -7751.49915236 & -3700.77434474 & 3148.12003385 \\
\midrule
\deltav{_\text{x}} m/s & 4.774015816660711e-01 & 4.126455467703491e-02 & -4.480105352801190e-01 \\
\deltav{_\text{y}} m/s & 6.781754913310237e-01 & -7.925658411887511e-02 & -8.241304954028742e-01 \\
\deltav{_\text{z}} m/s & 7.649481111877549e-01 & 4.826834479224431e-01 & -1.507332008655069e-01 \\
\midrule
\deltav{} m/s & 1.128264100301457 & 4.908845897939598e-01 & 9.500657929944257e-01 \\
\midrule
TCM \deltav{} m/s & 4.546833189860270e-0 & 4.563499345528536e-0 & 4.486347115134618e-0 \\
\bottomrule
\end{booktabs}
\end{document}
which gives me
The most obvious misalignment is the cell containing "0.0250 km2/s2". I want that text centered in the column.
Best Answer
You should change
booktabs
preamble to:Explanation:
By adding
guard
to specification of the second row, this row not obeysiunitx
specifications for columns and text in cells in this row are just centered, i.e. after this addition you will get:However, I would write your table on the following, to my opinion simpler and more in
tabularray
spirit, way where is considered @Mico comment too: