1

I would like to fit my table on one page with the title.

The code is:

       \documentclass[11p]{article}
        \usepackage[utf8]{inputenc}
        \usepackage[margin=3cm, left=2cm, includefoot]{geometry}
        \usepackage{longtable}

    \section{table 1}
        \begin{document}
                \begin{table}[htbp]\centering
            \def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}
            \begin{longtable}{l*{3}{c}}
            \caption{{\b table 1 }}\\
\hline\hline\endfirsthead\hline\endhead\hline\endfoot\endlastfoot
                                &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}&\multicolumn{1}{c}{(3)}\\
                                &\multicolumn{1}{c}{investments}&\multicolumn{1}{c}{investments}&\multicolumn{1}{c}{investments}\\
            \hline
            var0  &    0.000112\sym{++} &    0.000106\sym{++} &    0.000119\sym{+++}\\
                                &      (1.63)         &      (1.55)         &      (1.85)         \\
            [1em]
            var1    &       0.121\sym{+}  &       0.126\sym{+}  &       0.132\sym{++} \\
                                &      (1.33)         &      (1.38)         &      (1.46)         \\
            [1em]
            var2                 &     0.00420         &     0.00353         &     0.00479         \\
                                &      (1.04)         &      (0.87)         &      (1.17)         \\
            [1em]
            var3                &   -0.000207         &                     &                     \\
                                &     (-0.31)         &                     &                     \\
            [1em]
            var4        &    0.000744         &    0.000951         &    0.000697         \\
                                &      (0.75)         &      (1.02)         &      (0.78)         \\
            [1em]
            var5   &  -0.0000825         &   -0.000217         &   -0.000199         \\
                                &     (-0.04)         &     (-0.10)         &     (-0.10)         \\
            [1em]
            var6                  &    -0.00194         &    -0.00171         &                     \\
                                &     (-0.65)         &     (-0.56)         &                     \\
            [1em]
            var7 &    0.000311         &    0.000233         &    0.000264         \\
                                &      (0.41)         &      (0.30)         &      (0.37)         \\
            [1em]
            var8           &                     &                     &    -0.00713         \\
                                &                     &                     &     (-0.80)         \\
            [1em]
            var9          &                     &                     &     -0.0175\sym{+++}\\
                                &                     &                     &     (-1.68)         \\
            [1em]
            var10           &                     &                     &     -0.0176         \\
                                &                     &                     &     (-1.21)         \\
            [1em]
            Constant            &     0.00633         &    -0.00603         &    -0.00771         \\
                                &      (0.08)         &     (-0.10)         &     (-0.13)         \\
            \hline
            Observations        &         111         &         111         &         111         \\
            \(R^{2}\)           &                     &                     &                     \\
            \hline\hline
            \multicolumn{4}{l}{\footnotesize \textit{t} statistics in parentheses}\\
            \multicolumn{4}{l}{\footnotesize \sym{+} \(p<0.2\), \sym{++} \(p<.15\), \sym{+++} \(p<0.1\), \sym{*} \(p<0.05\), \sym{**} \(p<0.02\), \sym{***} \(p<0.01\)}\\
            \end{longtable}
            \end{table}

        \end{document}

I tried using \resize, but I did not manage to make it work.

6
  • Could you please make your code a minimal working example (MWE) by completing your code with the documentclass, the necessary packages and margin settings if used? Also, why do you use a longtable if you want your table to fit onto a single page?
    – leandriis
    Commented May 31, 2018 at 14:53
  • @leandriis Sorry for that, I just corrected the code. I used longtable because i downloaded it directly from STATA, and that was the one they used. Should i change that?
    – Chiara
    Commented May 31, 2018 at 14:59
  • 1
    Thank your for updating your example. longtable is intended to split tables that are too long to fit onto one page over several pages. If you want your table to fit on one page, you simply don't need it. (Apart from that, a longtable environment is not intended to be used inside a table environment.) With that in mind, your table is not too large for a page, so it should fit. What I unfortnately still don't understand is the part about the title in your question, as there is not title in the MWE.
    – leandriis
    Commented May 31, 2018 at 15:10
  • never use longtable inside a table. It seems you do not want longtable at all, and just use a normal tabular Commented May 31, 2018 at 15:23
  • @leandriis I forgot to add that part, when I was talking about the title I was referring to the \section{}
    – Chiara
    Commented May 31, 2018 at 16:49

1 Answer 1

1

try, maybe you liked:

\documentclass[11p]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=3cm, left=2cm, includefoot]{geometry}
\usepackage{booktabs, dcolumn, threeparttable}      % new
\newcolumntype{d}[1]{D{.}{.}{#1}}                   % new, for numbers aligning
\newcommand\mc[1]{\multicolumn{1}{c}{#1}}           % new, handy shortcut macro

\begin{document}
\section{Section title}
    \begin{table}[htbp]
    \centering
    \renewcommand\arraystretch{0.9}
    \begin{threeparttable}
\begin{tabular}{l*{3}{d{3.9}}}
    \toprule
        &   \mc{(1)}            &   \mc{(2)}            &   \mc{(3)}            \\
        &   \mc{investments}    &   \mc{investments}    &   \mc{investments}    \\
    \midrule
var0    &    0.000112\tnote{++} &   0.000106\tnote{++}  &   0.000119\tnote{+++} \\
        &   (1.63)              &   (1.55)              &   (1.85)              \\
    \addlinespace
var1    &   0.121\tnote{+}      &   0.126\tnote{+}      &   0.132\tnote{++}     \\
        &   (1.33)              &   (1.38)              &   (1.46)              \\
    \addlinespace
var2    &   0.00420             &   0.00353             &   0.00479             \\
        &   (1.04)              &   (0.87)              &   (1.17)              \\
    \addlinespace
var3    &   -0.000207           &                       &                       \\
        &   (-0.31)             &                       &                       \\
    \addlinespace
var4    &   0.000744            &   0.000951            &   0.000697            \\
        &   (0.75)              &   (1.02)              &   (0.78)              \\
    \addlinespace
var5    &  -0.0000825           &   -0.000217           &   -0.000199           \\
        &   (-0.04)             &   (-0.10)             &   (-0.10)             \\
    \addlinespace
var6    &   -0.00194            &   -0.00171            &                       \\
        &   (-0.65)             &   (-0.56)             &                       \\
    \addlinespace
var7    &   0.000311            &   0.000233            &   0.000264            \\
        &   (0.41)              &   (0.30)              &   (0.37)              \\
    \addlinespace
var8    &                       &                       &   -0.00713            \\
        &                       &                       &   (-0.80)             \\
     \addlinespace
var9    &                       &                       &   -0.0175\tnote{+++}  \\
        &                       &                       &   (-1.68)             \\
    \addlinespace
var10   &                       &                       &   -0.0176             \\
        &                       &                       &   (-1.21)             \\
    \addlinespace
Constant    &   0.00633         &   -0.00603            &   -0.00771            \\
            &   (0.08)          &   (-0.10)             &   (-0.13)             \\
    \addlinespace
Observations    &   \mc{111}    &   \mc{111}            &   \mc{111}            \\
    \(R^{2}\)   &               &                       &                       \\
    \bottomrule
\end{tabular}
    \begin{tablenotes}[para]\footnotesize
    \item[] statistics in parentheses

    \item[+]    \(p<0.2\),
    \item[++]   \(p<.15\),
    \item[+++]  \(p<0.1\).

    \item[*]    \(p<0.05\),
    \item[**]   \(p<0.02\),
    \item[***]  \(p<0.01\).
    \end{tablenotes}
    \end{threeparttable}
    \end{table}
\end{document}

above mwe gives:

enter image description here

i redesign your table a little bit :-):

  • numbers are aligned at decimal points. for this i used dcolumn package
  • instead \hline i use rules toprule, midrule and bottomrule from the package booktabs. to my taste with this table look nices
  • for table notes i use tablenotes environment from the package threeparttable
  • instead \\[1em] if for row's pairs separating is used \addlinespace from the package booktabs

edit: it is not clear what you mean with "to fit my table on one page with the title". is this section title, table caption? if your real table is not larger than shown, then there is enough space on the page for the title of the section and some lines of text. to show this i add section title to my code.

You must log in to answer this question.

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