表格溢出右边距

表格溢出右边距

无法限制表

\documentclass[pdflatex, sn-aps]{sn-jnl}% American Physical Society (APS) Reference Style
%%%% Standard Packages
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage{siunitx}
%%<additional latex packages if required can be included here>
\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{{./images/}}
%Table packages
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\usepackage{booktabs, makecell, multirow, tabularx}
\renewcommand{\theadfont}{\footnotesize\bfseries}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}


\raggedbottom
%%\unnumbered% uncomment this for unnumbered level heads

\begin{document}
\begin{table}
\centering
% table caption is above the table
\caption{Part of the patient data collected via the questionnaire}
\label{tab:Patient data}       % Give a unique label
% For LaTeX tables use
\begin{tabular} {           c
                            c
                            c
                            c
                            c
                            c
                            c
                            c
                            c
                             }
\toprule
\thead{Patient\\Number} &\thead{$T_{before}$\\(week1)} & \thead{$T_{after}$\\(week1)}& \thead{$C_{week1}$}
& \thead{$C_{week2}$}& \thead{$C_{week3}$}& \thead{$C_{week4}$}& \thead{Overall\\improvement}&\thead{$T_{after}$\\(week4)}\\
\midrule\\
1&41&34&17.07&17.26&20.62&23.67&6.60&32 \\
\addlinespace
2&41&41&0.00&3.49&6.47&7.16&7.16&35 \\
\addlinespace
3&41&34&17.07&18.88&19.87&21.12&4.05&30 \\
\addlinespace
4&89&88&1.12&3.27&6.13&8.30&7.18&81 \\
\addlinespace
12&50&50&0.00&0.00&0.00&0.00&0.00&50 \\
\bottomrule
\end{tabular}
\end{table}
 \end{document} 

输出

答案1

我建议您缩短标题条目(例如,将“week”缩写为“wk”,使用罗马字母而不是数学斜体字母,并且不要过度使用大胆的字母),使用\setlength\tabcolsep{0pt},并使用tabular*环境。这样,您甚至不需要使用\footnotesize。哦,我会对S表中 9 列中的 5 列使用列类型。

在此处输入图片描述

\documentclass[sn-aps]{sn-jnl}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{comment}
\usepackage[center]{caption}
\usepackage{subcaption}
\usepackage{float}
\usepackage[misc]{ifsym}
\usepackage{csquotes}
\usepackage[section]{placeins}
\usepackage{siunitx} % for 'S' column type

\usepackage{amsmath}
\usepackage{graphicx}
\graphicspath{{./images/}}

\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}
\usepackage{booktabs, makecell, multirow, tabularx}
\renewcommand{\theadfont}{\normalfont}
\renewcommand\theadgape{}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\raggedbottom

\begin{document}
\begin{table}
\setlength\tabcolsep{0pt} % let LaTeX figure out amount of intercolumn whitespace
\caption{Part of patient data collected via questionnaire}
\label{tab:Patient data}  
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} 
     S[table-format=2.0]
     cc 
     *{4}{S[table-format=2.2]} 
     cc }
\toprule
{\thead{Patient\\Number}} &
\thead{$T_{\textrm{before}}$ \\(wk1)} & 
\thead{$T_{\textrm{after}}$  \\(wk1)}& 
$C_{\textrm{wk1}}$& 
$C_{\textrm{wk2}}$& 
$C_{\textrm{wk3}}$& 
$C_{\textrm{wk4}}$& 
\thead{Overall\\improve't}&
\thead{$T_{\textrm{after}}$  \\(wk4)}\\
\midrule
1 &41&34&17.07&17.26&20.62&23.67&6.60&32 \\
2 &41&41& 0.00& 3.49& 6.47& 7.16&7.16&35 \\
3 &41&34&17.07&18.88&19.87&21.12&4.05&30 \\
4 &89&88& 1.12& 3.27& 6.13& 8.30&7.18&81 \\
12&50&50& 0.00& 0.00& 0.00& 0.00&0.00&50 \\
\bottomrule
\end{tabular*}
\end{table}
\end{document}

相关内容