1

I would like to reproduce the following table in a document:

enter image description here

I tried out different solutions using the package tabular, but without much success (I can make a "standard" table, but the one in the image looks quite specific, composition-speaking).

Any kind of suggestion is welcome.

Vladimir
  • 343
  • 1
    Would you mind sharing the code you have tried so far? – campa Jul 23 '21 at 13:53
  • This is the code I have:

    \begin{center} \begin{tabular}{lccr} \toprule a & b & c & c' \ \midrule d & e & f & f'\ g & h & i & i'\ l & m & n & n'\ \bottomrule \end{tabular} \end{center}

    The table in the image doesn't differ too much from the one produced by the above code. My problem is the length of the entries of the image table, among others.

    I made very few tables in my life. I am reading a guide, and I am here to learn from more expert users.

    – Vladimir Jul 23 '21 at 14:03

2 Answers2

2

enter image description here

A place to start from:

\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}

leandriis
  • 62,593
2

I would employ a tabularx environment and use a modified form of the X column type for the first column, where the modification suspends full justification and enables hanging indentation.

enter image description here

\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}
Mico
  • 506,678