2

What is the effect of the \parskip-setting on where LaTeX does the page break? I wonder why there is a page break before the paragraph-headline with my \parskip settings (unless I insert the \par\penalty-500), but after the following quote if I comment out my \parskip setting. I don't understand the effect of the \parskip setting here. And do you know what is (Xe)LaTeX's default setting for \parskip? (Please choose a similar font if you don't have Times New Roman on your system).

\documentclass[a4paper,12pt]{article}

\usepackage{scrpage2}
\usepackage{lipsum}

\raggedbottom
\setlength{\parindent}{1.5em}
\setlength{\parskip}{0ex plus6ex minus0ex} % <----- effect on pagebreak?

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text} 
\setmainfont{Times New Roman} 

\usepackage{polyglossia} 
\setdefaultlanguage[spelling=new, babelshorthands=true]{german}

\begin{document}

\lipsum[1-4]

% <------------------ why the pagebreak here?

\paragraph{Der Zweck der Darbringungen}

\begin{quote}
  1. Um jenen kostbaren Geist zu ergreifen, bringe ich den vollendeten Tathāgatas, dem
  makellosen Juwel des heiligen Dharma und den Kindern der Buddhas, diesen Meeren von
  guten Eigenschaften, in rechter Weise dar.
\end{quote}
% \par\penalty-500    <---- why not the pagebreak here? 
Um jenen kostbaren Geist anzunehmen, der der Ursprung aller Vortrefflichkeiten ist,
bringt man den Drei Juwelen, die Ozeane von guten Eigenschaften besitzen, in rechter Weise dar.

\lipsum[4]

\end{document}
Joseph Wright
  • 259,911
  • 34
  • 706
  • 1,036
Christof
  • 460
  • 1
    You've given TeX quite a bit of stretch here: I'm not surprised that you allow an 'early' break. Is there a specific reason for using so much? – Joseph Wright Feb 27 '14 at 16:54
  • 2
    Not related to the issue, but as you are using font-based units (em/ex), you should make your settings after loading fonts not before: the values change. – Joseph Wright Feb 27 '14 at 16:55
  • 1
    If you change parskip you change the vertical position of everything after the first paragraph, so page breaking is naturally affected (although the page breaking routine does not look at the value of parskip) – David Carlisle Feb 27 '14 at 16:56
  • @DavidCarlisle Am I misunderstanding? I don't think he changed the nominal \parskip (0pt before and after), but rather the plus6ex is the relevant factor. Giving that much +slop in how a \parskip could grow allowed LaTeX to choose not to break the quote (with an orphan, no less). – Steven B. Segletes Feb 27 '14 at 17:02
  • @StevenB.Segletes yes but it comes to the same thing, if you allow the inter paragraph space to stretch more, then you should expect vertical positions and page breaks to change. In some cases they may not, but change is the expected result. – David Carlisle Feb 27 '14 at 17:05
  • 1
    @DavidCarlisle Yes, I understand that every time you prepare a page for shipout, LaTeX is weighing a complex algorithm of glue and penalty trying to optimize. And what Christof has done here is to lower the optimization penalty for applying a large amount of stretchy glue to a \parskip. – Steven B. Segletes Feb 27 '14 at 17:08
  • @JosephWright I have a text with a lot of listings and quotes and I think I wanted to avoid breaks inside a listing. But now I understand: the longer the stretch, the earlier a page break. (I will now use the 'inparaenum' environment of 'paralist' package that puts all list-items in a line w/o line breaks to make the text more compact.) – Christof Feb 27 '14 at 17:11
  • @StevenB.Segletes So apparently LaTeX gives lower penalty to a break between two normal paragraphs than to a break between a quote and a paragraph (which makes sense)? My problem is a text that has a structure of quote - paragraph - listing - quote etc., so I tried to find a good balance. But you make one problem decrease here and increase another one there. Manual tuning the final output is the only way I suppose. – Christof Feb 27 '14 at 17:31
  • Anyone knows the default values in \setlength{\parskip}{x plusy minusz}? – Christof Feb 27 '14 at 17:40
  • For article class, \setlength\parskip{0\p@ \@plus \p@} – Steven B. Segletes Feb 27 '14 at 17:41
  • Stretchy "glue" is a great metaphor for what happens. The setting of penalties is like adjusting the spring constants of different types of glue that hold the document elements together. A many-page document is a complex system of springs built in serial. It is easy to imagine that, over a large document, you need to occasionally intervene with \clearpage and \vspace constraints, amongst others. The realistic goal is to only to have to insert manual adjustments ONCE, at the final moment of document preparation. – Steven B. Segletes Feb 27 '14 at 17:46
  • 2
    note your text after the quote is not (to latex) a new paragraph, note it is not indented. If you had a blank line there instead of a comment it would be (and the spacing and penalties would be different again) – David Carlisle Feb 27 '14 at 17:59
  • @DavidCarlisle Your three comments (plus mentioning the default values of \parskip) would make a fine answer. – lockstep Feb 28 '14 at 14:14
  • @StevenB.Segletes Thanks a lot for the defaults of \parskip - but frankly, I have no idea what those symbols mean. How to switch back to the defaults from a custom setting? – Christof Feb 28 '14 at 17:15
  • 1
    See http://tex.stackexchange.com/questions/17983/what-is-the-default-parskip-in-memoir for discussion of \p@ – Steven B. Segletes Feb 28 '14 at 18:00
  • @DavidCarlisle Wanna summarize the comments in an answer? – Johannes_B Mar 27 '15 at 19:33
  • @StevenB.Segletes Wanna summarize the comments in an answer? – Johannes_B Mar 27 '15 at 19:33
  • @Johannes_B I am sure that David's answer would be far more informative, accurate, and relevant than anything I might cobble together. Let's see if he takes the bait. – Steven B. Segletes Mar 27 '15 at 19:49
  • @StevenB.Segletes bait me? surely not. – David Carlisle Nov 24 '15 at 20:26
  • @DavidCarlisle Hook, line, and sinker – Steven B. Segletes Nov 24 '15 at 21:14

1 Answers1

2

The page breaking algorithm does not look at \parskip specifically but if you change parskip you change the vertical position of everything after the first paragraph, so page breaking is naturally affected.

\setlength{\parskip}{0ex plus6ex minus0ex} % <----- effect on pagebreak?

allows a lot of variability in inter-paragraph space, anywhere between 0 and 6ex (which is 31pt, here). As well as allowing pages to be shorter (with the paragraphs spreading apart to fill the space) so changing page breaking, this would give the document a very uneven look, especially if you print two-side, where you may have facing pages with one page with no vertical space between paragraphs and the opposite page having the equivalent of two blank lines of white space between paragraphs.

This problem isn't so pronounced here as article uses \raggedbottom by default so most of the stretch is in the space at the bottom of the page, adding \flushbottom to the preamble would show the effect of large stretch components in \parskip more vividly.

For the standard classes, the default value is

0pt plus 1pt

and some would argue that that 1pt is too much stretch.

The actual effect on your particular example is a bit surprising, you could add \tracingpoages=1 to the preamble so TeX logs its page break calculations to the log, but to be honest I wouldn't. Page breaking is like line breaking (but simpler) The page break is chosen to minimize a certain cost expression (badness) so is affected by several aspects in particular all vertical space on the page, changing one aspect such as the plus component of \parskip changes some of the parameters in the formula, but exactly how that affects the overall cost calculation is not always easy to guess, you just have to see what it does.

In this cased essentially what is happening is each of the paragraphs above the section heading is contributing 31pt of stretch to the page so as that is essentially "free" it is preferred to break before the heading leaving that short but with lots of specified stretch, you don't see the effect of the parskip though with \raggedbottom in effect as while that stretch has been used to judge the cost of the page break, the output routine adds a higher order stretch to the bottom of the page so all the space comes at the bottom.

Without the parskip stretching (or only having the default 1pt stretch) the cost of breaking after the list is less than the cost of leaving the page short.

However beware such paraphrases of the algorithm, TeX doesn't really make judgements, it just minimises a certain fixed badness formula over the feasible break points on that page, and takes the first breakpoint that for which the badness falls below a given threshold value.

David Carlisle
  • 757,742