1

I'm using a Springer template, so trying not to add add packages, however, I'm struggling to equally size the column widths. As shown in the image, the final three column widths seem unequal, and I'm not sure what is causing this, or how I might remedy this.

\documentclass[sn-mathphys]{sn-jnl}
\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{bm}
\usepackage{mathrsfs}%
\usepackage[figuresright]{rotating}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{program}%
\usepackage{listings}%
\usepackage{subcaption}
\begin{document}
\begin{table}[ht]
\begin{center}
\begin{minipage}{\textwidth}
\caption{Estimates of the noise standard deviation, and the corresponding reduction in velocity variance, once adjusted for noise, as a function of elevation from the channel bed. Dataset: $\boldsymbol{U_{0}}$ = 0.58 m/s; measurement location = (5, 0, $z$); ADV sampling period per coordinate = 5 min.}
\label{tab:noise_floor_as_a_function_elevation_0211-0215}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ccccccc}
\toprule
\multirow{2}{*}{z [m]}
& \multicolumn{3}{c}{Noise standard deviation [ms$^{-1}$]}
& \multicolumn{3}{c}{Variance reduction due to noise [\%]} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
 & $u$ & $v$ & $w$ & $u$ & $v$ & $w$ \\
\midrule
0.400   & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   77.8  &  20.5  \\
0.300   & 1.1e$^{-2}$  & 1.1e$^{-2}$   & 2.5e$^{-3}$   & 63.9  &   84.1  &  27.9  \\
0.200   & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.9  &   83.8  &  24.2  \\
0.100   & 9.5e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.0  &   76.5  &  20.9  \\
0     & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 60.6  &   80.0  &  21.4  \\
-0.100  & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 53.3  &   78.0  &  19.9  \\
-0.200  & 9.6e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 50.3  &   73.4  &  16.8  \\
-0.300  & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 51.5  &   59.8  &  13.6  \\
-0.385  & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   66.0  &  16.8  \\
\botrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\end{document}

enter image description here

5
  • Welcome to TeX:SE! Please extend your code fragment to complete small document with your table, called MWE: Minimal Working Example, that we can simply test it and than help you. Help us to help you!
    – Zarko
    Mar 20 at 10:22
  • BTW, with your code fragment I can't reproduce showed table. Please clarify, what is your problem.
    – Zarko
    Mar 20 at 10:31
  • Ok I've added a short preamble to the code. The problem is that the three rightmost columns are not equal. Ideally, all columns would have the same width.
    – eg0u30a2
    Mar 20 at 10:39
  • 1
    Sorry, where is added preamble? It start with \documentclass and end with \begin{document} ... I don't see anything like this. Regarding changes question title, you may consider to use tabularx table.
    – Zarko
    Mar 20 at 11:03
  • ok, thanks for the guidance, however, I'm working with a pre-defined journal template, and I'm reluctant to add more packages, like tabularx. Hopefully my preamble is more clear now.
    – eg0u30a2
    Mar 20 at 11:28

3 Answers 3

2

You may liked:

enter image description here

Edit:
Original MWE is now extended with preamble which OP show in question. Preamble is wee bit changed since packages amsmath and booktabs are now loadead as tblr libraries, as already stated in original answer (dee sentence below). Result is the same as before.

With use of the tabularray package with libraries booktabs and siunitx (which loads packages of the same name):

\documentclass[sn-mathphys]{sn-jnl}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{%amsmath,       % <--- moved to tblr library
            amssymb,
            %amsfonts,      % <--- loaded by amssymb
            amsthm}
\usepackage{bm}
\usepackage{mathrsfs}
\usepackage[figuresright]{rotating}
\usepackage[title]{appendix}
\usepackage{xcolor}
\usepackage{textcomp}
\usepackage{manyfoot}
%\usepackage{booktabs}      % <--- moved to tblr library
\usepackage{algorithm}
\usepackage{algorithmicx}
\usepackage{algpseudocode}
\usepackage{program}
\usepackage{listings}
\usepackage{subcaption}
% new, some packages are moved here as tblr library
\usepackage{tabularray}     % <--- new
\UseTblrLibrary{amsmath, booktabs, 
                siunitx}    % <--- new

\begin{document}
    \begin{table}[ht]
    \centering
    \sisetup{tight-spacing}
    \caption{Estimates of the noise standard deviation, and the corresponding reduction in velocity variance, once adjusted for noise, as a function of elevation from the channel bed. Dataset: $\bm{U}_0 = \qty{0.58}{\meter\per\second}/s$; measurement location: (5, 0, $z$); ADV sampling period per coordinate: \qty{5}{\minute}.}
    \label{tab:noise_floor_as_a_function_elevation_0211-0215}
\begin{tblr}{colspec = {@{} X[c, si={table-format=-1.3}]
                        *{3}{X[c, si={table-format= 1.1e1}]}
                        *{3}{X[c, si={table-format= 2.2}]}
                       },
             row{1,2}= {guard},
             row{2}  = {mode=math}  
             }
    \toprule
\SetCell[r=2]{c}    z [m] 
    &   \SetCell[c=3]{c}    Noise standard deviation [\unit{\meter\per\second}]
        &   &   &   \SetCell[c=3]{c}    Variance reduction due to noise [\%] 
                    &   &       \\
    \cmidrule[r]{2-4} \cmidrule[l]{5-7}
    & u & v & w & u & v & w     \\
    \midrule
0.400   & 9.7e-3    & 1.0e-2    & 2.2e-3    & 53.2  & 77.8  & 20.5  \\
    \bottomrule
0.300   & 1.1e-2    & 1.1e-2    & 2.5e-3    & 63.9  & 84.1  & 27.9  \\
0.200   & 9.3e-3    & 1.0e-2    & 2.1e-3    & 59.9  & 83.8  & 24.2  \\
0.100   & 9.5e-3    & 1.0e-2    & 2.1e-3    & 59.0  & 76.5  & 20.9  \\
0       & 9.9e-3    & 1.0e-2    & 2.2e-3    & 60.6  & 80.0  & 21.4  \\
-0.100  & 9.3e-3    & 1.0e-2    & 2.1e-3    & 53.3  & 78.0  & 19.9  \\
-0.200  & 9.6e-3    & 1.0e-2    & 2.2e-3    & 50.3  & 73.4  & 16.8  \\
-0.300  & 9.9e-3    & 1.0e-2    & 2.2e-3    & 51.5  & 59.8  & 13.6  \\
-0.385  & 9.7e-3    & 1.0e-2    & 2.2e-3    & 53.2  & 66.0  & 16.8  \\
    \bottomrule
\end{tblr}
\end{table}
\end{document}

Addendum: in the case that you prefer to have exponent numbers in form e^{-...}, than you only need to change column specification of the first column group, i.e. table preamble is:

\begin{tblr}{colspec = {@{}  X[c, si={table-format=-1.3,
                                      minimum-decimal-digits=3}]
                        *{3}{X[c, si={table-format= 1.1e1,
                                      exponent-product = {},        % <---
                                      exponent-base = \mathrm{e}}]} % <---
                        *{3}{X[c, si={table-format= 2.2}]}
                       },
             row{1,2}= {guard},
             row{2}  = {mode=math}  
             }

an table than become:

enter image description here

5
  • thank you for this, but the document will not compile when I copy your code. There are too many errors. I tried your code on a blank template, and the code worked, so I suspect there may be conflicts with other packages that I have, but I'm unable to diagnose the issue.
    – eg0u30a2
    Mar 20 at 16:32
  • @eg0u30a2, I tested my proposition with preamble which you show in figure. No errors. That you will be able to confirm my claims, I add your preamble to my MWE.
    – Zarko
    Mar 20 at 16:33
  • is there another way to do this without amending the list of packages in the preamble? I would only like to use the tabular package if possible
    – eg0u30a2
    Mar 20 at 16:45
  • 1
    It's a pity because tabularray is likely to become a standard because its interface is so intuitive
    – projetmbc
    Mar 20 at 16:48
  • 2
    Of course are other ways too, but to my opinion no so elegant/simple. Apparently will wait on other answer ... good luck!
    – Zarko
    Mar 20 at 17:03
1

As a minimal invasive change to make your columns equally spaced, you could use fixed width columns:

\documentclass[sn-mathphys]{sn-jnl}
\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{bm}
\usepackage{mathrsfs}%
\usepackage[figuresright]{rotating}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{program}%
\usepackage{listings}%
\usepackage{subcaption}
\begin{document}
\begin{table}[ht]
\begin{center}
\begin{minipage}{\textwidth}
\caption{Estimates of the noise standard deviation, and the corresponding reduction in velocity variance, once adjusted for noise, as a function of elevation from the channel bed. Dataset: $\boldsymbol{U_{0}}$ = 0.58 m/s; measurement location = (5, 0, $z$); ADV sampling period per coordinate = 5 min.}
\label{tab:noise_floor_as_a_function_elevation_0211-0215}
\begin{tabular*}{\textwidth}{@{}*{7}{p{.111\textwidth}}@{}}
\toprule
\multirow{2}{*}{z [m]}
& \multicolumn{3}{c}{Noise standard deviation [ms$^{-1}$]}
& \multicolumn{3}{c}{Variance reduction due to noise [\%]} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
 & $u$ & $v$ & $w$ & $u$ & $v$ & $w$ \\
\midrule
0.400   & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   77.8  &  20.5  \\
0.300   & 1.1e$^{-2}$  & 1.1e$^{-2}$   & 2.5e$^{-3}$   & 63.9  &   84.1  &  27.9  \\
0.200   & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.9  &   83.8  &  24.2  \\
0.100   & 9.5e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.0  &   76.5  &  20.9  \\
0     & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 60.6  &   80.0  &  21.4  \\
-0.100  & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 53.3  &   78.0  &  19.9  \\
-0.200  & 9.6e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 50.3  &   73.4  &  16.8  \\
-0.300  & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 51.5  &   59.8  &  13.6  \\
-0.385  & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   66.0  &  16.8  \\
\botrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\end{document}

enter image description here

The columns will look better centred, but this will require the array package (with an up-to-date array package, one could simplify this by using w{c}{.111\textwidth}, but if you are submitting to a journal, I would not bet on an up-to-date array package, but the manual approach shown below should not cause a problem, you are loading much more problematic packages than array)

\documentclass[sn-mathphys]{sn-jnl}
\usepackage{graphicx}%
\usepackage{multirow}%
\usepackage{amsmath,amssymb,amsfonts}%
\usepackage{amsthm}%
\usepackage{bm}
\usepackage{mathrsfs}%
\usepackage[figuresright]{rotating}%
\usepackage[title]{appendix}%
\usepackage{xcolor}%
\usepackage{textcomp}%
\usepackage{manyfoot}%
\usepackage{booktabs}%
\usepackage{algorithm}%
\usepackage{algorithmicx}%
\usepackage{algpseudocode}%
\usepackage{program}%
\usepackage{listings}%
\usepackage{subcaption}
\usepackage{array}
\begin{document}
\begin{table}[ht]
\begin{center}
\begin{minipage}{\textwidth}
\caption{Estimates of the noise standard deviation, and the corresponding reduction in velocity variance, once adjusted for noise, as a function of elevation from the channel bed. Dataset: $\boldsymbol{U_{0}}$ = 0.58 m/s; measurement location = (5, 0, $z$); ADV sampling period per coordinate = 5 min.}
\label{tab:noise_floor_as_a_function_elevation_0211-0215}
\begin{tabular*}{\textwidth}{@{}*{7}{>{\centering\arraybackslash}p{.111\textwidth}}@{}}
\toprule
\multirow{2}{*}{z [m]}
& \multicolumn{3}{c}{Noise standard deviation [ms$^{-1}$]}
& \multicolumn{3}{c}{Variance reduction due to noise [\%]} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
 & $u$ & $v$ & $w$ & $u$ & $v$ & $w$ \\
\midrule
0.400   & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   77.8  &  20.5  \\
0.300   & 1.1e$^{-2}$  & 1.1e$^{-2}$   & 2.5e$^{-3}$   & 63.9  &   84.1  &  27.9  \\
0.200   & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.9  &   83.8  &  24.2  \\
0.100   & 9.5e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 59.0  &   76.5  &  20.9  \\
0     & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 60.6  &   80.0  &  21.4  \\
-0.100  & 9.3e$^{-3}$  & 1.0e$^{-2}$   & 2.1e$^{-3}$   & 53.3  &   78.0  &  19.9  \\
-0.200  & 9.6e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 50.3  &   73.4  &  16.8  \\
-0.300  & 9.9e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 51.5  &   59.8  &  13.6  \\
-0.385  & 9.7e$^{-3}$  & 1.0e$^{-2}$   & 2.2e$^{-3}$   & 53.2  &   66.0  &  16.8  \\
\botrule
\end{tabular*}
\end{minipage}
\end{center}
\end{table}
\end{document}

enter image description here

2
  • thank you kindly, this has solved my problem. One last thing, how would I convert the number format in the 2nd - 4th columns to y x 10^{-z), as opposed to the current format, which I have?
    – eg0u30a2
    Mar 20 at 17:20
  • 1
    @eg0u30a2 If you have a new question, you should ask a new question Mar 20 at 17:25
1

You're loading packages, even more than needed: algorithmicx and algpseudocode are fighting each other; subcaption is not compatible with the used class.

Load also siunitx and compute a suitable width.

\RequirePackage{fix-cm}
\documentclass[sn-mathphys]{sn-jnl}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{mathrsfs}
\usepackage[figuresright]{rotating}
\usepackage[title]{appendix}
\usepackage{xcolor}
%\usepackage{textcomp} % no longer needed
\usepackage{manyfoot} % do you need it?
\usepackage{booktabs}
\usepackage{algorithm}
%\usepackage{algorithmicx}
\usepackage{algpseudocode}
%\usepackage{program} % already loaded by the class, unfortunately
\usepackage{listings}
\usepackage{siunitx}

\sisetup{output-exponent-marker = \mathrm{e}}
\newlength{\tempwd}

\begin{document}

\begin{table}[ht]
\caption{Estimates of the noise standard deviation, and the corresponding 
reduction in velocity variance, once adjusted for noise, as a function of 
elevation from the channel bed. Dataset: $\bm{U}_{0}$ = \qty{0.58}{m/s}; 
measurement location = $(5, 0, z)$; ADV sampling period per coordinate = \qty{5}{min}}
\label{tab:noise_floor_as_a_function_elevation_0211-0215}

\settowidth{\tempwd}{\num{-0.400}}
\setlength{\tempwd}{\dimexpr(\textwidth-1em-\tempwd)/6}
\newcommand{\?}[1]{{\makebox[\tempwd]{#1}}}
\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  S[table-format=-1.3]
  @{\quad}
  *{3}{S[table-format=1.1e-1]}
  *{3}{S[table-format=2.1]}
  @{}
}
\toprule
{z[m]}
& \multicolumn{3}{c}{Noise standard deviation (\unit{ms^{-1}})}
& \multicolumn{3}{c}{Variance reduction due to noise (\%)} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
 & \?{$u$} & \?{$v$} & \?{$w$} & \?{$u$} & \?{$v$} & \?{$w$} \\
\midrule
 0.400   & 9.7e-3  & 1.0e-2   & 2.2e-3   & 53.2  &   77.8  &  20.5  \\
 0.300   & 1.1e-2  & 1.1e-2   & 2.5e-3   & 63.9  &   84.1  &  27.9  \\
 0.200   & 9.3e-3  & 1.0e-2   & 2.1e-3   & 59.9  &   83.8  &  24.2  \\
 0.100   & 9.5e-3  & 1.0e-2   & 2.1e-3   & 59.0  &   76.5  &  20.9  \\
 0       & 9.9e-3  & 1.0e-2   & 2.2e-3   & 60.6  &   80.0  &  21.4  \\
-0.100   & 9.3e-3  & 1.0e-2   & 2.1e-3   & 53.3  &   78.0  &  19.9  \\
-0.200   & 9.6e-3  & 1.0e-2   & 2.2e-3   & 50.3  &   73.4  &  16.8  \\
-0.300   & 9.9e-3  & 1.0e-2   & 2.2e-3   & 51.5  &   59.8  &  13.6  \\
-0.385   & 9.7e-3  & 1.0e-2   & 2.2e-3   & 53.2  &   66.0  &  16.8  \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

enter image description here

I define a local command for the column headers, so they fix the common width of the columns.

1
  • thanks for this. The packages are pre-defined in the journal template, and they can quite funny about adding and modifying the package list. I opted for the solution posted by @samcarter_is_at_topanswers.xyz as it was more non-invasive.
    – eg0u30a2
    Mar 21 at 16:52

You must log in to answer this question.

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