I'm using the longtable environment with the field p{0.5\textwidth}
. The text on that field is set with very odd spacing, because latex attempts to justify it both for the left and right column margins. I tried setting \raggedright
for the entire document, but this has no effect on the text in the field. Can anyone suggest a quick fix?
[Tex/LaTex] line-breaking in longtable
horizontal alignmentlongtabletables
Related Solutions
I think a source of the problem is that whereas you define the table to have 19 columns in total, you actually only have 13 columns (1 header column and 12 data columns). Fixing this issue -- mainly by getting rid of unnecessary &
alignment characters -- lets the table fit into the available space just fine, without having to switch to a smaller font.
By the way, if one uses the rule-drawing commands of the booktabs
package, one should not use vertical bars as well, in part because the vertical lines will not join up correctly with the horizontal rules.
(I rotated the image below 90 degrees only to make it easier to display in this space.)
\documentclass[a4paper]{article}
\usepackage{lscape,booktabs,longtable}
\begin{document}
\begin{landscape}
\setlength\LTcapwidth{\textwidth} % default: 4in (rather less than \textwidth...)
\setlength\LTleft{0pt} % default: \parindent
\setlength\LTright{0pt} % default: \fill
\begin{longtable}{@{}l@{\extracolsep{\fill}}*{12}{c}@{}}
\caption{Multinomial logistic regression results for daily data of the major Eurozone, US, and UK market indices, January 1, 2005, to 20 July, 2012.} \label{grid_mlmmh} \\
\toprule
& \multicolumn{6}{c}{Bottom tails} & \multicolumn{6}{c}{Top tails} \\
\cmidrule(r){2-7} \cmidrule(l){8-13}
% 2 orizonties grammes aristera kai deksia
& \multicolumn{2}{c}{(1)} & \multicolumn{2}{c}{(2)} & \multicolumn{2}{c}{(3)}
& \multicolumn{2}{c}{(4)} & \multicolumn{2}{c}{(5)} & \multicolumn{2}{c}{(6)} \\
\cmidrule(r){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
\cmidrule(lr){8-9} \cmidrule(lr){10-11} \cmidrule(l){12-13}
% 2 orizonties grammes aristera kai deksia \\
& Coeff & $\Delta$Prob & Coeff & $\Delta$Prob & Coeff & $\Delta$Prob
& Coeff & $\Delta$Prob & Coeff & $\Delta$Prob & Coeff & $\Delta$Prob \\
\midrule
\endfirsthead
\multicolumn{7}{@{}l}%
{{\bfseries \tablename\ \thetable{} --- continued from previous page}} \\
\midrule[\heavyrulewidth]
& \multicolumn{6}{c}{Bottom tails} & \multicolumn{6}{c}{Top tails} \\
\cmidrule(r){2-7} \cmidrule(l){8-13}
% 2 orizonties grammes aristera kai deksia
& \multicolumn{2}{c}{(1)} & \multicolumn{2}{c}{(2)} & \multicolumn{2}{c}{(3)}
& \multicolumn{2}{c}{(4)} & \multicolumn{2}{c}{(5)} & \multicolumn{2}{c}{(6)} \\
\cmidrule(r){2-3} \cmidrule(lr){4-5} \cmidrule(lr){6-7}
\cmidrule(lr){8-9} \cmidrule(lr){10-11} \cmidrule(l){12-13}
% 2 orizonties grammes aristera kai deksia \\
& Coeff & $\Delta$Prob & Coeff & $\Delta$Prob & Coeff & $\Delta$Prob
& Coeff & $\Delta$Prob & Coeff & $\Delta$Prob & Coeff & $\Delta$Prob \\
\midrule
\endhead
\midrule[\heavyrulewidth]
\multicolumn{13}{r}{Continued on next page} \\
\endfoot
\bottomrule
\endlastfoot
PIIGS \\
$\beta_{01}$ (const.)
& 100 & 0.8 & 0.021 & 0.018 & 0.043 & 0.146 & 0.074 & 0.427 & 0.019 & 0.427 & 0.019 & 0.427 \\
Log-likel. \\
Pseudo-$R^{2}$ \\[2ex]
Non-PIIGS \\
$\beta_{01}$ (const.)
& 100 & 0.8 & 0.021 & 0.018 & 0.043 & 0.146 & 0.074 & 0.427 & 0.019 & 0.427 & 0.019 & 0.427 \\
Log-likel.\\
Pseudo-$R^{2}$ \\
\end{longtable}
\end{landscape}
\end{document}
This isn't quite what you asked for, but it may do in a pinch. The problem in odd-sized column width seems to arise when a multicolumn extends past the natural width of the table. So I placed your lipsum in a \parbox
called \tmp
, and then placed it in a 9-column multicolumn with makebox[0pt]{\tmp}
(a zero-width box), so that the width of \tmp
would not screw up the natural spacing of the table.
This solution has two drawbacks:
1) The table does not extend to the margins, but assumes its natural width, which was not what you asked for; and
2) A tweak is required to the width of the \parbox
name d\tmp
to make it conform to the natural width of the table. Here, I subtracted 4ex
from the full width, which is given by \linewidth
.
\documentclass[11pt]{article}
\usepackage[nolists]{endfloat}
\usepackage{comment}
\usepackage[margin=2.5cm]{geometry}
\usepackage{natbib,amssymb}
\setlength{\bibsep}{0pt plus 0.3ex}
\usepackage[affil-it]{authblk}
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{siunitx}
\usepackage{lipsum}
\usepackage[FIGBOTCAP]{subfigure}
\usepackage{float}
\usepackage{catchfile,tikz}
\usepackage{filecontents}
\usepackage{silence}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{shapes,trees}
\usepackage{pdflscape }
\usepackage{eurosym}
%\usepackage[T1]{fontenc}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{lipsum}
\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}%Need for STATA tables
\newenvironment{lgtable}
{\begin{landscape}\begin{longtable}}
{\end{longtable}\end{landscape}}
% make it known to endfloat
\DeclareDelayedFloatFlavor{lgtable}{table}
\begin{document}
\def\tmp{\parbox{\linewidth-4ex}{\footnotesize\lipsum[3-4]\vspace{1ex}}}
\begin{lgtable}{@{\extracolsep{\fill}}l*{8}{c}}
\caption{Regression Estimation: Blank, S(1)}
\label{table:first}\\
\multicolumn{9}{c}{\makebox[0pt]{\tmp}}%
\\
\toprule
\multicolumn{9}{c}{Some text}\\
\midrule
&Blank& \multicolumn{3}{c}{Some title}&\multicolumn{3}{c}{Some title}& Pooled\\
\midrule
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)} &\multicolumn{1}{c}{(7)} &\multicolumn{1}{c}{(8)} \\
& Blank &Blank, abcs &Blank, abcs &Blank, abcs & Blank, Abc & Blank, Abc & Blank, Abc &Blank, Pooled \\
\midrule
S(1) & 0.900\sym{***}& 0.887\sym{***}& 0.876\sym{***}& 0.239\sym{***}& 0.988\sym{***}& 0.952\sym{***}& 0.330 & 0.258\sym{***}\\
\bottomrule
\newpage
\multicolumn{9}{c}{Table \ref{table:first}: (continued)}\\
\toprule
\multicolumn{9}{c}{Panel B: Seom text}\\
\midrule
&Blank& \multicolumn{3}{c}{Some title}&\multicolumn{3}{c}{Some title}& Pooled\\
\midrule
&\multicolumn{1}{c}{(1)} &\multicolumn{1}{c}{(2)} &\multicolumn{1}{c}{(3)} &\multicolumn{1}{c}{(4)} &\multicolumn{1}{c}{(5)} &\multicolumn{1}{c}{(6)} &\multicolumn{1}{c}{(7)} &\multicolumn{1}{c}{(8)} \\
& Blank &Blank, abcs &Blank, abcs &Blank, abcs & Blank, Abc & Blank, Abc & Blank, Abc &Blank, Pooled \\
\midrule
S(1) & 0.900\sym{***}& 0.887\sym{***}& 0.876\sym{***}& 0.239\sym{***}& 0.988\sym{***}& 0.952\sym{***}& 0.330 & 0.258\sym{***}\\
\bottomrule
\end{lgtable}
\end{document}
p.s. Any attempts to extend the natural width of the table ended up adding space only to the last column, which caused me to abandon those attempts.
Best Answer
If you want to apply this to all
p
-columns you could consider this:From the documentation:
If you want to apply
\RaggedRight
only to a particular column, you can insert it into its format definition:>{\RaggedRight}p{0.5\textwidth}
.