我有两个表的 LaTeX 代码:
\begin{table}[h]
\scriptsize
\centering
\begin{tabular}{c|c}
\textbf{Brand} & \textbf{Customer Engagement Average} \\ \hline
Apple & 1,937,852.45 \\
Huawei & 156,962.065 \\
Samsung & 174,166.98 \\
\end{tabular}
\caption{Average Brand Customer Engagement}
\label{brand_ce}
%\end{table}
%\begin{table}[h]
\scriptsize
\centering
\begin{tabular}{c|c}
\textbf{Brand} & \textbf{Customer Satisfaction Score Average} \\ \hline
Apple & 3.37 \\
Huawei & 4.049 \\
Samsung & 3.76 \\
\end{tabular}
\caption{Average Brand Customer Satisfaction Score}
\label{brand_sscore}
\end{table}
这些表格相互叠放如下图所示:
我需要将这些表并排放置。
答案1
我建议使用floatrow
和S
第二列的列类型,以便将数字对齐到小数点。请注意,传统上,表格都有自己的标题多于表格,这是由 float row 自动完成的。此外,加载时geometry
,您将拥有更合理的边距(假设您不需要边注)。
\documentclass[11pt]{article}
\usepackage{geometry}
\usepackage{makecell}
\renewcommand{\theadfont}{\small\bfseries}
\usepackage{siunitx}
\usepackage{caption, floatrow}
\begin{document}
\begin{table}[h]
\centering
\setlength{\extrarowheight}{2pt}
\sisetup{table-number-alignment=center, group-separator={,}}
\captionsetup{format=hang, justification=raggedright}
\begin{floatrow}
\ttabbox{\caption{Average Brand Customer Engagement} \label{brand_ce}}%
{\centering\begin{tabular}{r|S[table-format=7.3]}
\textbf{Brand} & {\thead{Customer Engagement\\ Average}} \\ \hline
Apple & 1937852.45 \\
Huawei & 156962.065 \\
Samsung & 174166.98
\end{tabular}}
\qquad
\ttabbox{\caption{Average Brand Customer Satisfaction Score} \label{brand_sscore}}%
{\begin{tabular}{r|S[table-format=1.3]}
\thead[b]{Brand} & {\thead{Customer Satisfaction\\ Score Average}} \\ \hline
Apple & 3.37 \\
Huawei & 4.049 \\
Samsung & 3.76
\end{tabular}}
\end{floatrow}
\end{table}
\end{document}
答案2
从上面的评论来看
\begin{table}[h]
\scriptsize
\centering
\begin{tabular}{c|cc}
\textbf{Brand} & \multicolumn{2}{c}{\textbf{Customer Average}} \\
&\textbf{-Engagement-} &\textbf{-Satisfaction Score-}\\\hline
Apple & 1,937,852.45& 3.37 \\
Huawei & 156,962.065 & 4.049 \\
Samsung & 174,166.98& 3.76 \\
\end{tabular}
\caption{Average Brand Customer Engagement}
\label{brand_ce}
\end{table}