5

I was looking into the definition of \@normalcr. In some cases, the macro expands to include either \vadjust{\nobreak \relax} or \vadjust{\nobreak \vskip 1cm} (the 1cm is an example, more generally it is some length measurement).

What is the point of the \nobreak inside these expressions?

Many thanks in advance.

Edit: after some experimentation I have supplied my own answer below. Please could a more experienced user check it? Also, I still see no difference between \vadjust{\relax} and \vadjust{\nobreak \relax}. Is there a difference?

3
  • 1
    \vadjust{\relax} does nothing at all. \vadjust{\nobreak \relax} will prevent a page break after the current line. Commented Apr 3 at 11:51
  • 1
    the \nobreak is used when you use \\* which should prohibit a page break. Commented Apr 3 at 11:51
  • OK great. But @DavidCarlisle, I do not see that. For example, if I replace the \vadjust{...} in the final example of my answer below with \vadjust{\nobreak \relax} , I still get a page break on the line it is used in. Commented Apr 3 at 12:03

2 Answers 2

6

Also, I still see no difference between \vadjust{\relax} and \vadjust{\nobreak \relax}. Is there a difference?

\vadjust{\relax} does nothing at all.

\vadjust{\nobreak} with or without the \relax inserts a no-break penalty of 10000 into the vertical list after the current line, which will prevent page breaking at that point.

The simple test with just this in isolation does not show any effect as can be seen by looking at the vertical list constructed.

\showoutput\showboxdepth3

\documentclass{article}

\begin{document}

aa  \vadjust{\nobreak}
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
\end{document}

Produces a log of

...\glue(\topskip) 5.69446
...\hbox(4.30554+0.0)x345.0, glue set - 0.12003 []
...\penalty 10000
...\penalty 150
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x345.0, glue set 0.03998 []
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x345.0, glue set 0.03998 []
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x345.0, glue set 0.03998 []
...\penalty 150
...\glue(\baselineskip) 7.69446
...\hbox(4.30554+0.0)x345.0, glue set 108.33287fil []
...\glue 0.0 plus 1.0fil
...\glue 0.0
...\glue 0.0 plus 0.0001fil
..\glue(\baselineskip) 23.55556

So after the first line there is a penalty of 10000 which would stop a page break except there is an explicit penalty 150 from \clubpenalty as this is the first line of the paragraph, so line breaking is allowed after the first line despite the nobreak.

However in conjunction with setting other penalty values (such as \interlinepenalty, \clubpenalty, \widowpenalty) and other material that is added in \vadjust the penalty added at that point can prevent page breaking.

Note the standard \\* which is a linebreak that prevents (or at least discourages) page breaking at that line has the same issue with \clubpenalty

\showoutput\showboxdepth3

\documentclass{article}

\begin{document}

\vspace*{44\baselineskip}

aa\\*
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa 
\end{document}

Does page break at the penalty 150 desoite \\* being used.

2

Oh I think I see. But please could someone confirm.

The macro \vadjust{<vertical list>} inserts a vertical list just after the line has ended.

But vertical space is removed at page breaks. Thus if we insert a \vadjust{\vskip 1cm} somewhere in a line at the bottom of a page, it inserts this blank vertical list which is then swallowed by the new page and so we don't see the space.

On the other hand, by including a \nobreak as in \vadjust{\nobreak \vskip 1cm} we ensure that the vertical list does not go across a page and we do see it.

For example, this code distinguishes between the too cases:

\documentclass[11pt, a4paper, draft]{article}
\usepackage{lipsum}
\begin{document}
    \lipsum[63-68]

    Here is rather long line which \vadjust{\vskip 1cm} crosses the page, at least it does so with my TeX engine. And here is another sentence. \lipsum[66]
    
\end{document}

vs

\documentclass[11pt, a4paper, draft]{article}
\usepackage{lipsum}
\begin{document}
    \lipsum[63-68]

    Here is rather long line which \vadjust{\nobreak \vskip 1cm} crosses the page, at least it does so with my TeX engine. And here is another sentence. \lipsum[66]
    
\end{document}

In the first case, it looks exactly as if the \vadjust{...} were not there. In the second, the \nobreak forces the vertical space (along with the line calling the \vadjust) to be on the new page.

The remainder is added after David Carlisle's answer. As stated in David Carlisle's answer, there is a difference between \vadjust{\nobreak\relax} (=\vadjust{\nobreak}) and \vadjust{\relax}, but the example above will not show this, since the line going across pages is the first of a paragraph, so it gets its own penalty which is updated after the \nobreak penalty (and whose value is only 150 - allowing a page break). But modifying my examples above so as to display two lines of a paragraph before the natural page break does show a difference:

\documentclass[11pt, a4paper, draft]{article}
\usepackage{lipsum}
\begin{document}
    \lipsum[72-76]

    This is an extremely long sentence which will run over three lines including going across the page and to fill it out I am writing\vadjust{\nobreak} a lot of unnecessary words such as `vituperous' and `rebarbative'. And here is another sentence. \lipsum[66]
    
\end{document}

vs

\documentclass[11pt, a4paper, draft]{article}
\usepackage{lipsum}
\begin{document}
    \lipsum[72-76]

    This is an extremely long sentence which will run over three lines including going across the page and to fill it out I am writing\vadjust{} a lot of unnecessary words such as `vituperous' and `rebarbative'. And here is another sentence. \lipsum[66]
    
\end{document}

The first case now prevents a line break, so that the second line of the paragraph goes over to the new page, whereas it remains on the first page in the second case.

1
  • 1
    yes and this difference is the difference between \\[1cm] and \\*[1cm] Commented Apr 3 at 11:50

You must log in to answer this question.

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