1

I am writing a paper with the LNCS style file, and I ran into trouble trying to use multicols in my table. I am unable to get the text in my second row H (mm) to wrap to the next line, and I am unsure how to fix it. I basically want the number after the \pm to be on a new line since there is no space.

At the moment, it looks like this at the moment

I would like to get it everything equally spaced like this required table

Is there a more methodical way to do this because it looks ugly at the moment?

\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}}
.
.
\begin{table}[!ht]
\centering
\caption{Average error metrics.}
\smallskip
\begin{tabularx}{\columnwidth}{L{1cm} C{1.5cm}C{1.5cm}C{1.5cm}  C{0.01cm} C{1.5cm}C{1.5cm}C{1.5cm}}
\toprule
& \multicolumn{3}{c}{UHFUS} & & \multicolumn{3}{c}{HFUS} \\
\cmidrule(){2-4} \cmidrule(){6-8}
Metric & {G1} & {G2} & {G3} & & {G1} & {G2} & {G3} \\
\midrule
D & 0.91$\pm$0.01 & 0.90$\pm$0.01 & 0.89$\pm$0.01 & & 0.91$\pm$0.01 & 0.91$\pm$0.02 & 0.91$\pm$0.02 \\
H ($mm$) & 0.0973$\pm$0.019 & 0.0917$\pm$0.019 & 0.105$\pm$0.02 & & 0.292$\pm$0.023 & 0.281$\pm$0.065 & 0.273$\pm$0.04\\
DFP & 1.35 & 5 & 4.93 & & 12.3 & 5 & 34.6 \\
DFN & 1.35 & 5 & 4.93 & & 12.3 & 5 & 34.6\\
\bottomrule
\end{tabularx}
\label{table1}
\end{table}
2
  • 1
    Did you try H~($mm$)? This prevents the line break, but I think you may to redesign your table because some texts are overlapping, essentially since your fixed column widths are too small. (Really weird, a marmot trying to help a eagle. ;-)
    – user121799
    Feb 24, 2018 at 6:29
  • I suspect that instead of \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}, you want \newcolumntype{C}{>{\centering\arraybackslash}X}.
    – Mico
    Feb 24, 2018 at 7:22

2 Answers 2

3

Since no line-wrapping is needed in any of the columns, using a tabularx environment isn't required, or even advisable. Instead, use a tabular* environment.

Note that by switching to \footnotesize, it's possible to avoid having linebreaks between numbers.

enter image description here

\documentclass{llncs} % from ftp://ftp.springernature.com/cs-proceeding/llncs/llncs2e.zip
\usepackage{booktabs}
\begin{document}

\begin{table}[!ht]
\caption{Average error metrics.} \label{table1}
\setlength\tabcolsep{0pt} % let tabular&* figure out whitespace
\footnotesize
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{6}{c} }
\toprule
Metric &\multicolumn{3}{c}{UHFUS} & \multicolumn{3}{c}{HFUS} \\
\cmidrule(l){2-4} \cmidrule(l){5-7}
& G1 & G2 & G3 & G1 & G2 & G3 \\
\midrule
D & 0.91$\pm$0.01 & 0.90$\pm$0.01 & 0.89$\pm$0.01 & 0.91$\pm$0.01 & 0.91$\pm$0.02 & 0.91$\pm$0.02 \\
H\,(mm) & 0.097$\pm$0.019 & 0.092$\pm$0.019 & 0.105$\pm$0.02 & 0.292$\pm$0.023 & 0.281$\pm$0.065 & 0.273$\pm$0.04\\
DFP & 1.35 & 5 & 4.93 & 12.3 & 5 & 34.6 \\
DFN & 1.35 & 5 & 4.93 & 12.3 & 5 & 34.6 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}
0

Here is an alternative using siunitx:

enter image description here

\documentclass{llncs}
\usepackage{booktabs}
\usepackage{siunitx}
\begin{document}

\begin{table}[!ht]
\caption{Average error metrics.} 
\label{table1}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{6}{S[table-format=1.3(3)]} }
\toprule
Metric            &\multicolumn{3}{c}{UHFUS} & \multicolumn{3}{c}{HFUS} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
                  & {G1}      & {G2}         & {G3}      & {G1}      & {G2}      & {G3}      \\
\midrule 
D                 & 0.91(1)   & 0.90(1)      & 0.89(1)   & 0.91(1)   & 0.91(2)   & 0.91(2)   \\
H\,(\si{\mm})     & 0.097(19) & 0.092(19)    & 0.105(20) & 0.292(23) & 0.281(65) & 0.273(40) \\
DFP               & {1.35}    & {5}          & {4.93}    & {12.3}    & {5}       & {34.6}    \\
DFN               & {1.35}    & {5}          & {4.93}    & {12.3}    & {5}       & {34.6}    \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

You must log in to answer this question.

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