2

Do \clubpenalty or \widowpenalty extend beyond the paragraph in which they are issued? Specifically, if I put

   First paragraph blah blah \clubpenalty10000 blah blah...

   Next paragraph blah blah blah...

   Next paragraph blah blah blah...

does the penalty value set in the first paragraph continue to subsequent paragraphs? I'm sure this is no mystery, but I'm not able to find the relevant documentation.

My objective is to correct one bad pagebreak within a very long, complicated document. I want to solve the problem locally, and I think this will be less effort than the approach of putting \enlargethispage{-\baselineskip} on facing pages in this two-sided format.

  • The scope of any TeX macro it its group -- using "group" in hte TeX sense of the word. – Mico Feb 10 '17 at 1:04
  • it is a local counter so lasts to the end of the group or until reset but it's not a very convenient way of controlling the breaks for a specific paragrah. It's much easier in that case just to force the required linebreak putting \linebreak where you want a line to break. or \nopagebreak or whatever (but often its better to alter the line breaking than keep the linebreaking and break the page at a different place) – David Carlisle Feb 10 '17 at 1:10
  • David, thanks. This text gets edited quite often, and the break points change from version to version - I'm hoping for a solution that works in this version but that I won't need to find and rework in the next version (e.g., by removing or moving a \linebreak). In this specific version, I've got a club line that I'd like to have reflow in to something less ugly - letting tex figure out how to readjust the rest? – John Feb 10 '17 at 1:17
  • It should be mentioned that every environment is in its own group, and the \begin and \end macros will check for proper nesting. – John Kormylo Feb 10 '17 at 1:45
1

You asked,

Do \clubpenalty or \widowpenalty extend beyond the paragraph in which they are issued?

In general, the scope of any TeX macro is (the rest of) the group it is set in (or reset in), where "group" is used in the TeX sense of the word. A paragraph break doesn't (usually) trigger "end of group" criterion.

Consider the following example:

\documentclass{article}
\clubpenalty10000
\begin{document}

bla bla bla \the\clubpenalty

\begingroup % start a group
\clubpenalty1000 
bla bla bla \the\clubpenalty
\endgroup

$ % start a math group
\clubpenalty100 
\mbox{bla bla bla }
\the\clubpenalty
$ % paragraph ends after end of math group

bla bla bla \the\clubpenalty % 10000? 1000? 100?
\end{document}

What do you think the final value of \clubpenalty is: 100? 1000? 10000?

Two clarifications. First, as David Carlisle has pointed out in a comment, there are some macros -- e.g., \looseness -- that are reset automatically for each paragraph. For such macros, a paragraph break does (implicitly) act similarly to an end-of-group marker.

Second, if a macro comes into play only while TeX is exercising its paragraph-building algorithm -- \clubpenalty is an example of such a macro -- it's the value of the macro in force at the very end of the paragraph that is used for that paragraph. In the middle paragraph of the example code shown aove, the math group ends before the paragraph ends. Hence, the value of \clubpenalty which gets used for that paragraph is 10000, not 100.

  • 1
    i think that's over simplifying things as for example the otherwise similar looking \looseness is reset at the end of a paragraph also the effective value of \clubpenalty is the value at the end so in your middle para it is not 1000 but 10000 as the paragraph ends outside the group. – David Carlisle Feb 10 '17 at 1:43
  • Sigh .. I had hoped it would be as simple as a local change to \looseness. – John Feb 10 '17 at 2:05
  • In this particular case, my "paragraph" is the text beyond an \item within a special environment (for making a list of problems), so I gather from the responses of John Kormylo, Mico, and David that the value I'm proposing to set would not leave this environment in any case. I'm less clear as to whether my \item itself constitutes a group? – John Feb 10 '17 at 2:10
  • @John - The enumerate (or itemize) environment forms a group. Giveaway: the \begin{<env>} ... \end{<env>} syntax. – Mico Feb 10 '17 at 5:49
  • @Mico - Thanks, and in fact your tactic of putting \the\clubpenalty shows that the group ends once the text of the next \item begins (although not immediately after the \item command itself). So in the present case, I can change clubpenalty for this single entry. – John Feb 10 '17 at 15:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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