# [texhax] Update: Longtable question (partial) solution.

Beuthe, Thomas beuthet at aecl.ca
Mon Mar 8 05:20:03 CET 2010

UNRESTRICTED | ILLIMITÉ

No nibbles to my earlier question, but I have kept on digging...

I have found an answer to my first problem thanks to the efforts of Daniel Lemire at the following link:
He states:
" Here's an annoying longtable bug for those of you using LaTeX for a living. Sometimes, but rarely so,
a longtable will break at the oddest places when using horizontal lines (hline), including right after the header.
The solution is to define a special kind of hline called "nobreakhline" and use that instead where you don't want any page breaks."

The code is as follows:

\makeatletter
\def\nobreakhline{%
\noalign{\penalty10000}}
\makeatother

and it does exactly what I want.  Since the document is being mechanically generated,
replacing all \hline occurrences after the header with \nobreakhline is a snap.
I tested it and it works as advertised.  No more orphaned longtable headers.

On my second problem I am still clueless however, in spite of lots of testing over the weekend.
Is there any way of inextricably binding a section break with the longtable that occurs immediately after it
so that the section head can never be orphaned at the bottom of the page?  Doing this may cause ugly
page breaks (lots of white space at the bottom of a page), but that really doesn't matter in this case.
Raising the widow/orphan penalty doesn't help, and messing with the before or after skip parameters
didn't seem to help either.

Is there any way of doing this in a general way without manual intervention?

Any thoughts?  I really didn't find anything up to now.
Section breaks and longtables don't seem to be good bed partners at times.

Thomas

=======================================
Hello all,

I'm overseeing the production of some large documents that are almost entirely mechanically generated.
Large portions consist of sections that contain only longtables and no other text or features.
Example:

\subsection{A}
longtable here
\subsection{B}
another longtable here
and so on

This can cause funny pagebreaks sometimes where a section heading is orphaned
at the bottom of the page because the only thing following it is a longtable before the next
section break occurs.

It can also cause situations where the section break occurs at the bottom of the page
and the only thing that follows it is the header of the longtable and an \hline below it
at the very bottom of the page, and the table continues on next page.  For example:

2.0 Section Heading for a Section

------------------
----------------------------------------------------------------------------------

[page breaks here]

------------------
----------------------------------------------------------------------------------
| First table entry...                                                           |
----------------------------------------------------------------------------------
| Second table entry...                                                          |
----------------------------------------------------------------------------------
...and so on

So my question is:

...aside from manually entering a \newpage before the section break, which is not a good option
because the document source is being produced by a large perl script, and would mean I would
have to do the manual correction every time I re-produce the document source via the perl script...
(which happens far too often...)

1) Is there any way of glueing the \subsection to the top of the longtable somehow?

2) Is there any way to force longtable NOT to allow the orphaning of one of its heads at the end of a page?
(From what I read in the documentation, this isn't really supposed to happen.)

I've tried readin through all of the documentation again and done a search to see if anyone
else had this problem before me, but no luck?

Does David Carlisle or David Kastrup read this list?
I tried contacting them at some of their old email addresses, but got only a bounce.
Does anyone happen to have their up to date email addresses handy?

Even a pointer to a previous discussion or FAQ would be great!

Thomas

CONFIDENTIAL AND PRIVILEGED INFORMATION NOTICE

This e-mail, and any attachments, may contain information that
is confidential, subject to copyright, or exempt from disclosure.
Any unauthorized review, disclosure, retransmission,
dissemination or other use of or reliance on this information
may be unlawful and is strictly prohibited.

AVIS D'INFORMATION CONFIDENTIELLE ET PRIVILÉGIÉE

Le présent courriel, et toute pièce jointe, peut contenir de
l'information qui est confidentielle, régie par les droits
d'auteur, ou interdite de divulgation. Tout examen,
divulgation, retransmission, diffusion ou autres utilisations
non autorisées de l'information ou dépendance non autorisée
envers celle-ci peut être illégale et est strictement interdite.