3

I use XeTeX Version 3.14159265-2.6-0.99992 (TeX Live 2015/W32TeX). I am typesetting a book with lots of sloppypar with longtables. I followed this thread to use \LTpre and \LTpost to reduce spacing before and after a longtable. I still face three issues:

1) Setting \LTpre to 0pt results in less space before the longtable than the line spacing. 2) Setting \LTpost to 0pt results in more space after the longtable than the line spacing. 3) Some longtables are needed to be typeset entirely in boldface. For this I enclose the entire longtable inside a \textbf{}. This adds some additional space before the table which would otherwise not be present without boldface

Here is an MWE

\documentclass[12pt]{book}
\usepackage{ragged2e}
\raggedbottom
\usepackage{polyglossia}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{0pt}
\begin{document}
\begin{sloppypar}\hyphenrules{nohyphenation}\lipsum[2]\end{sloppypar}
{\centering
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
}
\begin{sloppypar}\hyphenrules{nohyphenation}\lipsum[2]\end{sloppypar}
{\centering\textbf{
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
}}
\end{document} 

And the output

enter image description here

EDIT 1 on 2015-12-19 0450 IST

The solution by @daleif solves issue 3. But issues 1 and 2 are still there. For better clarity, I added a grid on the page with this code:

\documentclass[12pt]{book}
\usepackage{ragged2e}
\raggedbottom
\usepackage[top=0pt,left=0pt,bottom=0pt,right=0pt,width=396pt,height=612pt]{geometry}
\usepackage[step=18pt]{pagegrid}
\pagegridsetup{top-left}
\usepackage{polyglossia}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{0pt}
\begin{document}
\fontsize{12}{18}\selectfont
\vspace*{6.5pt}
\begin{sloppypar}\hyphenrules{nohyphenation}
\lipsum[2]
\end{sloppypar}
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
\begin{sloppypar}\hyphenrules{nohyphenation}
\lipsum[2]
\end{sloppypar}
{\bfseries
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
}
\begin{sloppypar}\hyphenrules{nohyphenation}
\lipsum[2]
\end{sloppypar}
\end{document}

And here is the output. Note how the rows of the longtable are shifted up slightly, ie their baselines are not on the grid whose unit is same as the line spacing.

enter image description here

  • 1
    What exactly are you trying to do with that {\centering ... } contruction, that has no effect on longtable anyway. Plus removing the sloppypar then things look fine – daleif Dec 18 '15 at 15:12
  • @daleif using sloppypar is a constraint as I want to avoid hyphenation. The book is in Devanagari script where TeX's hyphenation is not the best. The problem remains even on removing {\centering ... } – user22209 Dec 18 '15 at 15:24
2

If you dislike this... er, this... feature of longtable, then there is an independent package available to patch the code to disable it.

The behaviour has nothing to do with XeTeX or sloppypar or similar. Here's the output from a version of the example from daleif's answer with the grid from the question and the patch applied:

patched spacing

\documentclass[12pt]{book}
\usepackage{ragged2e}
\raggedbottom
\usepackage[top=0pt,left=0pt,bottom=0pt,right=0pt,width=396pt,height=612pt]{geometry}
\usepackage[step=18pt]{pagegrid}
\pagegridsetup{top-left}
\usepackage{longtable,ltabptch}
\usepackage{lipsum}
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{0pt}
\begin{document}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
{\bfseries\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
\end{document}
  • Perfect. No spacing issues on including ltabptch. While both the answer by daleif and cfr helped solve parts of the problem, I have chosen this answer (though upvoted both). Thanks. – user22209 Dec 19 '15 at 23:32
4

I don't see any spacing issues here (Xelatex, TexLive 2015):

\documentclass[12pt]{book}
\usepackage{ragged2e}
\raggedbottom
\usepackage{polyglossia}
\usepackage{longtable}
\usepackage{lipsum}
\setlength{\LTpre}{0pt}
\setlength{\LTpost}{0pt}
\begin{document}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
{\bfseries\begin{longtable}{ll} C11 & C12\\C21 & C22 \end{longtable}}
\begin{sloppypar}
  \lipsum[2]
\end{sloppypar}
\end{document} 

enter image description here

  • Thanks, this solves issue (3). But (1) and (2) are still there. If you carefully observe , the space between the baseline of the last row in sloppypar and the baseline of the first row in longtable is less than that between two consecutive baselines in the sloppypar. Similarly, space between the baseline of the last row in longtable and the baseline of the first row in the following sloppypar is more than that between two consecutive baselines in the sloppypar. For this reason, I have upvoted your answer but not accepted it. – user22209 Dec 18 '15 at 23:00

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.