重现一个表格(使用表格?)

重现一个表格(使用表格?)

我想在文档中重现下表:

在此处输入图片描述

我尝试使用 tabular 包尝试了不同的解决方案,但没有取得太大成功(我可以制作一个“标准”表格,但从构图上看,图像中的表格看起来非常具体)。

欢迎提出任何建议。

答案1

我将采用一个tabularx环境并对第一列使用修改形式的X列类型,其中修改会暂停完全对齐并启用悬挂缩进。

在此处输入图片描述

\documentclass[12pt]{article} % or some other suitable document class
\usepackage{tabularx,ragged2e,booktabs}
\usepackage{newtxtext,newtxmath}
\newcolumntype{L}{>{\RaggedRight\hangafter=1\hangindent=1em}X}
\newcommand\mc[1]{\multicolumn{2}{c}{#1}}
\begin{document}
\begin{table}
\caption{Participant Characteristics}
\begin{tabularx}{\textwidth}{@{} L r@{\space}l @{\qquad} r@{\space}l c @{}}
\toprule
& \mc{More} & \mc{Less} \\
& \mc{Experienced} & \mc{Experienced} \\
Variables & \mc{Investors} & \mc{Investors} & P-Value$^*$ \\
\midrule
Percentage who had previously invested in the stock market
   & \multicolumn{2}{l}{78.50\%} & \multicolumn{2}{l}{36.78\%} & .001 \\
\addlinespace
Years of business work experience 
   & 6.35 & (6.00) & 1.28 & (2.14) & .001\\
\addlinespace
Age 
   & 30.46 & (1.70) & 20.11 & (2.67) & .001 \\
\addlinespace
Number of courses taken that discussed investing in mutual funds or the stock market 
   & 1.58 & (1.70) & .95 & (1.16) & .001 \\
\addlinespace
\dots \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}

答案2

在此处输入图片描述

起点:

\documentclass[twocolumn]{article}
\usepackage{booktabs} % horizontal lines, such as \toprule, \midrule and \bottomrule
\usepackage{tabularx} % tabularx environment
\usepackage{siunitx} % S type columns to improve alignment of numbers
\usepackage{threeparttable} % tablenotes environment and \tnote commend
\usepackage{makecell} % \thead command for column headers with manual line breaks
\renewcommand{\theadfont}{\normalsize}

\usepackage{lipsum} % dummy text. Do not use in real document.
\begin{document}
\begin{table}
  \begin{threeparttable}
    \caption{the table's caption}
    \label{tab:key}
    \begin{tabularx}{\linewidth}{@{}>{\raggedright\arraybackslash\hangindent=6pt}X r@{\;}l r@{\;}l S[table-format=1.3]@{}}
      \toprule
      \thead[bl]{header} 
        & \multicolumn{2}{c}{\thead[b]{a 3 \\line long \\ header}} 
        &\multicolumn{2}{c}{\thead[b]{a 3 \\line long \\ header}} 
        & {\thead[b]{header\tnote{*}}}\\
      \midrule
      some text                    & \multicolumn{2}{c}{11.11\%} & \multicolumn{2}{c}{11.11\%} & 1.111  \\
      a multiple line text         &  1.11 & (1.11)              & 11.11 & (1.11)              & 1.111  \\
      another entry with long text &  1.11 & (1.11)              &  1.1  & (1.11)              & 1.11  \\
      \bottomrule
    \end{tabularx}
    \begin{tablenotes}[flushleft]\small
      \item[*] some descriptive text below the table. This text is as wide as the table
    \end{tablenotes}
  \end{threeparttable}
\end{table}

\lipsum % dummy text. Do not use in real document.
\end{document}

相关内容