2

I use the tabularray package for tables and combined the X column with the si option.

The X column` is defined as: enter image description here

My MWE yields this obfuscated table enter image description here

And I tried to tweak some options, but I really don't know where I have gone wrong, because there are no errors or warnings. Or maybe is it a bug, I don't know? Can someone tell where the problem comes from and fix it?

MWE:

\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}

\usepackage{tabularray}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\UseTblrLibrary{amsmath, siunitx}

\begin{document}
    \begin{tblr}{hlines, vlines,
                 colspec = { l| *{8}{X[c, si={exponent-mode=scientific}]} },
                 rowsep  = 4pt,
                 row{1} = {guard}
                 }
    Koeffizient &A         &B       &C        &D        &E        &F         &G      \\ \hline
    \ce{H2}     &392,8422  &2,4906  &-3,6262  &-1,9624  &35,6197  &-81,3691  &62,666 \\ 
    \ce{H2O}    &706,3032  &5,1703  &-6,0865  &-6,6011  &36,2723  &-63,0965  &46,2085\\ 
    \end{tblr}
\end{document}

2 Answers 2

3

Like this?

enter image description here

  • The way as you define scientific mode is wrong, it should be defined before table.
  • Your table is quite wide. Therefore I rounded number figures to four digits and define table-format separately where scientific format take a place, and separate for negative and positive numbers:
\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}
\usepackage{geometry}
\usepackage{tabularray}
\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}
\sisetup{exponent-mode = scientific, exponent-product=\cdot, tight-spacing,
         round-mode = figures, round-precision=4,
         locale=DE
         }%

\begin{table}[ht]
    \centering
    \begin{tblr}{colspec = {@{} l
                                Q[c, si={table-format= 1.3e1}]
                                Q[c, si={table-format= 1.3}]
                           *{2}{Q[c, si={table-format=-1.3}]}
                                Q[c, si={table-format= 1.3}]
                                Q[c, si={table-format=-1.3e1}]
                                Q[c, si={table-format= 1.3e1}]
                           @{}},
                 row{1} = {guard}
                 }
    \toprule
    Koeffizient &A         &B       &C        &D        &E        &F         &G      \\ 
    \midrule
    \ce{H2}     &392,8422  &2,4906  &-3,6262  &-1,9624  &35,6197  &-81,3691  &62,666 \\
    \ce{H2O}    &706,3032  &5,1703  &-6,0865  &-6,6011  &36,2723  &-63,0965  &46,2085\\
    \bottomrule
    \end{tblr}
\end{table}
\end{document}

As you can see I also "liberate" cells' contents from "jail" of vertical and unnecessary horizonal lines.

2

You don't need tabularray.

\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}

\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\usepackage{booktabs} % for the second table

\begin{document}

\begin{table}[htp]

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}} | c ||
  S[table-format=3.4]  |
  S[table-format=1.4]  |
  S[table-format=-1.4] |
  S[table-format=-1.4] |
  S[table-format=2.4]  |
  S[table-format=-2.4] |
  S[table-format=2.4]  |
}
\hline
Koeffizient & {A}      & {B}    & {C}     & {D}     & {E}     & {F}      & {G}     \\
\hline
\ce{H2}     & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666  \\ 
\ce{H2O}    & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\hline
\end{tabular*}

\caption{A caption}

\end{table}

\begin{table}[htp]
\setlength{\tabcolsep}{0pt} % leave the spacing to TeX

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}} c
  S[table-format=3.4]
  S[table-format=1.4]
  S[table-format=-1.4]
  S[table-format=-1.4]
  S[table-format=2.4]
  S[table-format=-2.4]
  S[table-format=2.4]
}
\toprule
Koeffizient & {A}      & {B}    & {C}     & {D}     & {E}     & {F}      & {G}     \\
\midrule
\ce{H2}     & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666  \\ 
\ce{H2O}    & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\bottomrule
\end{tabular*}

\caption{A caption}

\end{table}

\end{document}

I'd prefer the latter realization, of course.

enter image description here

With exponential form, the first table must have reduced \tabcolsep to fit.

\documentclass[12pt, listof=totoc, numbers=noenddot]{scrartcl}

\usepackage[version=4]{mhchem}
\usepackage[detect-all]{siunitx}
\usepackage{booktabs} % for the second table

\begin{document}

\begin{table}[htp]

\sisetup{
  exponent-mode = scientific,
%  exponent-product=\cdot,
  tight-spacing,
  round-mode = figures,
  round-precision=4,
}

\addtolength{\tabcolsep}{-1.8pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}} | c ||
  S[table-format=1.3e1]  |
  S[table-format=1.3]  |
  S[table-format=-1.3] |
  S[table-format=-1.3] |
  S[table-format=1.3e1]  |
  S[table-format=-1.3e1] |
  S[table-format=1.3e1]  |
}
\hline
Koeffizient & {A}      & {B}    & {C}     & {D}     & {E}     & {F}      & {G}     \\
\hline
\ce{H2}     & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666  \\ 
\ce{H2O}    & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\hline
\end{tabular*}

\caption{A caption}

\end{table}

\begin{table}[htp]

\setlength{\tabcolsep}{0pt} % leave the spacing to TeX
\sisetup{
  exponent-mode = scientific,
%  exponent-product=\cdot,
  tight-spacing,
  round-mode = figures,
  round-precision=4,
}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}} c
  S[table-format=1.3e1]
  S[table-format=1.3]
  S[table-format=-1.3]
  S[table-format=-1.3]
  S[table-format=1.3e1]
  S[table-format=-1.3e1]
  S[table-format=1.3e1]
}
\toprule
Koeffizient & {A}      & {B}    & {C}     & {D}     & {E}     & {F}      & {G}     \\
\midrule
\ce{H2}     & 392,8422 & 2,4906 & -3,6262 & -1,9624 & 35,6197 & -81,3691 & 62,666  \\ 
\ce{H2O}    & 706,3032 & 5,1703 & -6,0865 & -6,6011 & 36,2723 & -63,0965 & 46,2085 \\
\bottomrule
\end{tabular*}

\caption{A caption}

\end{table}

\end{document}

enter image description here

Tips:

  1. never use double rules in tables;
  2. never use vertical rules in tables.
1
  • Thank you 👍, I wanted to use tabularray in the solution, but your answer is a nice alternative. It also sets the tabel width to the linewidth, with automatic row spacing, which is nice to learn for beginners like me (I only know X columne).
    – jajajafeti
    Aug 16, 2023 at 19:54

You must log in to answer this question.

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