Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

understanding needspace

86 views
Skip to first unread message

Tim Arnold

unread,
Sep 8, 2010, 11:30:56 AM9/8/10
to
Hi,
I suppose I'm misunderstanding the use of needspace. The minimal
document below produces several lines of space before the second
section header, but no produces no effect before the first.

What I thought would happen is that neither section header would have
any spaces added, just that each one would be certain to have a
certain number of lines left on the page before typesetting the
header; otherwise a page would be ejected and the section would begin
on the new page.

Am I misunderstanding the package?
thanks,
--Tim Arnold

\documentclass{memoir}
\usepackage{lipsum}
\raggedbottom
\begin{document}
\chapter{my chapter}

\needspace{8\onelineskip}
\section{my section}

\lipsum[1]

\needspace{4\onelineskip}
\section{another section}

\lipsum[1]

\end{document}

Lars Madsen

unread,
Sep 8, 2010, 6:15:40 PM9/8/10
to

I guess you will need to have Peter Wilson explain this one

I guess there is an interesting interaction when there is text
\needspace and then a \section (try removing the last section)

But the memoir manual mentions an alternative in the odd occasion that
\needspace behaves oddly, \Needspace and that works fine in your case

/daleif

Dan Luecking

unread,
Sep 8, 2010, 6:28:35 PM9/8/10
to

\needspace doesn't interact well with things like
section headers. Part of the effect of \section
is to examine the previous vertical space and discard
it if it is less than a certain amount. But \needspace
ends with some negative vertical space (to cancel some
previous positive space it added). Then \section sees
that negative space, discards it, and the positive space
remains.

This might be considered bug. Perhaps \needspace should
end with a \vskip 0pt for \section to find and discard,
protecting the necessary negative skip.

A workaround is to use \Needspace, which uses a different
method to ensure the space is available.


Dan
To reply by email, change LookInSig to luecking

Donald Arseneau

unread,
Sep 8, 2010, 8:10:28 PM9/8/10
to
Tim Arnold <a_j...@bellsouth.net> writes:

> I suppose I'm misunderstanding the use of needspace. The minimal
> document below produces several lines of space before the second
> section header, but no produces no effect before the first.

There is a conflict between \needspace and the \addpenalty
hidden inside the \section command. \needspace should end
with \vskip\z@skip (\vskip 0 pt), just as the definition of
\vspace does, to ensure co-operation.

The first \needspace works because page breaks are forbidden
after chapter headings, so \addpenalty is not used by \section.

Is Peter or another memoir maintainer reading?


--
Donald Arseneau as...@triumf.ca

Will Robertson

unread,
Sep 8, 2010, 10:55:43 PM9/8/10
to

Yep (usually).

I've added this to the issue tracker for needspace and I'll address it
when possible (a little swamped at the moment).

http://github.com/wspr/herries-press/issues/issue/10

Thanks,
Will

Donald Arseneau

unread,
Sep 9, 2010, 3:46:15 AM9/9/10
to
Will Robertson <wsp...@gmail.com> writes:

> > There is a conflict between \needspace and the \addpenalty
> > hidden inside the \section command.

Actually, the \addpenalty performs correctly, but the
ensuing \addvspace is what makes the mess. (The \addpenalty
would only make a mess when the page breaks at the penalty.)

> > \needspace should end
> > with \vskip\z@skip (\vskip 0 pt), just as the definition of
> > \vspace does, to ensure co-operation.

but the fix for \addvspace is the same \vskip\z@skip.

> I've added this to the issue tracker for needspace and I'll address it when
> possible (a little swamped at the moment).

Great! Thanks Will.

--
Donald Arseneau as...@triumf.ca

Lars Madsen

unread,
Sep 9, 2010, 5:02:09 AM9/9/10
to

I'll add the \vskip\z@skip fix to memoir as well

--

/daleif (remove RTFSIGNATURE from email address)

LaTeX FAQ: http://www.tex.ac.uk/faq
LaTeX book: http://www.imf.au.dk/system/latex/bog/ (in Danish)
Remember to post minimal examples, see URL below
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=minxampl
http://www.minimalbeispiel.de/mini-en.html

Lars Madsen

unread,
Sep 9, 2010, 10:18:08 AM9/9/10
to
Donald Arseneau wrote:
> Will Robertson <wsp...@gmail.com> writes:
>
>>> There is a conflict between \needspace and the \addpenalty
>>> hidden inside the \section command.
>
> Actually, the \addpenalty performs correctly, but the
> ensuing \addvspace is what makes the mess. (The \addpenalty
> would only make a mess when the page breaks at the penalty.)
>
>>> \needspace should end
>>> with \vskip\z@skip (\vskip 0 pt), just as the definition of
>>> \vspace does, to ensure co-operation.
>
> but the fix for \addvspace is the same \vskip\z@skip.
>

where should that be fixed?

>> I've added this to the issue tracker for needspace and I'll address it when
>> possible (a little swamped at the moment).
>
> Great! Thanks Will.
>


--

/daleif (remove RTFSIGNATURE from email address)

Tim Arnold

unread,
Sep 9, 2010, 11:40:26 AM9/9/10
to

Thanks everyone for the great explanation and upcoming fix. In the
meantime I'm using Needspace which as mentioned, works fine.
thanks,
--Tim

Donald Arseneau

unread,
Sep 9, 2010, 12:39:38 PM9/9/10
to
Lars Madsen <dal...@RTFMSIGNATUREimf.au.dk> writes:

> Donald Arseneau wrote:
> > but the fix for \addvspace is the same \vskip\z@skip.
>
> where should that be fixed?

Sorry that was too cryptic :-) I meant that even though the
blob of whitespace came out of \addvspace (and not from
\addpenalty), adding \vskip\z@skip to the end of \needspace
is still the proper fix.

--
Donald Arseneau as...@triumf.ca

Lars Madsen

unread,
Sep 9, 2010, 2:02:58 PM9/9/10
to

no problem, I've already added it to the next memoir version, and Will
will add it to the needspace package

/daleif

0 new messages