[texhax] Solved: Orphaned section breaks and longtable headers.
Beuthe, Thomas
beuthet at aecl.ca
Tue Mar 9 16:29:34 CET 2010
UNRESTRICTED | ILLIMITÉ
Here's a summary of the solution to my problem with orphaned section breaks and longtable headers.
(See below for a detailed description to the problem.)
In the end the combination of the use of the \nobreakhline and the needspace package using a
\Needspace{6\baselineskip} command inserted just before all \subsection commands solved my
problem in the automated way I was looking for. In fact, what I really did was to use a separately
defined variable in place of the 6\baselineskip to make the whole process more flexible.
I suppose it would have been even more ideal if I could have unbreakably bound the section command
to the top of the longtable, but in some senses that defeats the whole purpose of both the
section head and the longtable. I could always have made the text appearing in the
section head part of the top of the table, and then added a "virtual" section break with a direct
entry into the table of contents and anchored it to the position in the document with a
the hyperref \phantomsection command. That seemed a little extreme a ugly though.
My thanks goes out to everyone who helped me out with this pesky question, hh, Ulrike Fischer,
and Daniel Lemire.
Thomas
======================================================================================================
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:
http://www.daniel-lemire.com/blog/archives/2006/01/02/longtable-latex-package-breaks-pages-after-header/
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{%
\multispan\LT at cols\unskip\leaders\hrule\@height\arrayrulewidth\hfill\cr
\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
------------------
| longtable head |
----------------------------------------------------------------------------------
[page breaks here]
------------------
| longtable head |
----------------------------------------------------------------------------------
| 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?
Thanks in advance for any advice.
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.
More information about the texhax
mailing list