Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
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 Jul 16 '11 at 21:40
    
It would be nice to see that patch. –  egreg Aug 31 '11 at 14:32

3 Answers 3

up vote 6 down vote accepted

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
share|improve this answer
    
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 Jul 15 '11 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 Jul 15 '11 at 15:38

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.

share|improve this answer
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 Jul 15 '11 at 8:42

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}%
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.