1

I want to create a table with descriptions with line breaks. Unfortunately, one title is not displayed and I do not know why and how to solve it. My code is the following:

\documentclass{article}
\usepackage{rotating}   
\usepackage{makecell}   
\usepackage{tabularray}

\begin{document}
    
    
\begin{table}
 \footnotesize
    \begin{tblr}{colspec={cQ[c,3cm]Q[c,3cm]Q[c,3cm]Q[c,3cm]}}
        
            & \SetCell[c=2]{c} {Chlorination degree of \\ paraffinic compounds $n$\textsubscript{Cl}} & \SetCell[c=2]{c} {Chlorination degree of \\ olefinic compounds $n$\textsubscript{Cl}}\\ 
        & non-exposed (0h) & exposed (144h) & non-exposed (0h) & exposed (144h) \\ 
        Non-hydroxylated & 8.80  $\pm$ 0.00 & 9.07 $\pm$ 0.00 & 8.37 $\pm$ 0.02 & 8.55 $\pm$ 0.01    \\ 
        Mono-hydroxylated & 8.31  $\pm$ 0.06 a) & 7.59 $\pm$ 0.01 & 8.31  $\pm$ 0.06 a) & 7.04 $\pm$ 0.03 \\ 
        Di-hydroxylated & n.d. & 6.61 $\pm$ 0.04 & n.d. & 5.23 $\pm$ 0.01 \\ 
        
\end{tblr}
\end{table}


\end{document}

The output is this:

—-

As you can see, the description of the last two columns is missing. What it should look like is this:

—-

The data is taken from https://doi.org/10.1016/j.chemosphere.2020.128288

2 Answers 2

3

At tabularray in contrary to other tables' packages in each rows regardless if in them are multicolumn cells (written as \SetCell[c=2]{c} ... ) had to be all ampersands as defined in table preamble. In your case, the MWE should be:

\documentclass{article}
\usepackage{rotating}
\usepackage{makecell}
\usepackage{tabularray}
\usepackage[version=4]{mhchem} % <--- new

\begin{document}
    \begin{table}
    \footnotesize
\begin{tblr}{colspec={c *{4}{Q[c,3cm]}}}
    & \SetCell[c=2]{c} {Chlorination degree of \\ 
                        paraffinic compounds $n_{\ce{Cl}}$} 
        &   & \SetCell[c=2]{c} {Chlorination degree of \\ 
                                olefinic compounds $n_{\ce{Cl}}$}
                &                   \\
    & non-exposed (0h) 
        & exposed (144h) 
            & non-exposed (0h) 
                & exposed (144h)    \\
Non-hydroxylated 
    & $8.80\pm 0.00$ 
        & $9.07\pm 0.00$ 
            & $8.37\pm 0.02$
                & $8.55\pm 0.01$    \\
Mono-hydroxylated 
    & $8.31\pm 0.06$ a) 
        & $7.59\pm 0.01$ 
            & $8.31\pm 0.06$ a) 
                & $7.04\pm 0.03$    \\
Di-hydroxylated 
    & n.d. 
        & $6.61\pm 0.04$ 
            & n.d. 
                & $5.23\pm 0.01$    \\
\end{tblr}
    \end{table}
\end{document}

enter image description here

Edit: For chemical elements (and formulae) is sensible to employ mhchem package and write symbol for chlorine \ce{Cl} or n-clorine $n_{\ce{Cl}}$.

Off-topic: Your table is wider than text area width. So, you may consider the following table preamble:

\begin{tblr}{colspec={l *{4}{X[c]}}}

which gives:

enter image description here

2
  • Thanks a lot Zarko. The permeable \begin{tblr}{colspec={l *{4}{X[c]}}} worked. A comment to your suggestion of using \ce{Cl}. This is reasonable in a chemical formula, I agree. But as subscripted term like the used number of chlorine ($n$\textsubscript{Cl})I rather do not want to have it in the \ce{Cl} environment. An option might be $n$\textsubscript{\ce{Cl}}, but I did not test it.
    – MCK1886
    Commented Mar 29, 2022 at 13:39
  • @MCK1886, corrected notation for n-chlorine: $n_{\ce{Cl}}$. BTW, since answer solve your problem, you may consider to accept it ;-)
    – Zarko
    Commented Mar 29, 2022 at 13:49
0

Do you need tabularray? You can get a better result with the standard tabular* and siunitx.

\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage[version=4]{mhchem}

\sisetup{
  retain-zero-uncertainty,
  uncertainty-mode=separate,
}

\begin{document}
    
    
\begin{table}
\centering
\setlength{\tabcolsep}{0pt}

\newcommand{\splitcell}[2]{%
  \multicolumn{#1}{c}{\begin{tabular}{@{}c@{}}#2\end{tabular}}%
}
\newcommand{\?}[1]{\rlap{\textsuperscript{#1}}}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  l
  S[table-format=1.2(2)]
  S[table-format=1.2(2)]
  S[table-format=1.2(2)]
  S[table-format=1.2(2)]
  @{}
}
\toprule
& \splitcell{2}{Chlorination degree of \\ paraffinic compounds $n_{\ce{Cl}}$}
& \splitcell{2}{Chlorination degree of \\ olefinic compounds $n_{\ce{Cl}}$} \\
\cmidrule{2-3} \cmidrule{4-5}
& {non-exposed} & {exposed} & {non-exposed} & {exposed} \\
& {(0h)}        & {(144h)}  & {(0h)}        & {(144h)} \\
\midrule
Non-hydroxylated  & 8.80 \pm 0.00      & 9.07 \pm 0.00 & 8.37 \pm 0.02      & 8.55 \pm 0.01 \\
Mono-hydroxylated & 8.31 \pm 0.06\?{a} & 7.59 \pm 0.01 & 8.31 \pm 0.06\?{a} & 7.04 \pm 0.03 \\
Di-hydroxylated   & {n.d.}             & 6.61 \pm 0.04 & {n.d.}             & 5.23 \pm 0.01 \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

enter image description here

You must log in to answer this question.

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