2

I am using the longtable environment in combination with the siunitx package for 3 of my 10 columns. Unfortunately, when compiling the spacing of those three columns is not automatically adjusted. When using table-column-width the spacing of my top row with comments to the section is not adjusted accordingly. Please see my code (excerpt) and the output below, first without using the table-column-width command and then with respective command.

\documentclass[11pt,a4paper,oneside]{article}
\usepackage{setspace} 
\onehalfspacing

\usepackage[round]{natbib}
\usepackage{array}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[group-separator={.}]{siunitx}
\usepackage{booktabs,multirow} 
\renewcommand{\thetable}{\Roman{table}}

\usepackage[english]{babel}

\usepackage[margin=1in]{geometry}
\usepackage[small,bf,labelsep=period]{caption}

% -------------------------------------------------------------------
\begin{document}

\newpage
\begin{landscape}
{\small\begin{longtable}{lccccccS[table-format=2.4, table-column-width=60pt]S[table-format=1.4,  table-column-width=60pt]S[table-format=1.4,  table-column-width=60pt]}
\caption[Significant contributions]{Significant contributions} \label{tab:contributionscharacteristics} \\ 
\multicolumn{10}{p{.9\linewidth}}{Lorem ipsum dolor sit amet, consectetur adipiscing elit. In pharetra lobortis elit nec consectetur. Nulla accumsan lacus a diam varius, eget eleifend augue egestas. Nulla porttitor lacus turpis, in elementum tortor pellentesque sit amet. Mauris interdum ante ac velit fermentum, sed faucibus nisi elementum. Duis pretium lacinia nunc, quis maximus lectus facilisis id. Aliquam ornare dapibus risus, sed congue quam eleifend id. Donec vel fringilla lacus. Aenean blandit viverra quam, nec imperdiet ante volutpat ut. Mauris non dapibus eros. Suspendisse luctus feugiat tortor, quis consectetur metus facilisis vitae. Aenean imperdiet est sodales arcu ultrices lacinia. Duis nunc augue, egestas nec lacus ac, egestas porttitor nibh. Donec sed lorem sit amet ipsum vulputate consectetur in ut lorem. Nunc mattis luctus magna. } \\ 
\\
\hline
\rule{0pt}{3ex}  
 \multirow{2}{*} {{Author(s) and country of analysis}}&\multicolumn{2}{c} {{Sample}} & \multicolumn{2}{c} {{Event}} & \multirow{2}{*} {{Weighting}} & \multirow{2}{*} {{Type\textsuperscript{b}}} & \multicolumn{3}{c}{\hspace{15pt}{Key results}} \\
& \multicolumn{1}{c}{Period} & \multicolumn{1}{c}{Size} & \multicolumn{1}{c}{Window}\textsuperscript{a} & \multicolumn{1}{c}{Date}\textsuperscript{b} &  & & \multicolumn{1}{c}{BHAR}& \multicolumn{1}{c}{Alphas}& \multicolumn{1}{c}{CTAR}\\
\hline \\ [-2ex]
\endfirsthead
\multicolumn{10}{c}%
{\small{{\bfseries \tablename\ \thetable.{}} Significant contributions (continued)}} \\ [1ex]
\hline
\endhead
\hline \multicolumn{10}{r}{{Continued on next page}} \\
\endfoot
\endlastfoot
\cite{Loughran1997}, US & 1970-1989 & 234 & $[+1, +60]$ & Co&  EW & C &     0.3050\textsuperscript{1,2}* & & \\
& &300 &  &  & EW & S & -0.2400\textsuperscript{1,2}*** & & \\
\cite{Mitchell2000}, US & 1961-1993 & 1,029 & $[+1, +36]$ & Co & EW & S & -0.0840\textsuperscript{1}*** & -0.0900\textsuperscript{7}*** &  -0.0828\textsuperscript{4}*** \\
&  &  &  &  &  VW & S & -0.0530\textsuperscript{1}***& -0.0432\textsuperscript{7}*&   -0.0468\textsuperscript{4}***\\
&  & 1,039  &  &  &  EW & NC & 0.0640\textsuperscript{1}**& -0.0144\textsuperscript{7}*&  -0.0252\textsuperscript{4}\\
\hline
\end{longtable}
}
\end{landscape}

\end{document}

Without table-column-width command Without table-column-width command

With table-column-width command, as visible the section above with the description does not allign nicely With table-column-width command, as visible the section above with the description does not allign nicely

3
  • I have edited and added the complete compilable code. This is a quick compliation of my whole document, generally I do work with subdocuments which are the included. Jul 20, 2015 at 20:17
  • Please try to give us just the stuff we need to reproduce the tables. We don't need details of your ToC or list of abbreviations or headers or... ;).
    – cfr
    Jul 21, 2015 at 2:48
  • Did another edit, hope this is now sufficient. Left some details which are necessary in order that the formatting of the page is not odd. Results when using table-column width or not are the same as provided in the picture above. Jul 21, 2015 at 8:47

1 Answer 1

2

You have to put your table-note-marks in braces and add them to the siunitx column width calculation.

% arara: pdflatex    

\documentclass[11pt,a4paper,oneside]{article}
\usepackage[english]{babel}
\usepackage{setspace} 
\onehalfspacing
% not needed here... but you should prefer this over color
\usepackage{xcolor}
\usepackage{pdflscape}
\usepackage{longtable}
\usepackage[group-separator={,}]{siunitx}
% if you load booktabs, use it. See \toprule and so on...
% you have been loading the following two packages twice
\usepackage{booktabs,multirow} 
\renewcommand{\thetable}{\Roman{table}}
\usepackage[margin=1in]{geometry}
\usepackage[small,bf,labelsep=period]{caption}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\headrulewidth}{0.2pt}
% just for demo
\usepackage{blindtext}
% should be the last package in most cases
\usepackage[pdftex,bookmarks,colorlinks]{hyperref}

\begin{document}
\begin{landscape}
    {\small\begin{longtable}{@{}lcS[table-format=3.3]ccllS[table-format=-1.4, table-space-text-post = $^{1,2***}$]S[table-format=-1.4, table-space-text-post = $^{7***}$]S[table-format=-1.4, table-space-text-post = $^{4***}$]@{}}
            \caption[Hello]{Hello} \label{tab:contributionscharacteristics}\\
            \multicolumn{10}{p{.98\linewidth}}{\blindtext} \\\addlinespace 
            \toprule
            %\rule{0pt}{3ex} % this is not needed with booktabs and you were inserting some unwanted white space in front of your first cell with this
            \multirow{2}{*}{Author(s) and country of analysis} & \multicolumn{2}{c}{Sample} & \multicolumn{2}{c}{Event} & \multirow{2}{*}{Weighting} & \multirow{2}{*}{Type\textsuperscript{b}} & \multicolumn{3}{c}{Key results} \\\cmidrule(lr){2-3}\cmidrule(lr){4-5}\cmidrule(lr){8-10}
            & Period & {Size} & Window\textsuperscript{a} & Date\textsuperscript{b} & & & {BHAR} & {Alphas} & {CTAR} \\
            \midrule
            \endfirsthead
            {\small{{\bfseries \tablename\ \thetable.{}} Significant contributions (continued)}} \\
            \toprule
            \endhead
            \bottomrule \multicolumn{10}{r}{Continued on next page} \\
            \endfoot
            \endlastfoot
            \cite{Loughran1997}, US & 1970--1989 & 234 & $[+1, +60]$ & Co&  EW & C &     0.3050{$^{1,2*}$} & & \\
            & &300 &  &  & EW & S & -0.2400{$^{1,2***}$} & & \\
            \cite{Mitchell2000}, US & 1961--1993 & 1,029 & $[+1, +36]$ & Co & EW & S & -0.0840{$^{1***}$} & -0.0900{$^{7***}$} &  -0.0828{$^{4***}$} \\
            &  &  &  &  &  VW & S & -0.0530{$^{1***}$} & -0.0432{$^{7*}$}&   -0.0468{$^{4***}$}\\
            &  & 1,039  &  &  &  EW & NC & 0.0640{$^{1**}$} & -0.0144{$^{7*}$}&  -0.0252{$^{4}$}\\
            \bottomrule
        \end{longtable}}
\end{landscape}
\end{document}

enter image description here

The first and last column are stretched a bit. As I do not know, how your longtable will look in the end, I did not tweak around with that.

2
  • Thank you for the quick answer, after adjusting and considering your inputs, this was the solution! Jul 21, 2015 at 10:09
  • @Nevertoolate You are welcome
    – LaRiFaRi
    Jul 21, 2015 at 10:38

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.