8

In the following MWE, \clubpenalty has the expected default value of 150 at the begin of the document. However, a combination of a) a \section b) a paragraph c) a quote environment – in this particular sequence – will result in a \clubpenalty of 10000 (i.e. no orphans are allowed from this point forward). Leaving out any of these three elements will produce the expected value of 150 for \clubpenalty. Why is this the case?

\documentclass{article}

\begin{document}

Clubpenalty: \the\clubpenalty\ (should be 150)

% Removing either a) the \section or b) the paragraph following it
%     or c) the "quote" environment following it will produce
%     the expected value of 150 for \clubpenalty
\section{A section}

Some text.

\begin{quote}
Some text inside a \texttt{quote} environment.
\end{quote}

Clubpenalty: \the\clubpenalty\ (should be 150)

\end{document}
2
  • I'm the one that reported that bug. I discovered it while typesetting something using the mwart class (which is derived from article); I thought it is a mwart-specific bug. Marcin Woliński, who is the author of mwart, sent me a patch then; if nothing else works, I'll look into it and post it here (but I don't have too much time for that, so I can't do it now and don't want to do it unless someone really needs it).
    – mbork
    Commented Jul 16, 2011 at 21:40
  • It would be nice to see that patch.
    – egreg
    Commented Aug 31, 2011 at 14:32

3 Answers 3

7

I found that this hack seems to work, at least if the problematic environment is based on list:

\makeatletter
\g@addto@macro\endtrivlist{\aftergroup\@restoreclubpenalty}
\def\@restoreclubpenalty{\clubpenalty\@clubpenalty}
\makeatother
2
  • The definition of \@item includes the code snippet \if@nobreak \@nobreakfalse \clubpenalty \@M \else \clubpenalty \@clubpenalty \everypar{}% \fi. According to source2e, "[t]his code is intended to prevent a page break after the first line of an item that comes immediately after a section title". I don't know if this feature is affected by your "hack", but the latter is good enough for me.
    – lockstep
    Commented Jul 15, 2011 at 15:27
  • 2
    The hack will set the \clubpenalty after the list environment (because of \aftergroup); that code in \@item will only set the \clubpenalty inside the list environment, which is good, but the group ending will make TeX forget it.
    – egreg
    Commented Jul 15, 2011 at 15:38
10

I would say it is a bug. It also already reported (but neither analyzed nor solved): http://www.latex-project.org/cgi-bin/ltxbugs2html?pr=latex/4065

Rougly I would say that the problem is that in a list (quote is list) the \item doesn't start a paragraph and so the everypar trickery of the list and the section clash.

2
  • 3
    I've reminded the other members of the LaTeX3 Project about this. I avoid doing LaTeX2e bug fixes (much too complex!), but perhaps someone else will feel more inclined to take a look.
    – Joseph Wright
    Commented Jul 15, 2011 at 8:42
  • 1
    A fix for this problem was added 2015 to the LaTeX kernel (late but eventually it happened) Commented Feb 8, 2016 at 21:07
3

Sorry for the delay. Since my previous answer was converted into a comment, and AFAIK I can't include TeX code in comments, I paste Marcin Woliński's patch I mentioned here (I don't have time to analyze it now, just pasting it):

\def\@doendpe{\@endpetrue
  \clubpenalty\@clubpenalty
  \def\par{\@restorepar\everypar{}\par\@endpefalse}%
  \everypar{{\setbox\z@\lastbox}\everypar{}\@endpefalse}%
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .