Ich schreibe einige Songtexte. Wenn möglich, sollten teilweise leere Seiten Seitenumbrüchen innerhalb von Absätzen vorgezogen werden. Die Verwendung von \widowpenalties 1 10000
und \raggedbottom
hat nicht funktioniert.
Bisher konnte ich das gewünschte Verhalten nur erreichen, indem ich \filbreak
nach jedem Absatz (= Strophe) etwas eingefügt habe.
\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}
Ich möchte dies jedoch nicht nach jedem Absatz manuell eingeben. Ich habe versucht, die Methode von zu verwendenDasAntwort. Das Problem ist, dass ich auch verwenden muss, \\
um korrekte Zeilenumbrüche zwischen Versen zu erzielen. Mit der Methode aus der oben genannten Antwort erhalte ich \filbreak
bei jedem \\
, also funktioniert es nicht.
\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}
Ist es irgendwie möglich, \filbreak
nach jedem Absatz einen benutzerdefinierten Befehl () einzufügen, aber nicht nach jedem \\
? Wie sind \par
und \\
tatsächlich verbunden? Ich ziehe es vor, kein anderes Poesiepaket zu verwenden, da ich mein eigenes mit einem anderen spezifischen Verhalten schreibe, das für diese Frage nicht relevant ist.
Antwort1
\\
Ich schlage vor, innerhalb \newline
einer Umgebung zu wechseln poem
, in der Sie festlegen \interlinepenalty=10000
, dass Seitenumbrüche nur zwischen Absätzen zulässig sind.
\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}
Antwort2
Sie können einen para
Hook verwenden, um Seitenumbrüche innerhalb einer Strophe hinzuzufügen \filbreak
und zu verhindern, indem Sie einen hohen\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}