在双列文档中表格溢出列宽(svjour3)

在双列文档中表格溢出列宽(svjour3)

我尝试在 springer svjour3 格式下在一列内写入以下简单表格。它不仅溢出了列,还产生了很多坏框。我分别尝试在 tabular 和 tabularx 下使用 l/c/r/manual 宽度规范,但没有成功。

\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}

请帮忙。

答案1

像这样?

埃迪德: 参考数据已更改:

在此处输入图片描述

  • 减小了列标题的字体大小
  • 最后一列使用包S中定义的列类型\siunitx
  • 删除\tabcolsep 表格前面和末尾的部分
  • 启用多行单元格内容
\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}

笔记:如果您不喜欢使用siunitx软件包和 SI 单位系统,那么只需在序言中删除此软件包,S[table-format=2.2]并在表格标题中用所需的列类型替换(例如c,等等)。这取决于个人喜好,即基于意见。无论如何,表格不会溢出列,正如您在问题中问到的那样。

答案2

我会通过使用更少的大胆的毕竟,表格很小——读者不可能对什么是表头内容、什么是表格“主体”感到困惑。

文档svjour3类对于标题应该是什么样子有一些特定的想法,这些想法与captionsubcaption包的想法不兼容。因此,我不会加载这两个包。

在此处输入图片描述

\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}

答案3

在此处输入图片描述

\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}

相关内容