如何正确布局表格并解决文字重叠问题

如何正确布局表格并解决文字重叠问题

我想您可以从代码中看出我对乳胶表格还很陌生。我希望表格看起来像这样,但我遇到了单词重叠的问题。您有什么解决这些问题的技巧吗?以及如何最佳地创建表格?

 \begin{table}[htbp!]
\centering
\toprule\toprule
\caption{\textbf{Difference in Equal-Weighted First-Day Returns Between IPO Cycles}}
\label{table:7.2}

\settowidth{\templength}{\textbf{Subgroups}}
\setlength{\tabcolsep}{\dimexpr(\textwidth-\templength-6cm)/9\relax}

\begin{tabular}{@{} l *{4}{w{c}{0.8cm}@{}w{c}{0.8cm}} @{}}
\toprule
\multicolumn{9}{@{}p{\textwidth}@{}}{%
  The total sample includes 825 IPOs comprising of 171 PE, 182 VC and 472 NS. 
  The table presents the results from testing if the first-day returns across
  all three subgroups are significantly different from zero. The test is
  conducted using a two-sided t-test.} \\
\midrule
\textbf{Subgroups} & \textbf{HMA All} & \textbf{LMA All} & \textbf{HMA PE} & \textbf{LMA PE} & \textbf{HMA VC} & \textbf{LMA VC} & \textbf{HMA NS} & \textbf{LMA NS} \\
\midrule
Mean (\%) & 11 & 3 & 10 & 3 & 9 & 4 & 12 & 4 \\
P-Value & \multicolumn{2}{c}{0.028} & \multicolumn{2}{c}{0.123} & \multicolumn{2}{c}{0.350} & \multicolumn{2}{c}{0.098} \\
\bottomrule\bottomrule
\end{tabular}

\end{table}

该表如下所示: 在此处输入图片描述

答案1

关键是将标题分成两行并重叠空白处。

我伪造了\toprule\toprule使用\hrule\vskip。我计算了最大列宽,并使用\makebox设置列宽和重叠标题。

演示

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

\newlength{\templength}

\begin{document}

\begin{table}[htp]
\hrule height\heavyrulewidth\vskip\doublerulesep\hrule height\heavyrulewidth
\abovecaptionskip=1ex
\caption{\textbf{Difference in Equal-Weighted First-Day Returns Between IPO Cycles}}
\label{table:7.2}

\settowidth{\templength}{\textbf{Subgroups}}%
\setlength{\templength}{\dimexpr(\textwidth-\templength-16\tabcolsep)/8}% max column width

\centering
\begin{tabular}{@{} l rl rl rl rl @{}}
\toprule
\multicolumn{9}{@{}p{\textwidth}@{}}{%
  The total sample includes 825 IPOs comprising of 171 PE, 182 VC and 472 NS. 
  The table presents the results from testing if the first-day returns across
  all three subgroups are significantly different from zero. The test is
  conducted using a two-sided t-test.} \\
\midrule
\textbf{Subgroups} & \makebox[\templength][l]{\textbf{HMA All}} && \makebox[\templength][l]{\textbf{HMA PE}}
 && \makebox[\templength][l]{\textbf{HMA VC}} && \makebox[\templength][l]{\textbf{HMA NS}} \\
 && \makebox[\templength][r]{\textbf{LMA All}} && \makebox[\templength][r]{\textbf{LMA PE}}
 && \makebox[\templength][r]{\textbf{lMA VC}} && \makebox[\templength][r]{\textbf{LMA NS}} \\
\midrule
Mean (\%) & 11 & 3 & 10 & 3 & 9 & 4 & 12 & 4 \\
P-Value & \multicolumn{2}{c}{0.028} & \multicolumn{2}{c}{0.123} & \multicolumn{2}{c}{0.350} & \multicolumn{2}{c}{0.098} \\
\bottomrule\bottomrule
\end{tabular}
\end{table}

\end{document}

再想想,把标题放在表格里更简单。我就不让你担心标题跳动了。

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}

\newlength{\templength}

\begin{document}

\begin{table}[htp]
\settowidth{\templength}{\textbf{Subgroups}}%
\setlength{\templength}{\dimexpr(\textwidth-\templength-16\tabcolsep)/8}% max column width
\centering
\begin{tabular}{@{} l rl rl rl rl @{}}
\toprule\toprule
\multicolumn{9}{@{}p{\textwidth}@{}}{%
\caption{\textbf{Difference in Equal-Weighted First-Day Returns Between IPO Cycles}}
\label{table:7.2}} \\
\toprule
\multicolumn{9}{@{}p{\textwidth}@{}}{%
  The total sample includes 825 IPOs comprising of 171 PE, 182 VC and 472 NS. 
  The table presents the results from testing if the first-day returns across
  all three subgroups are significantly different from zero. The test is
  conducted using a two-sided t-test.} \\
\midrule
\textbf{Subgroups} & \makebox[\templength][l]{\textbf{HMA All}} && \makebox[\templength][l]{\textbf{HMA PE}}
 && \makebox[\templength][l]{\textbf{HMA VC}} && \makebox[\templength][l]{\textbf{HMA NS}} \\
 && \makebox[\templength][r]{\textbf{LMA All}} && \makebox[\templength][r]{\textbf{LMA PE}}
 && \makebox[\templength][r]{\textbf{lMA VC}} && \makebox[\templength][r]{\textbf{LMA NS}} \\
\midrule
Mean (\%) & 11 & 3 & 10 & 3 & 9 & 4 & 12 & 4 \\
P-Value & \multicolumn{2}{c}{0.028} & \multicolumn{2}{c}{0.123} & \multicolumn{2}{c}{0.350} & \multicolumn{2}{c}{0.098} \\
\bottomrule\bottomrule
\end{tabular}
\end{table}

\end{document}

相关内容