0

enter image description here

I would like to create the following table in latex. But I don't know how to write the headers.

1
  • 2
    Welcome to TeX SX! What did you try?
    – Bernard
    Nov 23, 2016 at 20:58

2 Answers 2

3

I can't help but share my view that I don't particularly care for the layout of the table that's shown in your screenshot. This table has a very lop-sided feel, both because the final two data columns are much wider than the first four data columns are and because of the dominant left-alignment appearance.

Anyway, it's reasonably straightforward to reproduce this lop-sided look with the facilities of the booktabs, tabularx, and siunitx packages.

I also show what, IMNSHO, is a better layout. It still uses the booktabs and siunitx packages, but it uses a tabular* environment instead of a tabularx environment, it centers the contents of the data columns, and it gives more structure to the right-hand most header cells. I hope you'll agree with me that the resulting look is superior.

enter image description here

\documentclass{article} 
\usepackage[margin=1in,letterpaper]{geometry} % text block parameters
\usepackage{tabularx,siunitx,booktabs}
\usepackage[skip=0.5\baselineskip]{caption}
\usepackage{newtxtext,newtxmath}
\newcommand\mX[1]{\multicolumn{1}{X}{#1}}  % handy shortcut macros
\newcommand\mcc[1]{\multicolumn{2}{c}{#1}}
\newcommand\mcl[1]{\multicolumn{2}{l}{#1}}
\begin{document}

\begin{table}[t]
\caption{Trying to recreate all questionable layout choices\dots}
\begin{tabularx}{\textwidth}{%
          l
          S[table-format=3.3,table-number-alignment = left]
     *{5}{S[table-format=3.2,table-number-alignment = left]}}
\toprule
& \mcl{\textbf{No policy}}
& \mcl{\textbf{Credit policy}}
& \mcl{\textbf{Macroprudential policy} ($\tau^2=0.0061$)}\\
\cmidrule(lr){2-3} \cmidrule(lr){4-5} \cmidrule(l){6-7}
& \mX{Low risk}  & \mX{High risk} & \mX{Low risk} 
& \mX{High risk} & \mX{Low risk}  & \mX{High risk} \\
\midrule
Output &  23.821 &  23.53 &  24.18 &  23.85 &  24.04 &  23.83\\
$\vdots$ \\
$K$    & 209.52  & 206.16 & 214.23 & 210.46 & 212.48 & 210.41\\
$\vdots$\\
SD output growth (\%) & 1.09 & 2.53 & 0.81 & 2.43 & 0.80 & 2.29 \\
\bottomrule
\end{tabularx}
\end{table}

\begin{table}[h]
\centering
\setlength\tabcolsep{0pt} % make LaTeX figure out the intercolumn whitespace
\caption{A (hopefully) superior layout\dots}
\begin{tabular*}{0.9\textwidth}{l@{\extracolsep{\fill}}
     S[table-format=3.3] *{5}{S[table-format=3.2]}@{}}
\toprule
& \mcc{\textbf{No policy}}
& \mcc{\textbf{Credit policy}}
& \mcc{\textbf{Macropru policy}}\\
& && && \mcc{($\tau^2=0.0061$)}\\
\cmidrule{2-3} \cmidrule{4-5} \cmidrule{6-7}
& {Low risk}  & {High risk} & {Low risk} 
& {High risk} & {Low risk}  & {High risk} \\
\midrule
Output &  23.821 &  23.53 &  24.18 &  23.85 &  24.04 &  23.83\\
$\vdots$ \\
$K$    & 209.52  & 206.16 & 214.23 & 210.46 & 212.48 & 210.41\\
$\vdots$\\
SD output growth (\%) & 1.09 & 2.53 & 0.81 & 2.43 & 0.80 & 2.29 \\
\bottomrule
\end{tabular*}
\end{table}

\end{document}
3

Partial solution with ConTeXt MKIV. I OCRed the numbers from your picture, so I don’t guarantee that they are correct.

\setuppapersize[A4,landscape]
\setupbodyfont[schola,10pt]
\starttext

\startsetups table:numbers
  \setupTABLE[frame=off,option=stretch]
  \setupTABLE[c][each][alignmentcharacter={.},aligncharacter=yes]
  \setupTABLE[r][1][style=bold,aligncharacter=no]
  \setupTABLE[r][1,2,3][topframe=on]
  \setupTABLE[r][-1][bottomframe=on]
  \setupTABLE[1][2][topframe=off]
\stopsetups

\startTABLE[setups=table:numbers]
  \NC                       \NC[nx=2] No policy         \NC[nx=2] Credit policy    \NC[nx=2] Macroprudential policy {\tf($\tau^s = 0.0061$)} \NC\NR
  \NC                       \NC Low risk  \NC High risk \NC Low risk \NC High risk \NC Low risk \NC High risk \NC\NR
  \NC Output                \NC 23.821    \NC 23.53     \NC 24.18    \NC 23.85     \NC 24.04    \NC 23.83     \NC\NR
  \NC $C$                   \NC 18.58     \NC 18.37     \NC 18.82    \NC 18.58     \NC 18.73    \NC 18.57     \NC\NR
  \NC $L$                   \NC 8.16      \NC 8.08      \NC 8.26     \NC 8.16      \NC 8.22     \NC 8.15      \NC\NR
  \NC $K$                   \NC 209.52    \NC 206.16    \NC 214.34   \NC 210.46    \NC 212.48   \NC 210.41    \NC\NR
  \NC $N$                   \NC 31.77     \NC 38.02     \NC 30.05    \NC 37.11     \NC 30.85    \NC 37.72     \NC\NR
  \NC Risk free rate (\%)   \NC 4.08      \NC 3.72      \NC 4.06     \NC 3.68      \NC 4.05     \NC 3.56      \NC\NR
  \NC Spread (\%)           \NC 0.99      \NC 1.46      \NC 0.89     \NC 1.38      \NC 0.94     \NC 1.48      \NC\NR
  \NC $x$ (\%)              \NC 10.12     \NC 15.16     \NC 9.63     \NC 13.35     \NC 18.77    \NC 21.98     \NC\NR
  \NC $\nu$                 \NC 1.63      \NC 1.38      \NC 1.76     \NC 1.42      \NC 1.81     \NC 1.54      \NC\NR
  \NC $\mu_e$               \NC 0.05      \NC 0.15      \NC 0.03     \NC 0.12      \NC 0.03     \NC 0.08      \NC\NR
  \NC $\mu_s$               \NC 0.29      \NC 0.16      \NC 0.33     \NC 0.19      \NC 0.37     \NC 0.27      \NC\NR
  \NC $\phi$                \NC 6.59      \NC 5.42      \NC 7.13     \NC 5.67      \NC 6.89     \NC 5.58      \NC\NR
  \NC $QK/*N+xQK)$          \NC 3.95      \NC 2.98      \NC 4.23     \NC 3.23      \NC 3.00     \NC 2.51      \NC\NR
  \NC $N/xQK$               \NC 1.50      \NC 1.22      \NC 1.46     \NC 1.32      \NC 0.77     \NC 0.82      \NC\NR
  \NC SD shock (\%)         \NC 0.69      \NC 2.07      \NC 0.69     \NC 2.07      \NC 0.69     \NC 2.07      \NC\NR
  \NC SD output growth (\%) \NC 1.09      \NC 2.53      \NC 0.81     \NC 2.43      \NC 0.80     \NC 2.29      \NC\NR
\stopTABLE

\stoptext

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .