Trying to replicate a table from academic paper
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}
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}
in your document's preamble.
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 assign5
to the number of digits to be set aside bydcolumn
, etc.)I've also used the
\toprule
,\midrule
, and\bottomrule
commands provided by thebooktabs
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,
skip=0.333\baselineskip}
\newcolumntype{d}[1]{D{.}{.}{#1}} % "decimal" column type
\renewcommand{\ast}{{}^{\textstyle *}} % for raised "asterisks"
\begin{document}
\begin{table}[h]
\setlength\tabcolsep{0pt} % let LaTeX figure out amount of inter-column whitespace
\caption{Number of turns and distance between top and bottom.}
\label{turns}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} l *{3}{d{2.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}