0

I have a long and wide table (9 columns, 67 rows). For the moment I have tried to use the lscape package to have it presented horizontally. The problem is that it's still too long and too wide, so that many rows and the last column don't fit into the page.

I am familiar with the longtable package and have tried to use it, but it still doesn't fit (neither horizontally nor vertically).

Does anybody have any ideas why this may be happening? Is resizing the font the only thing I can do?

I found some helpful posts but I am still wondering what's best in my case.

I report a fraction of the code in case it's needed.

\documentclass{article}

\usepackage[utf8]{inputenc}

\usepackage{dcolumn}

\usepackage{siunitx}

\usepackage{lscape} 

\usepackage{longtable}

\begin{table}[H]

  \sisetup{

    input-digits = ()-01234567890,

    input-open-uncertainty = ,

    input-close-uncertainty = ,

    table-align-text-post = false,

detect-all
  }
  \centering

  \begin{longtable}{lccccccccc}

\label{tab:panel_main} \\ \hline
    \toprule
          & \multicolumn{1}{l}{Model 1} & \multicolumn{1}{l}{Model 2} & \multicolumn{1}{l}{Model 3} & \multicolumn{1}{l}{Model 4} & \multicolumn{1}{l}{Model 5} & \multicolumn{1}{l}{Model 6} & \multicolumn{1}{l}{Model 7} & \multicolumn{1}{l}{Model 8} & \multicolumn{1}{l}{Model 9} \\
    \midrule

    year 1958 & 1.314* & -     & \multicolumn{1}{l}{1.363*} & -     & \multicolumn{1}{l}{1.558**} & \multicolumn{1}{r}{1.345} & -     & -     & - \\
   
 year 1959 & 0.209 & -     & \multicolumn{1}{r}{0.0816} & -     & \multicolumn{1}{r}{-0.625} & \multicolumn{1}{r}{0.148} & -     & -     & - \\
         \bottomrule
\multicolumn{2}{c}{ Robust standard errors in parentheses} \\
\multicolumn{2}{c}{ *** p$<$0.01, ** p$<$0.05, * p$<$0.1} \\
  \end{longtable}
\end{table}
\end{document}

Thanks in advance!

9
  • Could you complete your code with document class, \begin{document} and \end{document} up to a compilable MWE? And what is the idea of the alignment to the left or to the right in the cells? Is it a logical choice?
    – C. Peters
    Commented Jul 7, 2021 at 17:19
  • May be also add a screenshot?
    – MS-SPO
    Commented Jul 7, 2021 at 17:32
  • Nesting the longtable environment inside of a table does not make sense as it prevents page breaking. Remove the table environment. Also, your example code is not compilable, as at least the booktabs package is missing.
    – leandriis
    Commented Jul 7, 2021 at 17:48
  • You mention landscape orientation and the longtable package. You could combine both.
    – leandriis
    Commented Jul 7, 2021 at 17:49
  • Sorry I forgot to copy \begin{document}. How can I repost the code? Commented Jul 7, 2021 at 18:35

2 Answers 2

1

Placing a longtable in a table environment is wrong, because table cannot be broken across pages.

My impression is that you have a standard table. Here's some advice to get a better and smaller one.

Never repeat information: you can simply group the model columns and assign numbers to them. Similarly, repeating “year” can be avoided using a header.

With siunitx, aligning figures is much easier.

\documentclass{article}

\usepackage{booktabs}
\usepackage{siunitx}

\begin{document}

\begin{table}
\centering

\sisetup{table-align-text-after = false}

\begin{tabular}{
 @{}
 l
 S[table-format=1.3{*}]
 S[table-format=1.3]
 S[table-format=1.4{*}]
 S[table-format=1.3]
 S[table-format=-1.3{**}]
 S[table-format=1.3]
 S[table-format=1.3]
 S[table-format=1.3]
 S[table-format=1.3]
 @{}
}

\toprule
Year & \multicolumn{9}{c}{Model} \\
\cmidrule(l){2-10}
& {1} & {2} & {3} & {4} & {5} & {6} & {7} & {8} & {9} \\
\midrule

1958 & 1.314* & {--} & 1.363* & {--} & 1.558** & 1.345 & {--} & {--} & {--} \\

1959 & 0.209 & {--}  & 0.0816 & {--} & -0.625 & 0.148 & {--}  & {--} & {--} \\
\bottomrule
\multicolumn{10}{@{}l@{}}{Robust standard errors in parentheses} \\
\multicolumn{10}{@{}l@{}}{*** $p<0.01$, ** $p<0.05$, * $p<0.1$} \\
  \end{tabular}

\end{table}

\end{document}

Adjust the settings of the columns depending on the actual values you have.

enter image description here

0

Here is a code that works with lscape and siunitx. Note that a longtable is not a float, so it doesn't have to be nested in a table environment, and it is automatically centred, so \centering is useless. I added various improvements and simplifications of code.

\documentclass{report}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{lscape}
\usepackage{longtable}

\begin{document}

\begin{landscape}
  \sisetup{%
    input-digits = ()-01234567890,
    input-signs = -,
    input-open-uncertainty = ,
    input-close-uncertainty = ,
    table-align-text-post = false,
    detect-all,
    table-format =-1.4***}
\setlength{\extrarowheight}{3pt}
  \begin{longtable}{@{}l*{9}{S}}

\label{tab:panel_main} \\ \hline
    \toprule
    & {Model 1} & {Model 2} & {Model 3} & {Model 4} & {Model 5} & {Model 6} & {Model 7} & {Model 8} & {Model 9} \\
    \midrule
    year 1958 & 1.314* & {$ - $} & 1.363* & {$ - $} & 1.558** & 1.345 & {$ - $} & {$ - $} & {$ - $} \\
 year 1959 & 0.209 & {$ - $} & 0.0816 & {$ - $} & -0.625 & 0.148 & {$ - $}& {$ - $} & {$ - $} \\
         \midrule[\heavyrulewidth]
\multicolumn{10}{l}{ Robust standard errors in parentheses} \\
\multicolumn{10}{l}{ *** $p<0.01$, \enspace ** $p<0.05$,\enspace * $p<0.1$}
  \end{longtable}
\end{landscape}

\end{document} 

enter image description here

You must log in to answer this question.

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