将表格置于双列页面的中央,超出文本限制

将表格置于双列页面的中央,超出文本限制

我在一份双列文档中有一个“超大”表格,我想将其置于页面中央。但是,我无法使用\centering或使其工作\begin{center}。我添加了一个示例文档以及 jlmr2e.sty。

我如何确保此表和其他类似的表居中?

\documentclass{article}

\usepackage{multicol}
\usepackage{jmlr2e}
\usepackage{enumitem}
\usepackage{dblfloatfix}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage{needspace}
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{threeparttable}
\usepackage{adjustbox}
\captionsetup{labelfont=bf,
              justification=raggedright,
              singlelinecheck=false}
\usepackage{lipsum}

% Definitions of handy macros can go here

\pagestyle{fancy}
\fancyhf{}
\lhead{\footnotesize {T Stack | An example document}}
\cfoot{\thepage}

\newcommand{\dataset}{{\cal D}}
\newcommand{\fracpartial}[2]{\frac{\partial #1}{\partial  #2}}

\begin{document}
\begin{multicols}{2}
\begin{table*}[]
\begin{adjustbox}{width=1.12\textwidth}
\begin{threeparttable}
\begin{center}
\caption{Patient characteristics.}
\begin{tabular}{lllll|lll}
\hline
\multicolumn{5}{c}{Temporal} & \multicolumn{3}{l|}{Model} \\ \hline
 & All & \begin{tabular}[c]{@{}l@{}}Discharged \\ (no ICU)\end{tabular} & \begin{tabular}[c]{@{}l@{}}Discharged \\ after ICU\end{tabular} & Deceased & All & \begin{tabular}[c]{@{}l@{}}Essential \\ Hosp.\end{tabular} & \begin{tabular}[c]{@{}l@{}}Non-essential \\ Hosp.\end{tabular} \\ \hline
Female (\%) & 349 (38.3) & 318 (38.9) & 24 (33.8) & 7 (30.4) & 576 (39.6) & \textbf{501 (38.5)} & \textbf{75 (48.7)} \\
Age & 59.3 (14.0) & \textbf{59.0 (14.2)} & \textbf{60.0 (11.3)} & \textbf{68.6 (8.8)} & 63.7 (15.1) & \textbf{64.3 (14.5)} & \textbf{58.5 (18.4)} \\
Tocilizumab (\%) & 5 (0.6) & 4 (0.5) & 1 (1.5) & 0 (0.0) & 6 (0.4) & 6 (0.5) & 0 (0.0) \\ \hline
\end{tabular}
\end{center}
\end{threeparttable}
\end{adjustbox}
\label{pick_LOS}
\end{table*}

Example filler text

\end{multicols}
\end{document}

和 jlmr2e.sty:

% Change the overall width of the page.  If these parameters are
%       changed, they will require corresponding changes in the
%       maketitle section.
%
\renewcommand{\topfraction}{0.95}   % let figure take up nearly whole page
\renewcommand{\textfraction}{0.05}  % let figure take up nearly whole page

% Specify the dimensions of each page

\oddsidemargin .0in    %   Note \oddsidemargin = \evensidemargin
\evensidemargin .0in
\marginparwidth 0.07 true in
%\marginparwidth 0.75 true in
%\topmargin 0 true pt           % Nominal distance from top of page to top of
%\topmargin 0.125in
\topmargin -0.5in
\addtolength{\headsep}{0.25in}
\textheight 8.5 true in       % Height of text (including footnotes & figures)
\textwidth 6.5 true in        % Width of text line.
\widowpenalty=10000
\clubpenalty=10000
\@twosidetrue \@mparswitchtrue \def\ds@draft{\overfullrule 5pt}

答案1

如果您能确保表格适合可用空间,则无需允许表格溢出到边距。以下 MWE 显示了如何确保表格的宽度与文本宽度完全相同:

在此处输入图片描述

\documentclass{article}
\usepackage{multicol}
\usepackage{jmlr2e}
\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{threeparttable}
\usepackage{adjustbox}
\captionsetup{labelfont=bf,
              justification=raggedright,
              singlelinecheck=false}

\usepackage{makecell}

\begin{document}
\begin{multicols}{2}
\begin{table*}
\begin{threeparttable}
\small
\setlength{\tabcolsep}{0pt}
\caption{Patient characteristics.}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}lllll lll}
\toprule
& \multicolumn{4}{c}{Temporal} & \multicolumn{3}{c}{Model} \\ 
\cmidrule(lr){2-5} \cmidrule(lr){6-8}
 & \thead{All} & \thead{Discharged \\ (no ICU)} & \thead{Discharged \\ after ICU} & \thead{Deceased} & \thead{All} & \thead{Essential \\ Hosp.} & \thead{Non-essential \\ Hosp.} \\ \midrule
Female (\%)      & 349 (38.3)  & 318 (38.9)           & 24 (33.8)            & 7 (30.4)            & 576 (39.6)  & \textbf{501 (38.5)}  & \textbf{75 (48.7)}   \\
Age              & 59.3 (14.0) & \textbf{59.0 (14.2)} & \textbf{60.0 (11.3)} & \textbf{68.6 (8.8)} & 63.7 (15.1) & \textbf{64.3 (14.5)} & \textbf{58.5 (18.4)} \\
Tocilizumab (\%) & 5 (0.6)     & 4 (0.5)              & 1 (1.5)              & 0 (0.0)             & 6 (0.4)     & 6 (0.5)              & 0 (0.0)              \\ 
\bottomrule
\end{tabular*}
\end{threeparttable}
\label{pick_LOS}
\end{table*}

Example filler text

\end{multicols}
\end{document}

答案2

您需要adjustwidth来自 changepage package *not* theadjustbox environment from theadjustbox` 包的环境。

% multicolprob.tex  SE 611887

\documentclass{article}

\usepackage{multicol}
%\usepackage{jmlr2e}   %%% see below
\usepackage{enumitem}
\usepackage{dblfloatfix}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{array}
\usepackage[utf8]{inputenc}
\usepackage{needspace}
\usepackage{afterpage}
\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{caption}
\usepackage{threeparttable}
\usepackage{adjustbox}
\captionsetup{labelfont=bf,
              justification=raggedright,
              singlelinecheck=false}
\usepackage{lipsum}

%%%%%%%%%%%%%%%%%%%%% jlmr2e.sty

% Change the overall width of the page.  If these parameters are
%       changed, they will require corresponding changes in the
%       maketitle section.
%
\renewcommand{\topfraction}{0.95}   % let figure take up nearly whole page
\renewcommand{\textfraction}{0.05}  % let figure take up nearly whole page

% Specify the dimensions of each page

\oddsidemargin .0in    %   Note \oddsidemargin = \evensidemargin
\evensidemargin .0in
\marginparwidth 0.07 true in
%\marginparwidth 0.75 true in
%\topmargin 0 true pt           % Nominal distance from top of page to top of
%\topmargin 0.125in
\topmargin -0.5in
\addtolength{\headsep}{0.25in}
\textheight 8.5 true in       % Height of text (including footnotes & figures)
\textwidth 6.5 true in        % Width of text line.
\widowpenalty=10000
\clubpenalty=10000
\makeatletter
\@twosidetrue \@mparswitchtrue \def\ds@draft{\overfullrule 5pt}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Definitions of handy macros can go here

\pagestyle{fancy}
\fancyhf{}
\lhead{\footnotesize {T Stack | An example document}}
\cfoot{\thepage}

\newcommand{\dataset}{{\cal D}}
\newcommand{\fracpartial}[2]{\frac{\partial #1}{\partial  #2}}

\usepackage{changepage}


\begin{document}
\begin{multicols}{2}
\begin{table*}%[]
%\begin{adjustbox}{width=1.12\textwidth}
%\begin{adjustbox}{width=0.8\textwidth}
\begin{adjustwidth}{-1cm}{-1cm}
\begin{threeparttable}
%\begin{center}
\centering
\caption{Patient characteristics.}
\begin{tabular}{lllll|lll}
\hline
\multicolumn{5}{c}{Temporal} & \multicolumn{3}{l|}{Model} \\ \hline
 & All & \begin{tabular}[c]{@{}l@{}}Discharged \\ (no ICU)\end{tabular} & \begin{tabular}[c]{@{}l@{}}Discharged \\ after ICU\end{tabular} & Deceased & All & \begin{tabular}[c]{@{}l@{}}Essential \\ Hosp.\end{tabular} & \begin{tabular}[c]{@{}l@{}}Non-essential \\ Hosp.\end{tabular} \\ \hline
Female (\%) & 349 (38.3) & 318 (38.9) & 24 (33.8) & 7 (30.4) & 576 (39.6) & \textbf{501 (38.5)} & \textbf{75 (48.7)} \\
Age & 59.3 (14.0) & \textbf{59.0 (14.2)} & \textbf{60.0 (11.3)} & \textbf{68.6 (8.8)} & 63.7 (15.1) & \textbf{64.3 (14.5)} & \textbf{58.5 (18.4)} \\
Tocilizumab (\%) & 5 (0.6) & 4 (0.5) & 1 (1.5) & 0 (0.0) & 6 (0.4) & 6 (0.5) & 0 (0.0) \\ \hline
\end{tabular}
%\end{center}
\end{threeparttable}
%\end{adjustbox}
\end{adjustwidth}
\label{pick_LOS}
\end{table*}

Example filler text

\end{multicols}
\end{document}

另外,\centering不要使用center浮点数内的环境。

此外,这jmlr2e似乎与桌子的摆放没有关系。

相关内容