# Trying to replicate a table from academic paper

I have this table:

I'm trying to replicate something like this table:

The main things that I wish to replicate are (i) How the text is appended very neatly to the top and bottom of the table (ii) The table is the exact same width of the text on the page (iii) The width of the columns (which space between columns) seems to have automatically widened to fill up the page width.

My code for my table is the following:

\documentclass[a4paper,11pt]{article}
\begin{document}

\begin{table}[h]
\begin{center} {\footnotesize
\begin{tabular}{lccc}
\hline
& \multicolumn{3}{c}{AFC Window 1}  \\
& \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} &
\multicolumn{1}{c}{fbi}\\\hline
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Constant} & (1.22) & (2.22) & (0.56)\\[0ex]
& $0.025^*$ & -0.002 & $1.155^*$ \\[-2ex]
\raisebox{2ex}{Log(assets)$^a$} & (1.22) & (2.22) & (0.56)\\[0ex]
\hline
\end{tabular} }
\end{center}
\caption{\footnotesize Number of turns and distance between top and bottom.}
\label{turns}
\end{table}

\end{document}


I really have no idea how to proceed.

-
You can spread the table with \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}lccc@{}} And I would remove all the raisebox and [-2ex] negative spacing. –  David Carlisle Jul 13 '12 at 16:16
As you can see, the first "Constant" is aligned with the first row of numbers, not between the two rows. The table also uses features from the booktabs package. For the number columns, look at the S column specifier of siunitx (which was probably used). –  egreg Jul 13 '12 at 16:28
It looks like ctable to me –  bobobobo Jul 13 '12 at 20:59

How the text is appended very neatly to the top and bottom of the table?

Probably by placing the table's contents inside a minipage environment of width \textwidth.

The table is the exact same width of the text on the page

Probably with the use of a tabular* environment, with its first argument set to \textwidth.

The width of the columns (which space between columns) seems to have automatically widened to fill up the page width.

The second argument of the tabular* argument was probably set up as follows:

@{}l@{\extracolsep{\fill}}...@{}
% the @{} items suppress whitespace before first and after the last column
% the @{\extracolsep{\fill}} item inserts "\fill" between columns


Putting both elements together, you'd issue the command

\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}...@{}


to start the tabular* environment. Note that the . column type used here would need to be defined by loading the dcolumn package and issuing the command

\newcolumntype{.}{D{.}{.}{-1}}


in the preamble. The -1 instructs dcolumn to try to come up with the best layout ont its own. To fine-tune the layout it's usually a good idea to specify the number of decimal digits (i.e., the ones to the right of the decimal point) explicitly by defining, say, a new column type named d:

\newcolumntype{d}[1]{D{.}{.}{#1}}


The argument indicates the number of digits after the decimal point for which space needs to be reserved.

Finally, to emulate the appearance of the table's caption -- with a newline between the table number and the caption text -- you could load the caption package and issue the command

\captionsetup{labelsep=newline,singlelinecheck=false}


Addendum: Putting all of this together leads to the following MWE, which generates the table you're interested in. First, some notes:

• It's not necessary to specify something like \centering for this table because the table takes up the full width of the text block.

• Material in "decimal" columns (i.e., those generated by a dcolumn-based specifier) is automatically typeset in TeX's math mode. This is relevant for the \ast macro which typesets a raised asterisk.

• I've assigned 4 as the argument of the three d ("decimal-aligned") columns because the asterisks take up one extra space. (Thus, if you had three digits and two asterisks, you'd assign 5 to the number of digits to be set aside by dcolumn, etc.)

• I've also used the \toprule, \midrule, and \bottomrule commands provided by the booktabs package instead of the \hline command; the \...rule commands provide for much better vertical spacing that \hline does.

Here, then, is the MWE:

\documentclass[a4paper,11pt]{article}
\usepackage{booktabs,dcolumn,caption}
\captionsetup{labelsep=newline,singlelinecheck=false} % optional
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\renewcommand{\ast}{{}^{\textstyle *}} % for raised "asterisks"
\begin{document}
\begin{table}[h]
\caption{Number of turns and distance between top and bottom.}
\label{turns}
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}d{4}d{4}d{4}@{}}
\toprule
& \multicolumn{3}{c}{AFC Window 1} \\
& \multicolumn{1}{c}{gmt} & \multicolumn{1}{c}{jfk} & \multicolumn{1}{c}{fbi}\\
\midrule
Constant      & 0.025\ast & -0.002 & 1.155\ast \\
& (1.22)    & (2.22) & (0.56)\\
Constant      & 0.025\ast & -0.002 & 1.155\ast \\
& (1.22)    & (2.22) & (0.56)\\
Log(assets)\textsuperscript{a}
& 0.025\ast & -0.002 & 1.155\ast \\
& (1.22)    & (2.22) & (0.56)\\
\bottomrule
\end{tabular*}
\end{table}
\end{document}


-
Are we sure the table we are trying to replicate was LaTeX? Times. No ligatures. Perhaps not? That doesn't invalidate the advice, but I wouldn't assume we are trying to guess how this was done, so much as to get close ... Or better! –  Paul Stanley Jul 13 '12 at 21:29
@PaulStanley -- I'm an economist, and I recognized the table as being from a fairly well-known paper that was published in the Journal of International Economics in 2004. I also happen to know that this journal accepts LaTeX input files. (Indeed, I should know -- I have a paper under review at that journal at the moment...) For sure, though, the font is certainly not Computer Modern! –  Mico Jul 13 '12 at 22:35
The quality of the responses has really surprised me. Would you recommend using \footnotesize just after \begin{table}[h] if I want to use your code for something with 9-10 columns (so it doesn't go over the edge of the page)? –  user16208 Jul 14 '12 at 4:41
@IssacM: How best to squeeze a table to make it fit into the available space is a broad topic for discussion. For some suggestions (besides reducing the font size either via \small or, more drastically, \footnotesize), I suggest you take a look at the following answer: tex.stackexchange.com/a/44692/5001 (shameless self-citation alert!). –  Mico Jul 14 '12 at 11:04

In addidtion to @egreg's suggestions of using booktabs and siunitx, you can use tabu as a replacement to tabular. I would also use \centering instead of \begin{center} as the later adds vertical white space around it which may not be desired.

The tabu environment requires you to use an X column (which is automatically scaled to fit the the specified width. Since the S column type can only be of type c, you can use David's \extracolsep to increase the space before the S columns.

Edit: For the text below the table, you can make it as another multicolumn spanning across the entire table. In that case instead of using \bottomrule for the last line, you will have to use a \midrule as \bottomrule reduces the spacing after it. To make it look like a bottomrule you will need to add the width \midrule[\heavyrulewidth]. Also not the definition of the multicolumn where I add @{} before and after so that there isn't any margins on either side of the text.

As @Mico suggests, the caption styles can be achieved using the caption package

Edit 2: The previous version of inputting the numbers in brackets was slightly flawed. The answer to this question provide the proper way. The source and the preview have been updated. Note that you may need a fairly recent version of the siunitx package for it to work.

Edit 3: I realised that one can set the S column to be X defined as well using the syntax X[c]{S[<siunitx option]}} when defining the Y column type. This permits to get rid of the @{\extracolsep[]} which one would have to adjust depending on content. I have added a factor of 2 for the size of the first X column as it resembles more closely the original table. One note though is that with this method there is now padding on the right to the right-most column.

\documentclass[a4paper,11pt]{article}

\usepackage{tabu}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{caption}

\captionsetup{labelsep=newline,singlelinecheck=false}

\begin{document}

\begin{table}[h]
\centering
\footnotesize
\caption{\footnotesize Number of turns and distance between top and bottom.}
\label{turns}
\newcolumntype Y{X[c]{S[per-mode=symbol,
table-align-text-pre=false,
table-align-text-post=false,
input-symbols=,
input-open-uncertainty=,
input-close-uncertainty=,
detect-all
]}}
\tabucolumn Y
\begin{tabu} to \textwidth {@{}X[2,l]*3Y@{}}
\toprule
& \multicolumn{3}{c}{AFC Window 1}  \\
& {gmt} & {jfk} & {fbi} \\
\midrule
Constant & 0.025* & -0.002 & 1.155* \\
& (1.22) & (2.22) & (0.56)\\
Constant & 0.025* & -0.002 & 1.155* \\
& (1.22) & (2.22) & (0.56)\\
Log(assets)\textsuperscript{a} & 0.025* & -0.002 & 1.155* \\
& (1.22) & (2.22) & (0.56)\\
\midrule[\heavyrulewidth]
\multicolumn{4}{@{}p{\textwidth}@{}}{Dependent variables are the country-specific effects reported in Table 4 and obtained from the regressions reported in Table~3. Standard errors are in parentheses and are White adjested for the heteroscedasticity. *Significant at the 5\% level.}
\end{tabu}
\end{table}

\end{document}


-
Nice use of the tabu table type. A quick question: There seems to be an excessive amount of whitespace between the numbers in parentheses and the associated closing (right) parenthesis. Can this whitespace be suppressed? –  Mico Jul 13 '12 at 20:56
yes I saw that too. siunitx would not accept the numbers until I added input-symbols=(). I was expecting it to recognise the format for uncertainty but only seems to work when the uncertainty follows the actual value. After playing around with siunitx options and looking at the answers to this question, it seems that turning off the group-four-digits options removes the extraneous space. although as point out, this method disables rounding. but the method suggested add space after the first ( –  ArTourter Jul 13 '12 at 21:37
One of the answers to the question I mentioned above refers to the table-align-test-pre option, unfortunately, this option is not available in my version of siunitx. –  ArTourter Jul 13 '12 at 21:48
I have tested it on a machine with texlive2012 and the table-align-text-pre` option worked so I have updates the answer to reflect this. –  ArTourter Jul 13 '12 at 23:29