3

I would like to have a table description underneath the title and above the table itself. In addition, I want the description to be as width as the table itself. I know that the description part is frequently asked over the web, but I didn't manage to find an answer on the width so far. With the help of Jörg Weber his tutorials (See: 1 2 and 3) I came up with the following code in which I want to place the \figtext part in between the title and table:

\newcommand{\sym}[1]{\rlap{#1}}% Thanks to David Carlisle
\let\estinput=\input% define a new input command so that we can still flatten the document

\newcommand{\estwide}[3]{
    \vspace{.75ex}{
        \begin{tabular*}
            {\textwidth}{@{\hskip\tabcolsep\extracolsep\fill}l*{#2}{#3}}
            \toprule
            \estinput{#1}
            \bottomrule
            \addlinespace[.75ex]
        \end{tabular*}
    }
}   

\newcommand{\estauto}[3]{
    \vspace{.75ex}{
        \begin{tabular}{l*{#2}{#3}}
            \toprule
            \estinput{#1}
            \bottomrule
            \addlinespace[.75ex]
        \end{tabular}
    }
}

% Allow line breaks with \\ in specialcells
\newcommand{\specialcell}[2][c]{%
    \begin{tabular}[#1]{@{}c@{}}#2\end{tabular}}

% *****************************************************************
% Custom subcaptions
% *****************************************************************
% Note/Source/Text after Tables
\newcommand{\figtext}[1]{
    \vspace{-1.9ex}
    \captionsetup{justification=justified,font=footnotesize}
    \caption*{\hspace{6pt}\hangindent=1.5em #1}
}

\usepackage{threeparttable}% Alternative for Notes below table

% Note/Source/Text after Tables
\newcommand{\Figtext}[1]{%
    \begin{tablenotes}[para,flushleft]
        %\hspace{6pt}
        %\hangindent=1.75em
        #1
    \end{tablenotes}
}
\begin{document}
...
\begin{table}[H]\centering
    \begin{threeparttable}
    \caption{Descriptive statistics per REIT}
    \estauto{C:/Users/.../Panel_Constituents.tex}{6}{r}
    \Figtext{\small{All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.}}
    \label{Descriptives}
    \end{threeparttable}
\end{table}
...
\end{document}

                    &      Assets&        Debt&      Equity&   MarketCap&    Leverage&      Return\\
\midrule
mean                &   2,884,654&   1,443,272&   1,226,602&   2,169,579&      0.4753&        3.17\\
min                 &       8,142&           0&  -1,787,348&       1,910&      0.0000&       -8.31\\
max                 &  25,324,830&  17,978,696&   9,999,590&  32,474,382&      1.1650&       31.46\\
sd                  &   3,679,338&   2,163,937&   1,443,727&   3,809,827&      0.1712&        2.89\\

This leads to the following table:

Furthermore, the vertical space between the lines is now much wider than in my other tables for which I use the table and tabular environment. Is there a way to solve this as well? If i'm being unclear or something, sorry for that, I'm pretty new to all of this...

Edit: I managed to remove the extra vertical spacing in the table by removing a part in the Stata code, more specifically by removing the -gaps- option from esttab.

Edit 2: I don't know exactly how the \estauto command works (that's why I basically copied it), but inside the panel_constituents.tex file is the code shown at the bottom.

  • please merge your code snippet to one, complete document beginning with \documentclass{...} ans ending with end{document. – Zarko Dec 15 '17 at 9:54
  • why you not put description in \multicolumn environment? – Zarko Dec 15 '17 at 9:56
  • @Zarko, I'm not sure how to do that. Would the command be \multicolumn{7}{c}{description text}? If I put that inside the tabular environment in the imported .tex file it places the whole description on one line making the table go of the page. Furthermore, the values in the table might change since i'm still running some tests in Stata which alters the .tex file if Stata is ran. – Sukaldi Dec 15 '17 at 10:03
  • (i) provide code in for of small document by which you generate showed table. it is not fun to set your table from scratch ... help us to help you! (ii) ˙\multicolumn{1}{p{<table width<}{description text}`. i can show you how to do this, but after then when you will do (i) :-) – Zarko Dec 15 '17 at 10:08
  • Sorry, I thought this was sufficient. As said, I don't know how the \estauto command works exactly and thus I just put the code from the .tex file under the rest. I know this still requires you to copy paste it (probably) but I don't know how to present it accurately, sorry. Regarding your second point, I will try to figure this out myself. – Sukaldi Dec 15 '17 at 10:19
2

Some improvements with siunitx, and a description using a simple \multicolumn:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{tabularx, booktabs, caption, makecell, float}
\captionsetup{justification=justified,font=footnotesize}
\usepackage{siunitx}

\begin{document}

\begin{table}[H]
  \sisetup{table-format = 8.0, table-number-alignment = center, group-separator = {,}}
  \centering\setlength{\tabcolsep}{5pt}\setlength{\extrarowheight}{2pt}
  \caption{Descriptive statistics per REIT}
  \begin{tabularx}{\linewidth}{@{\,}>{\bfseries}X*{4}{S}S[table-format = 1.4]S[table-format = -1.2]@{\,}}
    \multicolumn{7}{@{}>{\footnotesize}p{\linewidth}@{}}
    {All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.} \\
    \addlinespace[1ex]
    \toprule
         & {Assets} & {Debt} & {Equity} & {MarketCap} & {Leverage} & {Return} \\
    \midrule
    mean & 2884654 & 1443272 & 1226602 & 2169579 & 0.4753 & 3.17 \\
    min & 8142 & 0 & -1787348 & 1910 & 0.0000 & -8.31 \\
    max & 25324830 & 17978696 & 9999590 & 32474382 & 1.1650 & 31.46 \\
    sd & 3679338 & 2163937 & 1443727 & 3809827 & 0.1712 & 2.89 \\
    \bottomrule
  \end{tabularx}
  \label{Descriptives}
\end{table}

\end{document}

enter image description here

|improve this answer|||||
2

i guess that you looking for something like this (but i'm not sure, from your code snippets is impossible figured out what you like to do):

\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs, tabularx, threeparttable}

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}
    \caption{Descriptive statistics per REIT}
    \label{Descriptives}
\begin{threeparttable}
    {\medskip\small
    All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.
    }
    \medskip
\begin{tabularx}{\linewidth}{l *{6}{X}}
    \toprule
        &   Assets   &   Debt     &   Equity   &  MarketCap &   Leverage &   Return \\
    \midrule
mean    &  2,884,654 &  1,443,272 &  1,226,602 &  2,169,579 & 0.4753     &  3.17    \\
min     &      8,142 &          0 & -1,787,348 &      1,910 & 0.0000     & -8.31    \\
max     & 25,324,830 & 17,978,696 &  9,999,590 & 32,474,382 & 1.1650     & 31.46    \\
sd      &  3,679,338 &  2,163,937 &  1,443,727 &  3,809,827 & 0.1712     &  2.89    \\
    \bottomrule
\end{tabularx}
\end{threeparttable}
    \end{table}
    \end{document}

this gives:

enter image description here

table can be improved with use of S columns from siunitx package, but first let me know, if i'm on right track ...

edit: alternative solution with use siunitx and caption package:

\documentclass{article}
\usepackage{geometry}
\usepackage[table]{xcolor}
\usepackage{booktabs, tabularx, threeparttable}
\usepackage{siunitx}
\usepackage[skip=1ex]{caption}

%-------------------------------- show page layout, only for test
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
    \begin{table}
\sisetup{group-four-digits,
         group-separator={,}
         }
    \caption{Descriptive statistics per REIT}
    \label{Descriptives}
    \centering
\begin{threeparttable}
    \caption*{\footnotesize
    All values depict the averages per REIT over the whole analyzed period. Values for Assets, Debt, Equity and Market Capitalization are reported in thousand US.
            }
\begin{tabular}{l *{4}{S[table-format=8.0]}
                  *{2}{S[table-format=2.4,
                         group-separator={\;}]} }
    \toprule
        & {Assets}   &   {Debt}   &   {Equity} & {MarketCap}& {Leverage} & {Return} \\
    \midrule
mean    &  2 884 654 &  1 443 272 &  1 226 602 &  2 169 579 & 0.4753     &  3.17    \\
min     &      8 142 &          0 & -1 787 348 &      1 910 & 0.0000     & -8.31    \\
max     & 25 324 830 & 17 978 696 &  9 999 590 & 32 474 382 & 1.1650     & 31.46    \\
sd      &  3 679 338 &  2 163 937 &  1 443 727 &  3 809 827 & 0.1712     &  2.89    \\
    \bottomrule
\end{tabular}
\end{threeparttable}
    \end{table}

\end{document}

enter image description here

|improve this answer|||||
  • Exactly that! Awesome. But can this work as well as when I want to input the values using a different .tex file? Off-topic: Are there instructions on stackexchange, which could tell me what I need to do to make it so that people can help me more easily? – Sukaldi Dec 15 '17 at 10:52
  • (i) you mean that table body is in different file? simplest is thaqn have there complete table. otherwise you should look to package `pgfplotstable. off-topic: see tex.meta.stackexchange.com/questions/228/…. – Zarko Dec 15 '17 at 12:02
  • Yes, that is what I meant. Let me clarify: I use Stata to generate my tables. Stata offers the option to generate a table output in a .tex file so that it can be imported in LaTeX. That is the reason for the directory in the \estauto command. I export my tables from Stata such that they only include the body of the table, since it should be easier to adjust headers etc. in LaTeX. – Sukaldi Dec 15 '17 at 12:41
  • sory, i'm not familiar with stata. i haven't any clue what is the stata if it conatain & for column delimeters, than you can simple include this data. if not, than you should stick with \estauto macro or use pgfplotstable package. – Zarko Dec 15 '17 at 12:46
  • Stata is statistical program like SPSS and others. I use it to perform my regressions and other tests. Thanks a lot for your help. this does the trick :) – Sukaldi Dec 15 '17 at 13:12

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.