# Is it true that when using \newline to stay in horizontal mode, the information will be on the same page?

I read here that using \newline keeps horizontal mode engaged. Is it true, then, that when I opt for \newline in for example

\noindent\rule{\textwidth}{\heavyrulewidth}\newline
Here is some text.


that the line and "Here is some text" will always be on the same page?

My understanding is that using \\ or \par switches to vertical mode briefly, which can lead to possible page breaks between content. This would not ensure that the line (\rule) and "Here is some text" would be on the same page.

I'd like to get a line followed immediately by tiny text (as close as possible without looking strange). They must always be typeset on the same page.

Example:

\documentclass{article}
\usepackage{fontspec}
\usepackage{booktabs}

\begin{document}
\noindent\rule{\textwidth}{\heavyrulewidth}\newline
{\tiny Here is some text.}

\noindent\rule{\textwidth}{\heavyrulewidth}\\[.1\baselineskip]
{\tiny Here is some text.}

\noindent\rule{\textwidth}{\heavyrulewidth}{\tiny\par
Here is some text.}
\end{document}

• (not authoritative) \\  does not go into vertical mode; \par definitely does. whether material after \newline will stay on the same page depends on (1) whether there's room on the page, (2) the setting of \widowpenalty, and (3) how many lines remain in the paragraph following the \newline. there are possibly other considerations as well, but i haven't time to test. – barbara beeton May 28 '15 at 14:23
• unless your tiny text is always one line it should have a \par before the } it would be closer to the rule in any case if you do that as it would be set with its own baslineskip not that of normalsize – David Carlisle May 28 '15 at 14:39
• @barbarabeeton \\  does not go into vertical mode here but it does in some other contexts, notably center – David Carlisle May 28 '15 at 14:40
• @DavidCarlisle -- thanks. (i did leave myself a weaselly out.) – barbara beeton May 28 '15 at 14:46

No, \\ in normal LR mode will not switch to vertical mode, nor does \newline.

In normal LR mode, the definition of \newline is \@normalcr\relax; the \relax is meant to avoid a subsequent * to be interpreted as a *-variant.

The definition of \\ is essentially \@normalcr, which however looks for a following * and an optional argument. If the optional argument is present, it should be a length and LaTeX inserts \vadjust{\vskip<length>}, which becomes \vadjust{\nobreak\vskip<length>} if a * followed the \\, then inserts \hfil\break to trigger a line break. The effect is to add a vertical space between the broken line and the following one; no page break can occur in case \\* or \\*[<length>] is used. In the former case, only \vadjust{\nobreak} is added, of course.

The \vadjust item adds vertical material which will be considered during page setting, after the paragraph has been broken into lines and the boxes so obtained are contributed to the vertical list under construction.

The possible added glue will be inserted between two lines in addition to the normal interline glue.

In general, the interline glue between two lines of a paragraph is a feasible page break point, unless the interline glue is preceded by a penalty, that may be inserted automatically: \clubpenalty between the first two lines, \widowpenalty between the last two lines and \interlinepenalty between any other pair (if the parameter is not set to 0).

What you want can be easily obtained by

\documentclass{article}
\usepackage{booktabs}
\usepackage{lipsum}

\begin{document}

\lipsum[2]

{\nopagebreak\tiny\noindent\rule{\textwidth}{\heavyrulewidth}\\*
\tiny Here is some text.\par}

\lipsum[3]

\end{document}


However, a simpler method is

\documentclass{article}
\usepackage{booktabs}
\usepackage{lipsum}

\begin{document}

\lipsum[2]

\par\kern3pt
\hrule height \heavyrulewidth
\kern1pt
{\tiny\noindent Here is some text.\par\nointerlineskip}
\kern3pt
\nopagebreak

\lipsum[3]

\end{document}


This uses lower level tools and exploits the following facts:

1. No interline glue is inserted before and after \hrule

2. A kern in vertical mode is not a feasible page break point if not followed by glue

So the rule with the tiny text cannot go to a new page, nor can there be a page break after it. If you want to allow it, remove the last \nopagebreak.

Controlling the spaces is easier this way.

I would use

{\tiny
\noindent\rule{\textwidth}{\heavyrulewidth}

\nopagebreak
Here is some text.

}


where both blank lines are needed (or could be \par which is the same thing).

The first blank line gets into vertical mode so that you can add the page breaking penalty (actually the blank line here isn't strictly necessary as \nopagebreak in vertical mode will work via \vadjust). the second blank line is needed so the tiny text is set with a suitable baseline, and suitably close to the rule.

• Okidoki. Thx. Looks like I was just missing a couple \pars then to set the baseline. I did not get the commant about the first empty line. Isn't \nopagebreak being called while still in horizontal mode without the empty line/\par? – Jonathan Komar May 28 '15 at 14:48
• @macmadness86 not if there is a blank line before it, as here. – David Carlisle Jun 12 '15 at 8:21