1

I am writing some song lyrics. If possible, partially empty pages should be preffered over page breaks inside paragraphs. Using \widowpenalties 1 10000 and \raggedbottom didn't work.

Until now, I was only able to achieve desired behavior by putting \filbreak after each paragraph (= stanza).

\documentclass[12pt]{article}
\usepackage[paperwidth=16cm, paperheight=9cm]{geometry}
\usepackage{nopageno}
\setlength\parindent{0pt}
\setlength\parskip{1em}

% Manually adding \filbreak at the end of stanza. This works as expected:
\begin{document}
\raggedright
Roads go ever ever on,\\
Over rock and under tree,\\
By caves where never sun has shone,\\
By streams that never find the sea;\\
Over snow by winter sown,\\
And through the merry flowers of June,\\
Over grass and over stone,\\
And under mountains in the moon.\filbreak

Roads go ever ever on\\
Under cloud and under star,\\
Yet feet that wandering have gone\\
Turn at last to home afar.\\
Eyes that fire and sword have seen\\
And horror in the halls of stone\\
Look at last on meadows green\\
And trees and hills they long have known.\filbreak
\end{document}

Compiled with manual \filbreak

However, I don't want to manually type this after every paragraph. I tried using method from this answer. Problem is that I also have to use \\ to achieve correct linebreaks between verses. Using method from aforementioned answer, I get \filbreak at every \\, so it is not working.

\documentclass[12pt]{article}
\usepackage[paperwidth=16cm, paperheight=9cm]{geometry}
\usepackage{nopageno}
\setlength\parindent{0pt}
\setlength\parskip{1em}

% Trying to add \filbreak after each paragraph automatically. Not working:
\makeatletter
    \def\filbreak{!\@@par\vfil\penalty-200\vfilneg}
    % Exclamation mark is there just to show, that \\ is also treated like \par.
\makeatother

\begin{document}
\raggedright
\let\par\filbreak
Roads go ever ever on,\\
Over rock and under tree,\\
By caves where never sun has shone,\\
By streams that never find the sea;\\
Over snow by winter sown,\\
And through the merry flowers of June,\\
Over grass and over stone,\\
And under mountains in the moon.

Roads go ever ever on\\
Under cloud and under star,\\
Yet feet that wandering have gone\\
Turn at last to home afar.\\
Eyes that fire and sword have seen\\
And horror in the halls of stone\\
Look at last on meadows green\\
And trees and hills they long have known.
\end{document}

Compiled with redefined \par

Is it possible to somehow put custom command (\filbreak) after every paragraph but not after every \\? How are \par and \\ actually connected? I prefer not to use some other poetry package, because I am writing my own with some other specific behavior, not relavant to this question.

4
  • 2
    the definition of \\ and whether it allows page breaks depends on the environment used, and you have given no indication of your document. Provide a small complete example with a bad page break Commented Apr 19 at 23:46
  • Welcome! ......
    – cfr
    Commented Apr 20 at 0:48
  • Because of the missing minimal working example just a guess: Maybe you are searching for tex.stackexchange.com/q/65355/277964 and tex.stackexchange.com/q/473612/277964
    – cabohah
    Commented Apr 20 at 6:58
  • Sorry, now I added MWE and "MNWE" (minimal not working example, not sure if anyone really uses that acronym :)
    – Filip Ž
    Commented Apr 20 at 9:18

2 Answers 2

0

I suggest to change \\ into \newline inside a poem environment, in which you set \interlinepenalty=10000, so page breaks are only allowed between paragraphs.

\documentclass[12pt]{article}
\usepackage[paperwidth=16cm, paperheight=9cm]{geometry}
\usepackage{nopageno}
\setlength\parindent{0pt}
\setlength\parskip{1em}

\newenvironment{poem}{%
  \begin{flushleft}\let\\\newline
  \interlinepenalty=10000
}{\end{flushleft}}

\begin{document}

\begin{poem}
Roads go ever ever on,\\
Over rock and under tree,\\
By caves where never sun has shone,\\
By streams that never find the sea;\\
Over snow by winter sown,\\
And through the merry flowers of June,\\
Over grass and over stone,\\
And under mountains in the moon.

Roads go ever ever on\\
Under cloud and under star,\\
Yet feet that wandering have gone\\
Turn at last to home afar.\\
Eyes that fire and sword have seen\\
And horror in the halls of stone\\
Look at last on meadows green\\
And trees and hills they long have known.
\end{poem}

\end{document}

enter image description here

0

You can use a para hook to add the \filbreak and discourage page breaks within a stanza by setting a high \interlinepenalty

\documentclass[12pt]{article}
\usepackage[paperwidth=16cm, paperheight=9cm]{geometry}
\usepackage{nopageno}
\setlength\parindent{0pt}
\setlength\parskip{1em}
\AddToHook{para/after}{\filbreak}
\showoutput
% Manually adding \filbreak at the end of stanza. This works as expected:

\begin{document}

\interlinepenalty=9000

Roads go ever ever on,\\
Over rock and under tree,\\
By caves where never sun has shone,\\
By streams that never find the sea;\\
Over snow by winter sown,\\
And through the merry flowers of June,\\
Over grass and over stone,\\
And under mountains in the moon.

Roads go ever ever on\\
Under cloud and under star,\\
Yet feet that wandering have gone\\
Turn at last to home afar.\\
Eyes that fire and sword have seen\\
And horror in the halls of stone\\
Look at last on meadows green\\
And trees and hills they long have known.
\end{document}

You must log in to answer this question.

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