我确信这个问题之前在某个地方已经得到解决,但我很难找到答案,非常感谢您的帮助。我尝试在各个地方插入 \centering 或使用 center 环境,但似乎无法找到答案。
我试图将表格置于页面中央,但使用 threeparttable 似乎会将表格推到左侧 - 导致其在左边距之后立即开始。我希望表格与页面左边缘之间的距离等于表格与页面右边缘之间的距离。以下是我当前设置的示例:
\documentclass[authoryear, review, 12pt, times]{elsarticle}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{setspace} % has commands for singlespacing, onehalfspacing, and doublespacing
\usepackage{mathrsfs}
\usepackage{IEEEtrantools}
%\usepackage{multirow}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{tabu}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} % These 3 lines define new column types mainly to allow for centered column of user defined width
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
%\pagenumbering{gobble} % Supresses page number
\begin{document}
\begin{table}[ht!]
\begin{threeparttable}
\bfseries{\footnotesize{Table 1. Test Table.}} \\ [2mm]
\scriptsize
\normalfont
\begin{tabular}[pos]{L{7.0cm} R{2.0cm}}
\toprule
\multicolumn{2}{c}{Dependent Variable: Outcome Var} \\
\midrule
$Variable 1$ & 0.123 \\
& (1.00) \\ [1.5mm]
$Variable 2$ & 0.456 \\
& (1.65) \\ [1.5mm]
$Variable 3$ & 0.789 \\
& (1.96) \\ [1.5mm]
$Variable 4$ & 1.123 \\
& (2.59) \\ [1.5mm]
$Variable 5$ & 1.456 \\
& (3.00) \\ [1.5mm]
$Variable 6$ & 1.789 \\
& (3.20) \\ [1.5mm]
$Variable 7$ & 2.000 \\
& (3.50) \\ [10.0mm]
Some Info & Yes \\ [0.5mm]
Other Info & No \\ [0.5mm]
Observations & Ample \\ [0.5mm]
Random Statistic & 1,505.37 \\ [0.5mm]
Last Piece of Info & 100.00 \\
\bottomrule
\end{tabular}
\centering
\caption{
\normalfont{\textnormal{This table displays information. It is just being used to see if I can actually center this thing, which has proved more difficult than anticipated. }}}
\label{tab:Test}
\end{threeparttable}
\end{table}
\end{document}
答案1
您的代码有两个问题:
和之间没有
\centering
指令。\begin{table}
\begin{threeparttable}
环境
threeparttable
有三个 [惊喜!] 正式组成部分:标题、tabular
(或tabular*
、或tabularx
等)环境和tablenotes
环境。考虑到这一点,指令\bfseries{\footnotesize{Table 1. Test Table.}} \\ [2mm]
不合适。您应该将其移除或合并到环境中
tabular
。
通过这两项调整,您的格式化目标将立即实现。
答案2
\documentclass[authoryear, review, 12pt, times]{elsarticle}
\usepackage[top=1in, bottom=1in, left=1in, right=1in]{geometry}
\usepackage{setspace} % has commands for singlespacing, onehalfspacing, and doublespacing
\usepackage{mathrsfs}
\usepackage{IEEEtrantools}
%\usepackage{multirow}
\usepackage{booktabs}
\usepackage{threeparttable}
\usepackage{array}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{tabu}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash}p{#1}} % These 3 lines define new column types mainly to allow for centered column of user defined width
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash}p{#1}}
%\pagenumbering{gobble} % Supresses page number
\begin{document}
\oddsidemargin = 4cm
\begin{table}[ht!]
\begin{threeparttable}
\bfseries{\footnotesize{Table 1. Test Table.}} \\ [2mm]
\scriptsize
\normalfont
\begin{tabular}[pos]{L{7.0cm} R{2.0cm}}
\toprule
\multicolumn{2}{c}{Dependent Variable: Outcome Var} \\
\midrule
$Variable 1$ & 0.123 \\
& (1.00) \\ [1.5mm]
$Variable 2$ & 0.456 \\
& (1.65) \\ [1.5mm]
$Variable 3$ & 0.789 \\
& (1.96) \\ [1.5mm]
$Variable 4$ & 1.123 \\
& (2.59) \\ [1.5mm]
$Variable 5$ & 1.456 \\
& (3.00) \\ [1.5mm]
$Variable 6$ & 1.789 \\
& (3.20) \\ [1.5mm]
$Variable 7$ & 2.000 \\
& (3.50) \\ [10.0mm]
Some Info & Yes \\ [0.5mm]
Other Info & No \\ [0.5mm]
Observations & Ample \\ [0.5mm]
Random Statistic & 1,505.37 \\ [0.5mm]
Last Piece of Info & 100.00 \\
\bottomrule
\end{tabular}
\centering
\caption{
\normalfont{\textnormal{This table displays information. It is just being used to see if I can actually center this thing, which has proved more difficult than anticipated. }}}
\label{tab:Test}
\end{threeparttable}
\end{table}
\end{document}
% 我所做的是添加\oddsiemargin =4cm
。桌子结束后,必须设置\oddsidemargin=0