我正在为我的论文写一份统计报告,我正在努力创建一个表格。该表需要是页面宽度,即跨越我的文档的两列,并且单元格需要对齐。这是我当前使用的代码:
\documentclass[scientificpaper,11pt, twocolumn]{article}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
\usepackage{caption}
\usepackage{textcomp}
\raggedbottom
\usepackage{rotating}
\usepackage{booktabs, makecell}
\usepackage[referable]{threeparttablex}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}
\usepackage{upquote}
\usepackage{balance}
\usepackage{wasysym}
\usepackage{footmisc}
\maketitle
\begin{document}
\begin{figure}[b]\setlength{\hfuzz}{1.1\columnwidth}
\begin{minipage}{\textwidth}
\ttfamily ...
\begin{table}
\caption{Model Specification}
\label{tab:table2}
\raggedright
Fixed Effect and Random Effect Models
\medskip
\setlength\tabcolsep{4pt}
\small
\makegapedcells
\begin{tablularx}{\pagewidth}
\toprule
\thead{Coefficient} & \thead{Estimate} & \thead{STD} & \thead{t-value} & \thead{$P(>|t|)$}\\
\midrule
Intercept & -2.6380 & 28.8535 & -0.0914 & 0.9279 \\
Independent & 31.9893 & 24.0831 & 1.3283 & 0.1956 \\
Female & -44.2676 & 108.4990 & -0.4080 & 0.6866 \\
Financial Expertise & -29.9851 & 39.7247 & -0.7548 & 0.4571 \\
CRO & 6.3840 & 7.3231 & 0.8718 & 0.3913 \\
\bottomrule
\smallskip
\end{tablularx} ...
\end{table}
\end{minipage}
\end{figure}
\end document
目前,表格加载在页面顶部,跨越两列,但是,单元格中的所有数据都挤在左侧,而标题则均匀分布在顶部。
如果有人能提供帮助,我们将不胜感激
答案1
您的文档示例存在很多问题/错误。我怀疑您能否生成显示图像:
table
您在 float 中插入 floatfigure
。较新的版本会这样做。在任何其他环境中都不会插入 float 。- 在序言中,您两次加载某些包并使用不同的选项。
- 您没有定义
tabularx
列规范。 - 目前还不清楚,如何在标题和
tabularx
- 你没有定义
title
\makettitle
必须在“begin{document}”之后- 定义选项在哪里
scientificpaper
?
我猜,你喜欢获得下表:
(红线表示文本边框)
为此,我使用了新的表环境tabullarray
,不幸的是它可能尚未安装在 Overleaf 中。因此,您需要自行将其添加到项目中(为此请求其支持):
\documentclass[11pt, twocolumn]{article}
\usepackage{textcomp}
%\usepackage{wasysym}
%\usepackage{upquote}
%\usepackage{balance}
%\usepackage{footmisc}
%\raggedbottom
%
%\usepackage{rotating}
%\usepackage{booktabs, makecell, tabularx}
%\renewcommand\theadfont{\normalsize}
%\renewcommand\theadgape{}
%\setcellgapes{2pt}
%\newcolumntype{L}{>{\raggedright\arraybackslash}X}
%\usepackage[referable]{threeparttablex}
\usepackage[skip=1ex]{caption}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}
\begin{document}
%\maketitle
\begin{table*}
\caption{Model Specification}
\label{tab:table2}
\centering
\begin{tblr}{colspec={l S[table-format=-2.4] S[table-format= 3.4]
S[table-format=-1.4] S[table-format= 1.4]
},
row{2}={font=\bfseries},
hspan=minimal
}
\SetCell[c=5]{l} Fixed Effect and Random Effect Models \\
\toprule
Coefficient & {{{Estimate}}}
& {{{STD}}} & {{{t-value}}}
& {{{$P(>|t|)$}}} \\
\midrule
Intercept & -2.6380 & 28.8535 & -0.0914 & 0.9279 \\
Independent & 31.9893 & 24.0831 & 1.3283 & 0.1956 \\
Female & -44.2676 & 108.4990 & -0.4080 & 0.6866 \\
Financial Expertise
& -29.9851 & 39.7247 & -0.7548 & 0.4571 \\
CRO & 6.3840 & 7.3231 & 0.8718 & 0.3913 \\
\bottomrule
\end{tblr}
\end{table*}
\end{document}
附录:
您还可以使用标准tabular
表环境:
\documentclass[11pt, twocolumn]{article}
\usepackage{textcomp}
%\usepackage{wasysym}
%\usepackage{upquote}
%\usepackage{balance}
%\usepackage{footmisc}
%\raggedbottom
%
%\usepackage{rotating}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}
\setcellgapes{2pt}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}
%\usepackage[referable]{threeparttablex}
\usepackage[skip=1ex]{caption}
%\usepackage{tabularray}
%\UseTblrLibrary{booktabs, siunitx}
\usepackage{siunitx}
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
\begin{document}
%\maketitle
\begin{table*}
\caption{Model Specification}
\label{tab:table2}
\centering
\begin{tabular}{l S[table-format=-2.4] S[table-format= 3.4]
S[table-format=-1.4] S[table-format= 1.4]
}
\multicolumn{5}{l}{Fixed Effect and Random Effect Models}\\
\toprule
\makecell{Coefficient}
& {\thead{Estimate}}
& {\thead{STD}}
& {\thead{t-value}}
& {\thead{$P(>|t|)$}} \\
\midrule
Intercept & -2.6380 & 28.8535 & -0.0914 & 0.9279 \\
Independent & 31.9893 & 24.0831 & 1.3283 & 0.1956 \\
Female & -44.2676 & 108.4990 & -0.4080 & 0.6866 \\
Financial Expertise
& -29.9851 & 39.7247 & -0.7548 & 0.4571 \\
CRO & 6.3840 & 7.3231 & 0.8718 & 0.3913 \\
\bottomrule
\end{tabular}
\end{table*}
\end{document}
其结果与第一个例子类似(相同):