1

I'm trying to add a unique table displaying the regression results in my working paper. However, I'm facing three issues: i) I'm unable to insert "Dependent Variable: y$_{it}" as a caption just above the table.

ii) I'm struggling to include the legend regarding the p-values and the text "In this table, we present the average marginal effects, with robust standard errors displayed within parentheses. All the regression models include a full set of year dummies" just below the table.

iii) The table is too wide and needs to be adjusted to fit on the sheet.

My attempt as follows

\documentclass[12pt,fleqn,a4paper]{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}



\begin{document}



\begin{table}[htbp]
    \centering
    \caption{%
        Dependent Variable: y$_{it}$
    }
    \vspace{0.5em} 
    \begin{tabular}{ccccccc}
        \toprule
        \textbf{Variable} & \textbf{Model 1} & \textbf{Model 2} & \textbf{Model 3} & \textbf{Model 4} & \textbf{Model 5} & \textbf{Model 6}  \\
        \midrule
        k$_{it}$ & & & & & &    \\
        & & & & & & \\
        h$_{it}$ & & & & & &\\
        & & & & & & \\
        Americas & & & & & &\\
        & & & & & & \\
        East Asia and South Asia and Pacific & & & & & &       \\
        & & & & & &  \\
        Europe and Central Asia & & & & & & \\
        Middle East and  North Africa & & & & & &       \\
        & & & & & &  \\
        \midrule
        Sample  & & & & & &  \\
        N       & & & & & &\\
        McFaddenR$^{2}$     & & & & & & \\
        \bottomrule
        \addlinespace[1ex]
        \multicolumn{4}{l}{\textsuperscript{***}$p<0.01$, \textsuperscript{**}$p<0.05$, \textsuperscript{*}$p<0.1$. In this table, we present the average marginal effects, with robust standard errors displayed within parentheses. All the regression models include a full set of year dummies.}
        \label{probit1}
    \end{tabular}
\end{table}

\end{document}
5
  • Does the code you posted compile in a fresh directory? No? Can you do better, please? Thank you
    – MS-SPO
    Oct 1 at 16:36
  • 1
    Do you mean should I add the packages and documentclass details? Just updated, thanks a lot
    – Maximilian
    Oct 1 at 16:41
  • Your table compiles, it's just very big, because you use only c columns that do not admit breaking text into lines. (btw, don't use y$_it$ --- $\mathrm{y}_{it}$ is much better to have a non-italic y).
    – Rmano
    Oct 1 at 17:20
  • @Maximilian, thank you. Right: It's easier, saves time and avoids ambiguities about packages used or not used ... and we can just copy, compile and focus on answering or improving. // However, it's almost always a good idea to use only packages which are needed to compile OR to show the problem, because sometimes some packages don't work together, or effects depend on which one was loaded first etc.
    – MS-SPO
    Oct 1 at 19:26

1 Answer 1

2

To have a table with three parts (caption, table, and notes), the better option is to use the package threeparttable.

The c columns center text in one line, so you have a very big table that does not fit.

Find below a try at it, but probably this table must be re-thought; read the suggestions here.

I used the threeparttable package, changed the first column to a p{}\ (paragraph) one (with ragged-right text), and reduced the size of the font to \footnotesize. Still, it doesn't fit the standard article width by almost 30 pt... (so it's not correctly centered on the page).

\documentclass[12pt,fleqn,a4paper]{article}
\usepackage{caption}
\usepackage{booktabs}
\usepackage{array}
\usepackage{amsmath}
\usepackage{threeparttable}
\usepackage{ragged2e}

\begin{document}
\begin{table}[htbp]
    \footnotesize
    \begin{threeparttable}[b]
        \caption{%
            Dependent Variable: $\mathrm{y}_{it}$
        }
        \label{probit1}
        \begin{tabular}{>{\RaggedRight}p{3cm}cccccc}
            \toprule
            \textbf{Variable} & \textbf{Model 1} & \textbf{Model 2} & \textbf{Model 3} & \textbf{Model 4} & \textbf{Model 5} & \textbf{Model 6}  \\
            \midrule
            $\mathrm{k}_{it}$ & & & & & &    \\
                     & & & & & & \\
            $\mathrm{h}_{it}$ & & & & & &\\
                     & & & & & & \\
            Americas & & & & & &\\
                     & & & & & & \\
            East Asia and South Asia and Pacific & & & & & &       \\
                                                 & & & & & &  \\
            Europe and Central Asia & & & & & & \\
                                    & & & & & &  \\
            Middle East and  North Africa & & & & & &       \\
                                          & & & & & &  \\
            \midrule
            Sample  & & & & & &  \\
            N       & & & & & &\\
            McFaddenR$^{2}$     & & & & & & \\
            \bottomrule
        \end{tabular}
        \begin{tablenotes}
            \item [] \textsuperscript{***}$p<0.01$, \textsuperscript{**}$p<0.05$, \textsuperscript{*}$p<0.1$. In this table, we present the average marginal effects, with robust standard errors displayed within parentheses. All the regression models include a full set of year dummies.
        \end{tablenotes}
    \end{threeparttable}
\end{table}

\end{document}

enter image description here

2
  • 1
    That's amazing. Thank you very much. One final question before upvoting the question: How can I prevent the table from floating on the sheet? In other words, how can I specify the precise position of the table on the sheet?
    – Maximilian
    Oct 1 at 17:59
  • 1
    If you do not want it to float, just remove the floating environment (i.e., do not surround it in a table environment). See tex.stackexchange.com/questions/39017/… (you can use a \begin{center}...\end{center} for example, to contain the effect of the \footnotesize command and adding a bit of vertical space)
    – Rmano
    Oct 1 at 18:10

You must log in to answer this question.

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