使用 tabulararray 包将数字对齐到小数点

使用 tabulararray 包将数字对齐到小数点

我使用该选项是si={table-format=3.4}因为我将有数百位范围内的整数和多达四位小数,但小数和范围都没有排列。

我可能错过了什么?

\documentclass{scrartcl}
\usepackage[margin=20mm]{geometry}

\usepackage{pdflscape}
\usepackage[version=4]{mhchem}
\usepackage{xcolor}
\definecolor{dark-blue}{RGB}{28, 69, 135}
\definecolor{purple}{rgb}{.82, .1, .26}
\definecolor{tableLineOne}{RGB}{255, 253, 233}
\definecolor{tableLineTwo}{RGB}{255, 250, 194}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewTableCommand\panelsteel{
    \SetCell[c=8]{c,bg=purple,fg=white}}    

\begin{document}
\begin{landscape}
    \begin{longtblr}[
        caption = {Minimal booktabs example.},
        label = {tab:table1}
        ]{
            colspec = {*{8}{X[si={table-format=3.4},c, m, cmd={\hskip 0pt}]}},
            colsep  = 1.2pt,
            cell{1}{1-2} = {r=2}{m},
            row{even[3]} = {bg= black!30},
            row{odd[3]}  = {bg= black!5},
            row{1,2}= {fg=white,bg=dark-blue},
            rowhead=2
        }
        \toprule[fg=white]
       Thickness (in)
        &   Amperage (\unit{\ampere}) 
        &   \SetCell[c=3]{c}  Voltage (\unit{\volt})& &
        &   \SetCell[c=3]{c}  Wire feed speed (ipm)& &\\
        \midrule[fg=white]
        &   & \ce{CO2}   
        & \ce{Ar} \qty{75}{\%} \ce{CO2} \qty{25}{\%}  
        & \ce{Ar} \qty{98}{\%}+  \ce{O2} \qty{2}{\%} 
        & Steel 0.030  
        & Steel 0.035 
        & Steel 0.045 \\
        \bottomrule[fg=white]
        \panelsteel{Short circuit transfer mode}
          &   &   &   &   &   &   &        \\
        \midrule[fg=dark-blue]
         .028 & 40 - 55   & 16 - 17   & 15 - 16   & -  & 90 - 100  & - & - \\
         .036 & 50 - 60   & 17 - 18   & 15 - 16   & - & 120 - 135 & 105 - 115 & -  \\
         .048 & 70 - 80   & 18 - 19   & 16 - 17   & - & 150 - 175 & 140 - 160 & 70 \\
         .064 & 90 - 110  & 19 - 20   & 17 - 18   & - & 220 - 250 & 180 - 220 & 90 - 110 \\
         .08 & 120 - 130 & 20 - 21   & 17 - 18   & - & 250 - 340 & 240 - 260 & 120 - 130\\
         .125   & 140 - 150 & 21 - 22   & 18 - 19   &   & - & 280 - 300 & 140 - 150\\
         .1875  & 160 - 170 & 21 - 22   & 18 - 19   & - & - & 320 - 340 & 160 - 175\\
         .25   & 180 - 190 & 23 - 24   & 21 - 22   & - & - & 360 - 380 & 185 - 195\\
         .3125  & 200 - 210 & 23 - 24   & 21 - 22   & - & - & 400 - 420 & 210 - 220\\
         .375   & 220 - 250 & 24 - 25   & 23 - 24   & - & - & 420 - 520 & 220 - 270\\
         .5   & 300 & - & - &  - & - & - & 375\\
        \midrule[fg=dark-blue]
        \panelsteel{Spray arc transfer mode}
           &   &   &   &   &   &   &   \\
        \midrule[fg=dark-blue]
         .028 & 50 - 60 & - & - & - & 120 - 135   & 105 - 115 & - \\
         .036 & 70 - 80 & - & - & - & 150 - 175   & 140 - 160 &   70\\
         .048 & 90 - 110    & - & - & - & 220 - 250   & 180 - 220 & 90 - 110\\
         .064 & 120 - 130   & - & - & - & 250 - 340   & 240 - 260 & 120 - 130\\
         .08 & 140 - 150   & - & - & - & - & 280 - 300   & 140 - 150\\
         .125   & 160 - 170   & - & - &  23 - 24 & - & 320 - 340   & 160 - 175\\
         .1875  & 180 - 190   & - & - &  24 - 25 & - & 360 - 380   & 185 - 195\\
         .25   & 200 - 210   & - & - &  24 - 25 & - & 400 - 420   & 210 - 220\\
         .3125  & 220 - 250   & - & - &  25 - 26 & - & 420 - 520   & 220 - 270\\
         .375   & 300 & - & - &   26 - 27 & - & - & 375\\
         .5   & 315 & - & - &   29 - 30 & - & - & 390\\
        \bottomrule[fg=dark-blue]
    \end{longtblr}    
\end{landscape}
\end{document}

答案1

您对使用该选项的列非常慷慨si。您实际上只想将其用于第一列,而不是将其用于所有列。因此,我替换了

colspec = {*{8}{X[si={table-format=3.4},c, m, cmd={\hskip 0pt}]}},

经过

colspec = colspec = {X[si={table-format=3.4},c]*{7}{X[c]}},

此外,如手册中所述,您需要使用三倍用大括号保护该列中的非数字单元格。

\documentclass{scrartcl}
\usepackage[margin=20mm]{geometry}

\usepackage{pdflscape}
\usepackage[version=4]{mhchem}
\usepackage{xcolor}
\definecolor{dark-blue}{RGB}{28, 69, 135}
\definecolor{purple}{rgb}{.82, .1, .26}
\definecolor{tableLineOne}{RGB}{255, 253, 233}
\definecolor{tableLineTwo}{RGB}{255, 250, 194}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\NewTableCommand\panelsteel{
    \SetCell[c=8]{c,bg=purple,fg=white}}    

\begin{document}
\begin{landscape}
    \begin{longtblr}[
        caption = {Minimal booktabs example.},
        label = {tab:table1}
        ]{
            colspec = {X[si={table-format=3.4},c]*{7}{X[c]}},{X[c]}},
            colsep  = 1.2pt,
            cell{1}{1-2} = {r=2}{m},
            row{even[3]} = {bg= black!30},
            row{odd[3]}  = {bg= black!5},
            row{1,2}= {fg=white,bg=dark-blue},
            rowhead=2
        }
        \toprule[fg=white]
       {{{Thickness (in)}}}
        &   Amperage (\unit{\ampere}) 
        &   \SetCell[c=3]{c}  Voltage (\unit{\volt})& &
        &   \SetCell[c=3]{c}  Wire feed speed (ipm)& &\\
        \midrule[fg=white]
        &   & \ce{CO2}   
        & \ce{Ar} \qty{75}{\%} \ce{CO2} \qty{25}{\%}  
        & \ce{Ar} \qty{98}{\%}+  \ce{O2} \qty{2}{\%} 
        & Steel 0.030  
        & Steel 0.035 
        & Steel 0.045 \\
        \bottomrule[fg=white]
        \panelsteel{{{{Short circuit transfer mode}}}}
          &   &   &   &   &   &   &        \\
        \midrule[fg=dark-blue]
         .028 & 40 - 55   & 16 - 17   & 15 - 16   & -  & 90 - 100  & - & - \\
         .036 & 50 - 60   & 17 - 18   & 15 - 16   & - & 120 - 135 & 105 - 115 & -  \\
         .048 & 70 - 80   & 18 - 19   & 16 - 17   & - & 150 - 175 & 140 - 160 & 70 \\
         .064 & 90 - 110  & 19 - 20   & 17 - 18   & - & 220 - 250 & 180 - 220 & 90 - 110 \\
         .08 & 120 - 130 & 20 - 21   & 17 - 18   & - & 250 - 340 & 240 - 260 & 120 - 130\\
         .125   & 140 - 150 & 21 - 22   & 18 - 19   &   & - & 280 - 300 & 140 - 150\\
         .1875  & 160 - 170 & 21 - 22   & 18 - 19   & - & - & 320 - 340 & 160 - 175\\
         .25   & 180 - 190 & 23 - 24   & 21 - 22   & - & - & 360 - 380 & 185 - 195\\
         .3125  & 200 - 210 & 23 - 24   & 21 - 22   & - & - & 400 - 420 & 210 - 220\\
         .375   & 220 - 250 & 24 - 25   & 23 - 24   & - & - & 420 - 520 & 220 - 270\\
         .5   & 300 & - & - &  - & - & - & 375\\
        \midrule[fg=dark-blue]
        \panelsteel{{{{Spray arc transfer mode}}}}
           &   &   &   &   &   &   &   \\
        \midrule[fg=dark-blue]
         .028 & 50 - 60 & - & - & - & 120 - 135   & 105 - 115 & - \\
         .036 & 70 - 80 & - & - & - & 150 - 175   & 140 - 160 &   70\\
         .048 & 90 - 110    & - & - & - & 220 - 250   & 180 - 220 & 90 - 110\\
         .064 & 120 - 130   & - & - & - & 250 - 340   & 240 - 260 & 120 - 130\\
         .08 & 140 - 150   & - & - & - & - & 280 - 300   & 140 - 150\\
         .125   & 160 - 170   & - & - &  23 - 24 & - & 320 - 340   & 160 - 175\\
         .1875  & 180 - 190   & - & - &  24 - 25 & - & 360 - 380   & 185 - 195\\
         .25   & 200 - 210   & - & - &  24 - 25 & - & 400 - 420   & 210 - 220\\
         .3125  & 220 - 250   & - & - &  25 - 26 & - & 420 - 520   & 220 - 270\\
         .375   & 300 & - & - &   26 - 27 & - & - & 375\\
         .5   & 315 & - & - &   29 - 30 & - & - & 390\\
        \bottomrule[fg=dark-blue]
    \end{longtblr}    
\end{landscape}
\end{document}

在此处输入图片描述

相关内容