2

I am trying to write the following simple table within one column under springer svjour3 format. It is not only overflowing the column but also producing lots of bad boxes. I have tried with l/c/r/manual width specification under tabular and tabularx respectively without success.

\documentclass[twocolumn]{svjour3}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\usepackage{makecell}
\renewcommand{\theadfont}{\bfseries}

\begin{document}

%%%%%%%%%%%%%%%%% Accuracy comparison %%%%%%%%%%%%%%%%%%%%%%
\begin{table}
% table caption is above the table
\caption{Accuracy comparison with similar approaches}
\label{tab:accuracy comparison}       % Give a unique label
% For LaTeX tables use
\begin{tabularx}{\linewidth}{>{\raggedright\arraybackslash}p{0.5in}
                            >{\raggedright\arraybackslash}p{0.75in}
                            >{\raggedright\arraybackslash}p{0.75in}
                            X
                             }
\toprule
\thead{Reference} &\thead{ Learning\\approach} & \thead{Initial\\movement}& \thead{Accuracy\\claimed(\%)}\\
\midrule\\
\textbf{[1]} & KNN(K=1) & Walking/running & 93\\
\addlinespace
\textbf{[2]} & Threshold & Walking & 72\\
\addlinespace
\textbf{[3]} & Threshold & Walking & 87.5\\
\addlinespace
\textbf{Implemented system} & Threshold & Walking & 94.45\\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

Please help.

5
  • Please provide a minimal working example following the demands you find here: tex.meta.stackexchange.com/q/228/231952, so that we can better understand the problem you are encountering.
    – Ivan
    Commented Mar 29, 2021 at 11:10
  • As Ivan said you should provide a complete MWE but you are bound to get bad boxes with that code since you are using tabularx without X columns.
    – campa
    Commented Mar 29, 2021 at 11:12
  • @Bukaida -- I do not have the document class svjour3 -- using multicol -- please see the answer below
    – js bibra
    Commented Mar 29, 2021 at 11:13
  • Modified the OP into MWE. Adding 'X' column did not have any effect on appearance apparently
    – Bukaida
    Commented Mar 29, 2021 at 11:37
  • In fact replacing 'c' with 'X' for the last column, made the header alignment unbalanced.
    – Bukaida
    Commented Mar 29, 2021 at 11:48

3 Answers 3

3

Like this?

Edid: with changed reference data:

enter image description here

  • reduced is font size in column headers
  • for last column is used S column type defined in the \siunitx package
  • remove \tabcolsep at front and the end of table
  • enable multi lines cells' contents
\documentclass[twocolumn]{svjour3}
\usepackage{caption}
\usepackage{booktabs, makecell, tabularx}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\usepackage{siunitx}

\usepackage{lipsum}

\begin{document}
\lipsum[1]
%%%%%%%%%%%%%%%%% Accuracy comparison %%%%%%%%%%%%%%%%%%%%%%
\begin{table}[ht]
% table caption is above the table
\caption{Accuracy comparison with similar approaches}
\label{tab:accuracy comparison}       % Give a unique label
% For LaTeX tables use
\renewcommand\tabularxcolumn[1]{m{#1}}
\renewcommand\arraystretch{1.2}
\begin{tabularx}{\linewidth}{@{} >{\bfseries}X X X S[table-format=2.2] @{}}
    \toprule
\thead{Reference} 
                &\thead{ Learning\\approach} 
                    & \thead{Initial\\movement}
                        & {\thead{Accuracy\\claimed (\%)}}   \\
    \midrule
{[1]}       & KNN(K=1) & Walking/ running & 93\\
{[2]}       & Threshold & Walking & 72\\
{[3]}       & Threshold & Walking & 87.5\\
Our system  & Threshold & Walking & 94.45\\
    \bottomrule
\end{tabularx}
    \end{table}
\lipsum[2-7]
\end{document}

Note: if you not like to use siunitx package and SI units systems, than simple delete this package in preamble in replace S[table-format=2.2] in table headers with desired column type (for example c, etc.). This mater of personal preferences, i.e. it is opinion based. In any case, tabel not spill out of column, as you asked in question.

2
  • 90% as per expectation, however, is it possible to avoid \usepackage{siunitx} and still get a similar result? Also the word "Implemented" in the last record may be substituted by "Our", if it gives better look.
    – Bukaida
    Commented Mar 29, 2021 at 12:36
  • 1
    @Bukaida, you can make these changes yourself :-). If you not like S column type, you use anyone else (for example c), however, to my opinion S gives the nicer alignment of numbers.
    – Zarko
    Commented Mar 29, 2021 at 12:41
4

I would simplify and streamline the look of the table by using much less bold-facing. AFter all, the table is quite small -- there's no chance the readers will become confused over what's the header material and what's the "body" of the table.

The svjour3 document class has some particular idea about captions are supposed to look like, and these ideas are not compatible with those of the caption and subcaption packages. Hence, I wouldn't load these two packages.

enter image description here

\documentclass[twocolumn]{svjour3}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{tabularx,booktabs}

\newcolumntype{P}[1]{>{\raggedright\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newlength\mylenA \settowidth\mylenA{Implemented}
\newlength\mylenB \settowidth\mylenB{KNN ($K=1$)}
\newlength\mylenC \settowidth\mylenC{movement}

\begin{document}

\begin{table}
\setlength\tabcolsep{4pt} % default value: 6pt
\caption{Accuracy comparison with similar approaches}
\label{tab:accuracy comparison} 

\begin{tabularx}{\linewidth}{@{} P{\mylenA} P{\mylenB} P{\mylenC} C @{}}
\toprule
Reference &
Learning approach & 
Initial movement  & 
Accuracy claimed~(\%) \\
\midrule
{[1]} & KNN ($K=1$) & Walking\slash running & 93\phantom{.00}\\
{[2]} & Threshold & Walking & 72\phantom{.00}\\
{[3]} & Threshold & Walking & 87.5\phantom{0}\\
Implemented system & Threshold & Walking & 94.45 \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
-1

enter image description here

\documentclass[10pt]{scrartcl}
\usepackage[margin=25mm,paper=a4paper]{geometry}
\usepackage{booktabs}
\usepackage[colaction]{multicol}
\usepackage{setspace}
\usepackage{lipsum}
\usepackage{graphicx, array, tabularx, booktabs, makecell}
\title{Table formatting}
\author{The geniuses at SE}

\begin{document}
    \maketitle
    \doublespacing
    
    \begin{multicols}{2}
        
        \section{Introduction}      
        \lipsum[1-1]
        \noindent
        \begin{minipage}{\columnwidth}
                \begin{tabular}
                    {p{0.5in}p{0.75in}p{0.75in}p{0.75in}}
                    \toprule
                    \thead{Reference} &\thead{ Learning\\approach} & \thead{Initial\\movement}& \thead{Accuracy\\claimed(\%)}\\
                    \midrule\\
                    \textbf{[1]} & KNN(K=1) & \makecell[l]{Walking/\\running} & 93\\
                    \addlinespace
                    \textbf{[2]} & Threshold & Walking & 72\\
                    \addlinespace
                    \textbf{[3]} & Threshold & Walking & 87.5\\
                    \addlinespace
                    \textbf{\makecell[l]{Implemented \\system}} & \makecell[l]{\\Threshold} & \makecell[l]{\\Walking} & \makecell[l]{\\94.45}\\
                    \bottomrule
                \end{tabular}
        \end{minipage}
        
        \addvspace{\intextsep}
        
        \lipsum[1-2]
        
    \end{multicols}
    
\end{document}

You must log in to answer this question.

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