0

enter image description hereMy table exceeds the page length. Any help would be highly appreciated.

\setlength{\tabcolsep}{1pt}
\begin{tabular}{l*{12}{c}}
    \hline\hline

    \multicolumn{12}{l}{\hspace{8cm}\textbf{Panel B: Return and Profitability Descriptive Statistics}}\\

    \hline
    &\multicolumn{1}{c}{Non\_Dur}&\multicolumn{1}{c}{ Durable}&\multicolumn{1}{c}{Manufacturing}&\multicolumn{1}{c}{Oil \& Gas }&\multicolumn{1}{c}{Chemicals}&\multicolumn{1}{c}{Bus Eqp}&\multicolumn{1}{c}{Phone \& TV}&\multicolumn{1}{c}{Utilities}&\multicolumn{1}{c}{Whole\_Ret}&\multicolumn{1}{c}{Healthcare}&\multicolumn{1}{c}{Finance}&\multicolumn{1}{c}{Other}\\
    \hline

ROE         &       0.077&       0.057&       0.034&       0.031&       0.026&      -0.069&      -0.927&       1.096&       0.094&      -0.281&       0.450&       0.001 \\
            &       0.119&      -0.111&       0.126&      -0.755&       0.117&      -0.050&       0.102&       0.116&       0.059&       0.067&       0.100&      -0.000 \\
            &      -1.067&       6.948&      -2.569&       7.551&      -1.519&      -0.240&      -0.930&       3.766&       0.998&      -8.318&       4.282&       0.053 \\
[0.5em]
\hline
CF          &       0.061&       0.051&       0.060&       0.059&       0.044&       0.009&       0.029&       0.029&       0.062&      -0.140&       0.003&       0.038 \\
            &       0.062&       0.069&       0.058&       0.076&       0.058&       0.042&       0.054&       0.037&       0.052&      -0.035&       0.021&       0.002 \\
            &      -1.044&      -7.180&       2.385&      -6.253&      -6.694&     -23.859&      -8.631&      -6.328&      11.392&     -37.083&      -6.982&       7.542 \\
[0.5em]
\hline
EBIT\_MAR     &       0.043&      -0.016&      -0.066&      -0.639&      -0.443&      -1.742&      -1.598&       0.017&      -0.012&     -17.730&       0.018&      -1.102 \\
            &       0.075&       0.050&      -0.050&      -5.519&       0.034&      -0.254&      -0.163&       0.185&       0.020&      -8.070&       0.095&      -0.137 \\
            &      -2.244&      -6.142&      -0.519&      10.781&      -4.773&      -5.256&      -1.514&     -11.954&      -2.024&      -5.218&      -0.509&      -8.969 \\
[0.5em]
\hline
GM          &       0.340&       0.262&       0.217&       0.152&       0.146&      -0.847&      -0.696&       0.221&       0.277&     -14.841&       0.350&      -0.587 \\
            &       0.323&       0.285&       0.176&       0.042&       0.361&       0.285&       0.234&       0.279&       0.237&      -7.230&       0.276&       0.165 \\
            &       2.168&      -2.748&       1.644&       0.820&      -5.184&      -4.208&      -1.029&      -9.724&       5.978&      -4.262&       0.583&      -7.792 \\
[0.5em]
\hline
TAX         &       0.339&       0.309&       0.221&       0.264&       0.278&       0.141&       0.263&       0.392&       0.564&       0.249&       0.246&       0.138 \\
            &       0.300&       0.131&       0.369&       0.276&       0.344&       0.162&       0.018&       0.329&       0.306&       0.207&       0.204&       0.216 \\
            &       1.820&       5.471&      -3.440&      -0.289&      -3.618&      -1.018&       3.346&       2.985&       1.382&       0.862&       0.986&      -1.205 \\
[0.5em]
\hline
RET12\_L    &       1.211&       1.223&       1.212&       1.240&       1.215&       1.320&       1.261&       1.166&       1.239&       1.322&       1.144&       1.232 \\
            &       1.217&       1.241&       1.208&       1.257&       1.176&       1.312&       1.293&       1.151&       1.229&       1.318&       1.212&       1.208 \\
            &      -1.006&      -2.006&       1.176&      -2.261&       5.777&       1.258&      -2.815&       6.934&       1.854&       0.631&     -23.983&       6.033 \\
\hline\hline
\end{tabular}
  • (1) welcome, (2) on this site we prefer full minimal examples that can be copied an tested as is without having to add anything, and not like there where it is only a sniplet. 12 columns of data will probably never fint the page width unless you do way down in font size. Might be an idea to redesign your table (12 colums are also not very user friendly) – daleif Sep 2 '16 at 9:26
  • Thanks daleif, but I use in my report portrait not landscape. – Umar Hayat Sep 2 '16 at 9:29
  • It's not a longtable, but a tabular, so it doesn't split across pages. – egreg Sep 2 '16 at 9:32
  • Erh, how is that even related to my comment? The data will be hard to understand in any case – daleif Sep 2 '16 at 9:32
  • Now, I upload the picture for easy understanding. – Umar Hayat Sep 2 '16 at 9:38
4

You have several options:

  • Redesign your table. Split the columns to multiple tables, if that is an option.

If that's not possible, you can change the appearance of the table:

  • Decrease the font size (e.g. using \small inside \begin{tabular}). In general, this is a bad idea as it will make reading the text harder. Not only because reading text at smaller sizes is more difficult, bot also because your eyes can get lost between all the columns and rows. (Although your caption might say "zoom in for more details" :) - but this is really bad style and not appropriate for printing).

  • Put your table at a separate landscape page.

  • Rotate the heading text. This is in particular useful if your headings are longer than the actual cell context.

  • Convey less information, e.g. reduce the number of significant digits.

With a combination of these, you should be able to produce a good-looking table. In particular, remember the first hint: Redesign your table if possible.

  • Sometimes you have to provide a data table (often in something like an appendix). When you get to this stage, a landscape page is commonly used. – Chris H Sep 2 '16 at 13:17
  • Sure, I completely understand that. That's why I also mentioned decreasing font size. My answer was intentionally kept more general (or vague …). – Martin Nyolt Sep 2 '16 at 13:20
  • My +1 was mainly for "landscape", but covering all the bases helped – Chris H Sep 2 '16 at 13:25
2

An alternative, if the protrusion of table to outer page margin is allowed:

enter image description here

Table design presented on above picture is based on guessing about your page layout. So, if it is different as assumed, the result will differ from showed.

In MWE I use few new packages:

  • booktabs for table rules
  • makecell for table column headings
  • tabularx for fit table in determined width of table
  • changepage for make more room for table with extension to outer border
  • calc for calculate allowed width of table
  • ˛siunitxfor columnS` which align numbers at decimal point.

In column heads i made some shortening of text. Complete MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\sffamily\bfseries\small}
\usepackage{siunitx}
\usepackage{calc}
\usepackage[strict]{changepage}
\usepackage[showframe
            ]{geometry}

\usepackage{lipsum}
\begin{document}
\lipsum[2]
    \setlength{\tabcolsep}{1.5pt}
    \noindent
\begin{adjustwidth}{}{-\marginparwidth-\marginparsep}
\begin{tabularx}{\linewidth}{X*{12}{S[table-format=-2.3]}
                             }
    \toprule
\multicolumn{12}{c}{%
    \thead{Panel B: Return and Profitability Descriptive Statistics}}\\
    \midrule
& {\thead[br]{Non\_\\ Dur.}} & {\thead[br]{Du-\\rable}}
                                        & {\thead[br]{Manu-\\factur.}}
& {\thead[br]{Oil \&\\ Gas}} & {\thead[br]{Chem.}}     
                                        & {\thead[br]{Bus\\ Eqp}}
& {\thead[br]{Phone\\\& TV}} & {\thead[br]{Util.}}     
                                        & {\thead[br]{Whole\\ Ret.}}
& {\thead[br]{Health\\care}} & {\thead[br]{Fin.}}      & {\thead[br]{Other}}  \\
    \midrule
ROE     &  0.077 &  0.057 &  0.034 &  0.031 &  0.026 & -0.069 & -0.927 & 1.096
        &  0.094 & -0.281 &  0.450 &  0.001 \\
        &  0.119 & -0.111 &  0.126 & -0.755 &  0.117 & -0.050 &  0.102 & 0.116
        &  0.059 &  0.067 &  0.100 & -0.000 \\
        & -1.067 &  6.948 & -2.569 &  7.551 & -1.519 & -0.240 & -0.930 & 3.766
        &  0.998 & -8.318 &  4.282 &  0.053 \\
    \midrule
CF      &  0.061 &  0.051 &  0.060 &  0.059 &  0.044 &  0.009 &  0.029 & 0.029
        &  0.062 & -0.140 &  0.003 &  0.038 \\
        &  0.062 &  0.069 &  0.058 &  0.076 &  0.058 &  0.042 &  0.054 & 0.037
        &  0.052 & -0.035 &  0.021 &  0.002 \\
        & -1.044 & -7.180 &  2.385 & -6.253 & -6.694 &-23.859 & -8.631 &-6.328
        & 11.392 &-37.083 & -6.982 &  7.542 \\
    \midrule
EBIT\_ 
        &  0.043 & -0.016 & -0.066 & -0.639 & -0.443 & -1.742 & -1.598 & 0.017
        & -0.012 &-17.730 &  0.018 & -1.102 \\
MAR     &  0.075 &  0.050 & -0.050 & -5.519 & 0.034  & -0.254 & -0.163 & 0.185
        & 0.020  & -8.070 &  0.095 & -0.137 \\
        & -2.244 & -6.142 & -0.519 & 10.781 & -4.773 & -5.256 & -1.514&-11.954
        & -2.024 & -5.218 & -0.509 & -8.969 \\
    \midrule
GM      &  0.340 & 0.262  & 0.217  &  0.152 &  0.146 & -0.847 & -0.696 & 0.221
        &  0.277 &-14.841 & 0.350  & -0.587 \\
        &  0.323 & 0.285  & 0.176  &  0.042 & 0.361  & 0.285  & 0.234  & 0.279
        &  0.237 & -7.230 & 0.276  &  0.165 \\
        &  2.168 & -2.748 & 1.644  &  0.820 & -5.184 & -4.208 & -1.029 &-9.724
        &  5.978 & -4.262 & 0.583  & -7.792 \\
    \midrule
TAX     &  0.339 &  0.309 &  0.221 &  0.264 &  0.278 &  0.141 &  0.263 & 0.392
        &  0.564 &  0.249 &  0.246 &  0.138 \\
        &  0.300 &  0.131 &  0.369 &  0.276 &  0.344 &  0.162 &  0.018 & 0.329
        &  0.306 &  0.207 &  0.204 &  0.216 \\
        &  1.820 &  5.471 & -3.440 & -0.289 & -3.618 & -1.018 &  3.346 & 2.985
        &  1.382 &  0.862 &  0.986 & -1.205 \\
    \midrule
RET12\_L 
        &  1.211 &  1.223 &  1.212 &  1.240 &  1.215 &  1.320 &  1.261 & 1.166
        &  1.239 &  1.322 &  1.144 &  1.232 \\
        &  1.217 &  1.241 &  1.208 &  1.257 &  1.176 &  1.312 &  1.293 & 1.151
        &  1.229 &  1.318 &  1.212 &  1.208 \\
        & -1.006 & -2.006 &  1.176 & -2.261 &  5.777 &  1.258 & -2.815 & 6.934
        &  1.854 &  0.631 &-23.983 &  6.033 \\
    \bottomrule
\end{tabularx}
\end{adjustwidth}
\lipsum[3]
\end{document}
1

This answer incorporates many of the suggestions from Martin Nyolt's answer, with some minor additions.

  • Instead of constantly writing \multicolumn… for every header-text, create a macro. That makes it a lot easier to change the format afterwards. Here, a macro called \tableheader{text} is created which is used instead. It is set to rotate the content 45 degrees, and not take up any space, except for some manual shifting.
  • suinitx is great for typesetting lots of numbers in tables, and is here used to align the numbers at the decimal point.
  • To write abbreviations in all caps looks a bit shouty. Consider writing them in small caps instead, by using \textsc{text} or \scshape. Numbers in text are often also prettier with old style figures. You can enable this throughout your document with some advice from Utilizing oldstyle figures without resorting to \oldstylenums, or just for a few numbers using \oldstylenums{123}.

You might also want to look into the booktabs-package, and use \toprule, \midrule, and `\bottomrule, for a more professional look to your table.

The first column

Also, an advanced table like this might in some cases be better to plot.

Output

enter image description here

Code

\documentclass{article}
\usepackage{rotating}
\usepackage{caption}
\usepackage{siunitx}

\newcommand{\tableHeader}[1]{%
  \multicolumn{1}{l}{\hspace*{2em}\makebox[0.0cm][l]{\rotatebox{45}{#1}}}
}
\begin{document}
  \setlength{\tabcolsep}{3pt}
\begin{sidewaystable}
  \centering
  \caption{Panel B: Return and Profitability Descriptive Statistics}
\begin{tabular}{l*{12}{S}}
    \hline\hline


    \hline
      &
      \tableHeader{Non\_Dur}&
      \tableHeader{Durable}&
      \tableHeader{Manufacturing}&
      \tableHeader{Oil \& Gas }&
      \tableHeader{Chemicals}&
      \tableHeader{Bus Eqp}&
      \tableHeader{Phone \& TV}&
      \tableHeader{Utilities}&
      \tableHeader{Whole\_Ret}&
      \tableHeader{Healthcare}&
      \tableHeader{Finance}&
      \tableHeader{Other}\\
    \hline

\textsc{roe}         &       0.077&       0.057&       0.034&       0.031&       0.026&      -0.069&      -0.927&       1.096&       0.094&      -0.281&       0.450&       0.001 \\
            &       0.119&      -0.111&       0.126&      -0.755&       0.117&      -0.050&       0.102&       0.116&       0.059&       0.067&       0.100&      -0.000 \\
            &      -1.067&       6.948&      -2.569&       7.551&      -1.519&      -0.240&      -0.930&       3.766&       0.998&      -8.318&       4.282&       0.053 \\
[0.5em]
\hline
\textsc{cf}         &       0.061&       0.051&       0.060&       0.059&       0.044&       0.009&       0.029&       0.029&       0.062&      -0.140&       0.003&       0.038 \\
            &       0.062&       0.069&       0.058&       0.076&       0.058&       0.042&       0.054&       0.037&       0.052&      -0.035&       0.021&       0.002 \\
            &      -1.044&      -7.180&       2.385&      -6.253&      -6.694&     -23.859&      -8.631&      -6.328&      11.392&     -37.083&      -6.982&       7.542 \\
[0.5em]
\hline
\textsc{ebit\_}    &       0.043&      -0.016&      -0.066&      -0.639&      -0.443&      -1.742&      -1.598&       0.017&      -0.012&     -17.730&       0.018&      -1.102 \\
\textsc{mar}            &       0.075&       0.050&      -0.050&      -5.519&       0.034&      -0.254&      -0.163&       0.185&       0.020&      -8.070&       0.095&      -0.137 \\
            &      -2.244&      -6.142&      -0.519&      10.781&      -4.773&      -5.256&      -1.514&     -11.954&      -2.024&      -5.218&      -0.509&      -8.969 \\
[0.5em]
\hline
\textsc{gm}          &       0.340&       0.262&       0.217&       0.152&       0.146&      -0.847&      -0.696&       0.221&       0.277&     -14.841&       0.350&      -0.587 \\
            &       0.323&       0.285&       0.176&       0.042&       0.361&       0.285&       0.234&       0.279&       0.237&      -7.230&       0.276&       0.165 \\
            &       2.168&      -2.748&       1.644&       0.820&      -5.184&      -4.208&      -1.029&      -9.724&       5.978&      -4.262&       0.583&      -7.792 \\
[0.5em]
\hline
\textsc{tax}         &       0.339&       0.309&       0.221&       0.264&       0.278&       0.141&       0.263&       0.392&       0.564&       0.249&       0.246&       0.138 \\
            &       0.300&       0.131&       0.369&       0.276&       0.344&       0.162&       0.018&       0.329&       0.306&       0.207&       0.204&       0.216 \\
            &       1.820&       5.471&      -3.440&      -0.289&      -3.618&      -1.018&       3.346&       2.985&       1.382&       0.862&       0.986&      -1.205 \\
[0.5em]
\hline
\textsc{ret\oldstylenums{12}\_l}    &       1.211&       1.223&       1.212&       1.240&       1.215&       1.320&       1.261&       1.166&       1.239&       1.322&       1.144&       1.232 \\
            &       1.217&       1.241&       1.208&       1.257&       1.176&       1.312&       1.293&       1.151&       1.229&       1.318&       1.212&       1.208 \\
            &      -1.006&      -2.006&       1.176&      -2.261&       5.777&       1.258&      -2.815&       6.934&       1.854&       0.631&     -23.983&       6.033 \\
\hline\hline
\end{tabular}
\end{sidewaystable}

\end{document}
1

I do not know this is good or bad. Thanks for response Martin Nyolt. Runar Trollet your code is also very good.

\setlength {\tabcolsep}{2pt}
\begin{tabular}{l*{12}{c}}
\hline\hline
\multicolumn{12}{l}{\hspace*{8em}\textbf{Panel B: Return and Profitability Descriptive Statistics}}\\
\hline
&\multicolumn{1}{c}{
\begin{sideways}
Non\_Dur\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Durable\,
\end{sideways}} 
&\multicolumn{1}{c}{
\begin{sideways}
Manufacturing\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Oil \& Gas\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Chemicals\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Bus Eqp\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Phone \& TV\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}    
Utilities\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}    
Whole\_Ret\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Health care\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}    
Finance\,
\end{sideways}}
&\multicolumn{1}{c}{
\begin{sideways}
Other\,
\end{sideways}}\\
\hline

ROE &0.077&0.057&0.034&0.031&0.026&-0.069&-0.927&1.096&0.094&-0.281&0.450&0.001 \\
    &0.119&-0.111& 0.126& -0.755& 0.117& -0.050& 0.102& 0.116& 0.059& 0.067& 0.100& -0.000 \\
    & -1.067& 6.948& -2.569& 7.551& -1.519& -0.240& -0.930& 3.766& 0.998& -8.318& 4.282& 0.053 \\
[0.5em]
\hline
CF & 0.061& 0.051& 0.060& 0.059& 0.044& 0.009& 0.029& 0.029& 0.062& -0.140& 0.003& 0.038 \\
 & 0.062& 0.069& 0.058& 0.076& 0.058& 0.042& 0.054& 0.037& 0.052& -0.035& 0.021& 0.002 \\
 & -1.044& -7.180& 2.385& -6.253& -6.694& -23.859& -8.631& -6.328& 11.392& -37.083& -6.982& 7.542 \\
[0.5em]
\hline
EBIT\_MAR & 0.043& -0.016& -0.066& -0.639& -0.443& -1.742& -1.598& 0.017& -0.012& -17.730& 0.018& -1.102 \\
 & 0.075& 0.050& -0.050& -5.519& 0.034& -0.254& -0.163& 0.185& 0.020& -8.070& 0.095& -0.137 \\
 & -2.244& -6.142& -0.519& 10.781& -4.773& -5.256& -1.514& -11.954& -2.024& -5.218& -0.509& -8.969 \\
[0.5em]
\hline
GM & 0.340& 0.262& 0.217& 0.152& 0.146& -0.847& -0.696& 0.221& 0.277& -14.841& 0.350& -0.587 \\
 & 0.323& 0.285& 0.176& 0.042& 0.361& 0.285& 0.234& 0.279& 0.237& -7.230& 0.276& 0.165 \\
 & 2.168& -2.748& 1.644& 0.820& -5.184& -4.208& -1.029& -9.724& 5.978& -4.262& 0.583& -7.792 \\
[0.5em]
\hline
TAX & 0.339& 0.309& 0.221& 0.264& 0.278& 0.141& 0.263& 0.392& 0.564& 0.249& 0.246& 0.138 \\
 & 0.300& 0.131& 0.369& 0.276& 0.344& 0.162& 0.018& 0.329& 0.306& 0.207& 0.204& 0.216 \\
 & 1.820& 5.471& -3.440& -0.289& -3.618& -1.018& 3.346& 2.985& 1.382& 0.862& 0.986& -1.205 \\
[0.5em]
\hline
RET12\_L & 1.211& 1.223& 1.212& 1.240& 1.215& 1.320& 1.261& 1.166& 1.239& 1.322& 1.144& 1.232 \\
 & 1.217& 1.241& 1.208& 1.257& 1.176& 1.312& 1.293& 1.151& 1.229& 1.318& 1.212& 1.208 \\
 & -1.006& -2.006& 1.176& -2.261& 5.777& 1.258& -2.815& 6.934& 1.854& 0.631& -23.983& 6.033 \\
\hline\hline
\end{tabular}

enter image description here

  • 1
    I'd say you really shouldn't do this. Placing text vertically is very bad for your readers. They will have to keep rotating either their head or the page. The alignment is off, have a look at your decimal of negative values compared to positive values. The heading text should probably be in a caption, inside a table. Then you can also reference your table with \ref{label}, \pageref{label}, or \cref{label} if using cleverref-package. – Runar Sep 2 '16 at 15:06
  • It looks like you've got two separate accounts, which means you cannot edit your original post or leave comments. The Stack Exchange staff can merge them together for you. – Andrew Swann Sep 2 '16 at 15:12
  • you are also probably exceeding the textarea also, with the table spilling into the margins, and possibly more, with some warnings in the logs. This of course depends on what kind of page you are using, and how you set up your page, but for all regular sizes, I think this would be too big. You can check this using the package showframe, which adds some borders. Disable it before you hand in your paper. – Runar Sep 2 '16 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.