Line break without page break using `poetry` package












3















The poetry package overrides \*, which means that I can't use that to prevent page breaks in the middle of a stanza. Is there another way to create a line break while forbidding a page break at the same location? Preferably a setting, rather than adding something to the end of every line - but whatever works, works.



Example:



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{15cm} % Force poem down page

poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


I'd like to prevent page breaks in mid-stanza (in the final stanza in the compiled example).










share|improve this question




















  • 3





    Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

    – Marijn
    Feb 6 at 15:09











  • Please provide an MWE to show the issue.

    – Steven B. Segletes
    Feb 6 at 18:19






  • 1





    @Marijn I don't mind having to correct by hand, but the more automatic, the better.

    – Watercleave
    Feb 6 at 18:20











  • @StevenB.Segletes Gladly! What's an MWE?

    – Watercleave
    Feb 6 at 18:20











  • MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

    – Steven B. Segletes
    Feb 6 at 18:22
















3















The poetry package overrides \*, which means that I can't use that to prevent page breaks in the middle of a stanza. Is there another way to create a line break while forbidding a page break at the same location? Preferably a setting, rather than adding something to the end of every line - but whatever works, works.



Example:



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{15cm} % Force poem down page

poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


I'd like to prevent page breaks in mid-stanza (in the final stanza in the compiled example).










share|improve this question




















  • 3





    Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

    – Marijn
    Feb 6 at 15:09











  • Please provide an MWE to show the issue.

    – Steven B. Segletes
    Feb 6 at 18:19






  • 1





    @Marijn I don't mind having to correct by hand, but the more automatic, the better.

    – Watercleave
    Feb 6 at 18:20











  • @StevenB.Segletes Gladly! What's an MWE?

    – Watercleave
    Feb 6 at 18:20











  • MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

    – Steven B. Segletes
    Feb 6 at 18:22














3












3








3








The poetry package overrides \*, which means that I can't use that to prevent page breaks in the middle of a stanza. Is there another way to create a line break while forbidding a page break at the same location? Preferably a setting, rather than adding something to the end of every line - but whatever works, works.



Example:



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{15cm} % Force poem down page

poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


I'd like to prevent page breaks in mid-stanza (in the final stanza in the compiled example).










share|improve this question
















The poetry package overrides \*, which means that I can't use that to prevent page breaks in the middle of a stanza. Is there another way to create a line break while forbidding a page break at the same location? Preferably a setting, rather than adding something to the end of every line - but whatever works, works.



Example:



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{15cm} % Force poem down page

poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


I'd like to prevent page breaks in mid-stanza (in the final stanza in the compiled example).







line-breaking page-breaking






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 6 at 18:54







Watercleave

















asked Feb 6 at 12:09









WatercleaveWatercleave

1185




1185








  • 3





    Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

    – Marijn
    Feb 6 at 15:09











  • Please provide an MWE to show the issue.

    – Steven B. Segletes
    Feb 6 at 18:19






  • 1





    @Marijn I don't mind having to correct by hand, but the more automatic, the better.

    – Watercleave
    Feb 6 at 18:20











  • @StevenB.Segletes Gladly! What's an MWE?

    – Watercleave
    Feb 6 at 18:20











  • MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

    – Steven B. Segletes
    Feb 6 at 18:22














  • 3





    Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

    – Marijn
    Feb 6 at 15:09











  • Please provide an MWE to show the issue.

    – Steven B. Segletes
    Feb 6 at 18:19






  • 1





    @Marijn I don't mind having to correct by hand, but the more automatic, the better.

    – Watercleave
    Feb 6 at 18:20











  • @StevenB.Segletes Gladly! What's an MWE?

    – Watercleave
    Feb 6 at 18:20











  • MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

    – Steven B. Segletes
    Feb 6 at 18:22








3




3





Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

– Marijn
Feb 6 at 15:09





Do you need a fully automatic solution where you don't know what your input will be, or is it sufficient to correct the occasional bad page break manually?

– Marijn
Feb 6 at 15:09













Please provide an MWE to show the issue.

– Steven B. Segletes
Feb 6 at 18:19





Please provide an MWE to show the issue.

– Steven B. Segletes
Feb 6 at 18:19




1




1





@Marijn I don't mind having to correct by hand, but the more automatic, the better.

– Watercleave
Feb 6 at 18:20





@Marijn I don't mind having to correct by hand, but the more automatic, the better.

– Watercleave
Feb 6 at 18:20













@StevenB.Segletes Gladly! What's an MWE?

– Watercleave
Feb 6 at 18:20





@StevenB.Segletes Gladly! What's an MWE?

– Watercleave
Feb 6 at 18:20













MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

– Steven B. Segletes
Feb 6 at 18:22





MWE = Minimum Working Example. Code beginning with documentclass and ending with end{document}, boiled down to as small a size as possible to demonstrate the actual issue at hand.

– Steven B. Segletes
Feb 6 at 18:22










1 Answer
1






active

oldest

votes


















4














Not sure if this is sufficient, but it allows the avoidance of 1-line widows by growing the page by baselineskip. It is invoked with \*



The "fix" accomplishes this by redefining poem@endpart, which is what gets invoked via \*. The original poem@endpart is saved in poemendpart



The following MWE demonstrates the use of \* on page 1, but not on page 2 (which wraps to page 3).



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter
letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here



An alternative in the other direction, that is, forcing an early break, is to issue a clearpage immediately prior to a \, as in



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.clearpage\!

The final stanza\
A final metaphor\
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here





SUPPLEMENT



This attempt tries to modify the use of \ so that page breaks are prevented altogether. Thus, a normal verse will never break across a page boundary midway through. Seems to work for this use case.



I edited poem@endline to begin with a nopagebreak, so that a break did not occur at such a line. However, additional instances of nopagebreak needed to be added in the macro placelineno, after instances of hskip, to prevent pagebreaks following the line number (but before the verse line). I don't think I got them all, but enough to demonstrate the effect in the OP's MWE.



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter

defpoem@endline{nopagebreak%
par%
advancepoemlineno by1%
advancevslineno by1%
poem@defaultpars%
leftskip=poem@defleftskip%
placelineno%
}%

defplacelineno{%
setcounter{verseline}{thevslineno}%
setcounter{poemline}{thepoemlineno}%
poem@linenumsevery=value{poemlinenumsevery}%
poem@linenumboxgap=thepoemlinenumboxgap%
poem@linenumboxwd=thepoemlinenumboxwd%
modulo{thepoemlineno}{thepoem@linenumsevery}%
ifpoemlinenums%
ifnumpoem@tmpa=0%
ifpoemlinenumright%
hskip0ptnopagebreaktlap{%
rlap{%
hskippoem@maxlinewd%
hskippoem@linenumboxgap%
hbox topoem@linenumboxwd{%
hfil%
poemlinenumstylethepoemline%
}%
}%
}%
else%
hskip-poem@linenumboxgapnopagebreak%
llap{%
tlap{%
hbox topoem@linenumboxwd{%
poemlinenumstylethepoemline%
hfil%
}penalty10000%
}%
}penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
parvskip-baselineskip%
poem@indentevery=value{poemindentevery}%
ifnumpoem@indentevery=0%
else%
modulo{thepoemlineno}{thepoem@indentevery}%
ifnumpoem@tmpa=0%
hin%
fi%
fi%
expandafterpoem@expandvsloopexpandafter{poemvsindentlines}%
def@currentlabel{thepoemline}%
phantomsection%
}%


letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}





share|improve this answer


























  • Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

    – Watercleave
    Feb 8 at 12:30











  • @Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

    – Steven B. Segletes
    Feb 8 at 13:50













  • @Watercleave See SUPPLEMENT to my answer.

    – Steven B. Segletes
    Feb 8 at 15:15













  • Ah, markup error. I meant \ (double backslash), the short line break command.

    – Watercleave
    Feb 9 at 17:22











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473612%2fline-break-without-page-break-using-poetry-package%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














Not sure if this is sufficient, but it allows the avoidance of 1-line widows by growing the page by baselineskip. It is invoked with \*



The "fix" accomplishes this by redefining poem@endpart, which is what gets invoked via \*. The original poem@endpart is saved in poemendpart



The following MWE demonstrates the use of \* on page 1, but not on page 2 (which wraps to page 3).



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter
letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here



An alternative in the other direction, that is, forcing an early break, is to issue a clearpage immediately prior to a \, as in



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.clearpage\!

The final stanza\
A final metaphor\
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here





SUPPLEMENT



This attempt tries to modify the use of \ so that page breaks are prevented altogether. Thus, a normal verse will never break across a page boundary midway through. Seems to work for this use case.



I edited poem@endline to begin with a nopagebreak, so that a break did not occur at such a line. However, additional instances of nopagebreak needed to be added in the macro placelineno, after instances of hskip, to prevent pagebreaks following the line number (but before the verse line). I don't think I got them all, but enough to demonstrate the effect in the OP's MWE.



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter

defpoem@endline{nopagebreak%
par%
advancepoemlineno by1%
advancevslineno by1%
poem@defaultpars%
leftskip=poem@defleftskip%
placelineno%
}%

defplacelineno{%
setcounter{verseline}{thevslineno}%
setcounter{poemline}{thepoemlineno}%
poem@linenumsevery=value{poemlinenumsevery}%
poem@linenumboxgap=thepoemlinenumboxgap%
poem@linenumboxwd=thepoemlinenumboxwd%
modulo{thepoemlineno}{thepoem@linenumsevery}%
ifpoemlinenums%
ifnumpoem@tmpa=0%
ifpoemlinenumright%
hskip0ptnopagebreaktlap{%
rlap{%
hskippoem@maxlinewd%
hskippoem@linenumboxgap%
hbox topoem@linenumboxwd{%
hfil%
poemlinenumstylethepoemline%
}%
}%
}%
else%
hskip-poem@linenumboxgapnopagebreak%
llap{%
tlap{%
hbox topoem@linenumboxwd{%
poemlinenumstylethepoemline%
hfil%
}penalty10000%
}%
}penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
parvskip-baselineskip%
poem@indentevery=value{poemindentevery}%
ifnumpoem@indentevery=0%
else%
modulo{thepoemlineno}{thepoem@indentevery}%
ifnumpoem@tmpa=0%
hin%
fi%
fi%
expandafterpoem@expandvsloopexpandafter{poemvsindentlines}%
def@currentlabel{thepoemline}%
phantomsection%
}%


letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}





share|improve this answer


























  • Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

    – Watercleave
    Feb 8 at 12:30











  • @Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

    – Steven B. Segletes
    Feb 8 at 13:50













  • @Watercleave See SUPPLEMENT to my answer.

    – Steven B. Segletes
    Feb 8 at 15:15













  • Ah, markup error. I meant \ (double backslash), the short line break command.

    – Watercleave
    Feb 9 at 17:22
















4














Not sure if this is sufficient, but it allows the avoidance of 1-line widows by growing the page by baselineskip. It is invoked with \*



The "fix" accomplishes this by redefining poem@endpart, which is what gets invoked via \*. The original poem@endpart is saved in poemendpart



The following MWE demonstrates the use of \* on page 1, but not on page 2 (which wraps to page 3).



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter
letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here



An alternative in the other direction, that is, forcing an early break, is to issue a clearpage immediately prior to a \, as in



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.clearpage\!

The final stanza\
A final metaphor\
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here





SUPPLEMENT



This attempt tries to modify the use of \ so that page breaks are prevented altogether. Thus, a normal verse will never break across a page boundary midway through. Seems to work for this use case.



I edited poem@endline to begin with a nopagebreak, so that a break did not occur at such a line. However, additional instances of nopagebreak needed to be added in the macro placelineno, after instances of hskip, to prevent pagebreaks following the line number (but before the verse line). I don't think I got them all, but enough to demonstrate the effect in the OP's MWE.



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter

defpoem@endline{nopagebreak%
par%
advancepoemlineno by1%
advancevslineno by1%
poem@defaultpars%
leftskip=poem@defleftskip%
placelineno%
}%

defplacelineno{%
setcounter{verseline}{thevslineno}%
setcounter{poemline}{thepoemlineno}%
poem@linenumsevery=value{poemlinenumsevery}%
poem@linenumboxgap=thepoemlinenumboxgap%
poem@linenumboxwd=thepoemlinenumboxwd%
modulo{thepoemlineno}{thepoem@linenumsevery}%
ifpoemlinenums%
ifnumpoem@tmpa=0%
ifpoemlinenumright%
hskip0ptnopagebreaktlap{%
rlap{%
hskippoem@maxlinewd%
hskippoem@linenumboxgap%
hbox topoem@linenumboxwd{%
hfil%
poemlinenumstylethepoemline%
}%
}%
}%
else%
hskip-poem@linenumboxgapnopagebreak%
llap{%
tlap{%
hbox topoem@linenumboxwd{%
poemlinenumstylethepoemline%
hfil%
}penalty10000%
}%
}penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
parvskip-baselineskip%
poem@indentevery=value{poemindentevery}%
ifnumpoem@indentevery=0%
else%
modulo{thepoemlineno}{thepoem@indentevery}%
ifnumpoem@tmpa=0%
hin%
fi%
fi%
expandafterpoem@expandvsloopexpandafter{poemvsindentlines}%
def@currentlabel{thepoemline}%
phantomsection%
}%


letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}





share|improve this answer


























  • Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

    – Watercleave
    Feb 8 at 12:30











  • @Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

    – Steven B. Segletes
    Feb 8 at 13:50













  • @Watercleave See SUPPLEMENT to my answer.

    – Steven B. Segletes
    Feb 8 at 15:15













  • Ah, markup error. I meant \ (double backslash), the short line break command.

    – Watercleave
    Feb 9 at 17:22














4












4








4







Not sure if this is sufficient, but it allows the avoidance of 1-line widows by growing the page by baselineskip. It is invoked with \*



The "fix" accomplishes this by redefining poem@endpart, which is what gets invoked via \*. The original poem@endpart is saved in poemendpart



The following MWE demonstrates the use of \* on page 1, but not on page 2 (which wraps to page 3).



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter
letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here



An alternative in the other direction, that is, forcing an early break, is to issue a clearpage immediately prior to a \, as in



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.clearpage\!

The final stanza\
A final metaphor\
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here





SUPPLEMENT



This attempt tries to modify the use of \ so that page breaks are prevented altogether. Thus, a normal verse will never break across a page boundary midway through. Seems to work for this use case.



I edited poem@endline to begin with a nopagebreak, so that a break did not occur at such a line. However, additional instances of nopagebreak needed to be added in the macro placelineno, after instances of hskip, to prevent pagebreaks following the line number (but before the verse line). I don't think I got them all, but enough to demonstrate the effect in the OP's MWE.



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter

defpoem@endline{nopagebreak%
par%
advancepoemlineno by1%
advancevslineno by1%
poem@defaultpars%
leftskip=poem@defleftskip%
placelineno%
}%

defplacelineno{%
setcounter{verseline}{thevslineno}%
setcounter{poemline}{thepoemlineno}%
poem@linenumsevery=value{poemlinenumsevery}%
poem@linenumboxgap=thepoemlinenumboxgap%
poem@linenumboxwd=thepoemlinenumboxwd%
modulo{thepoemlineno}{thepoem@linenumsevery}%
ifpoemlinenums%
ifnumpoem@tmpa=0%
ifpoemlinenumright%
hskip0ptnopagebreaktlap{%
rlap{%
hskippoem@maxlinewd%
hskippoem@linenumboxgap%
hbox topoem@linenumboxwd{%
hfil%
poemlinenumstylethepoemline%
}%
}%
}%
else%
hskip-poem@linenumboxgapnopagebreak%
llap{%
tlap{%
hbox topoem@linenumboxwd{%
poemlinenumstylethepoemline%
hfil%
}penalty10000%
}%
}penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
parvskip-baselineskip%
poem@indentevery=value{poemindentevery}%
ifnumpoem@indentevery=0%
else%
modulo{thepoemlineno}{thepoem@indentevery}%
ifnumpoem@tmpa=0%
hin%
fi%
fi%
expandafterpoem@expandvsloopexpandafter{poemvsindentlines}%
def@currentlabel{thepoemline}%
phantomsection%
}%


letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}





share|improve this answer















Not sure if this is sufficient, but it allows the avoidance of 1-line widows by growing the page by baselineskip. It is invoked with \*



The "fix" accomplishes this by redefining poem@endpart, which is what gets invoked via \*. The original poem@endpart is saved in poemendpart



The following MWE demonstrates the use of \* on page 1, but not on page 2 (which wraps to page 3).



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter
letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here



An alternative in the other direction, that is, forcing an early break, is to issue a clearpage immediately prior to a \, as in



documentclass[a4paper]{article}
usepackage{poetry}

begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.clearpage\!

The final stanza\
A final metaphor\
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}


enter image description here





SUPPLEMENT



This attempt tries to modify the use of \ so that page breaks are prevented altogether. Thus, a normal verse will never break across a page boundary midway through. Seems to work for this use case.



I edited poem@endline to begin with a nopagebreak, so that a break did not occur at such a line. However, additional instances of nopagebreak needed to be added in the macro placelineno, after instances of hskip, to prevent pagebreaks following the line number (but before the verse line). I don't think I got them all, but enough to demonstrate the effect in the OP's MWE.



documentclass[a4paper]{article}
usepackage{poetry}

makeatletter

defpoem@endline{nopagebreak%
par%
advancepoemlineno by1%
advancevslineno by1%
poem@defaultpars%
leftskip=poem@defleftskip%
placelineno%
}%

defplacelineno{%
setcounter{verseline}{thevslineno}%
setcounter{poemline}{thepoemlineno}%
poem@linenumsevery=value{poemlinenumsevery}%
poem@linenumboxgap=thepoemlinenumboxgap%
poem@linenumboxwd=thepoemlinenumboxwd%
modulo{thepoemlineno}{thepoem@linenumsevery}%
ifpoemlinenums%
ifnumpoem@tmpa=0%
ifpoemlinenumright%
hskip0ptnopagebreaktlap{%
rlap{%
hskippoem@maxlinewd%
hskippoem@linenumboxgap%
hbox topoem@linenumboxwd{%
hfil%
poemlinenumstylethepoemline%
}%
}%
}%
else%
hskip-poem@linenumboxgapnopagebreak%
llap{%
tlap{%
hbox topoem@linenumboxwd{%
poemlinenumstylethepoemline%
hfil%
}penalty10000%
}%
}penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
else
hskip-poem@linenumboxgapnopagebreak%
llap{tlap{hbox topoem@linenumboxwd{hfil}}}%
penalty10000%
fi%
parvskip-baselineskip%
poem@indentevery=value{poemindentevery}%
ifnumpoem@indentevery=0%
else%
modulo{thepoemlineno}{thepoem@indentevery}%
ifnumpoem@tmpa=0%
hin%
fi%
fi%
expandafterpoem@expandvsloopexpandafter{poemvsindentlines}%
def@currentlabel{thepoemline}%
phantomsection%
}%


letpoemendpartpoem@endpart
defpoem@endpart{enlargethispage{baselineskip}poem@endline}
makeatother
begin{document}

Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\*
The end\-
clearpage
Some text.
vspace{16.2cm} % Force poem down page


poem
Some poetry\
A metaphor here,\
A metaphor there.\!

Here begins another stanza\
More words.\!

The final stanza\
A final metaphor\
The end\-

end{document}






share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 8 at 18:43

























answered Feb 6 at 19:59









Steven B. SegletesSteven B. Segletes

155k9199407




155k9199407













  • Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

    – Watercleave
    Feb 8 at 12:30











  • @Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

    – Steven B. Segletes
    Feb 8 at 13:50













  • @Watercleave See SUPPLEMENT to my answer.

    – Steven B. Segletes
    Feb 8 at 15:15













  • Ah, markup error. I meant \ (double backslash), the short line break command.

    – Watercleave
    Feb 9 at 17:22



















  • Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

    – Watercleave
    Feb 8 at 12:30











  • @Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

    – Steven B. Segletes
    Feb 8 at 13:50













  • @Watercleave See SUPPLEMENT to my answer.

    – Steven B. Segletes
    Feb 8 at 15:15













  • Ah, markup error. I meant \ (double backslash), the short line break command.

    – Watercleave
    Feb 9 at 17:22

















Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

– Watercleave
Feb 8 at 12:30





Thanks! Is it possible to redefine ` to nopagebreak` followed by the existing `` command? Would that work?

– Watercleave
Feb 8 at 12:30













@Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

– Steven B. Segletes
Feb 8 at 13:50







@Watercleave Do you really mean `? That is a macro that places a grave accent over a letter.

– Steven B. Segletes
Feb 8 at 13:50















@Watercleave See SUPPLEMENT to my answer.

– Steven B. Segletes
Feb 8 at 15:15







@Watercleave See SUPPLEMENT to my answer.

– Steven B. Segletes
Feb 8 at 15:15















Ah, markup error. I meant \ (double backslash), the short line break command.

– Watercleave
Feb 9 at 17:22





Ah, markup error. I meant \ (double backslash), the short line break command.

– Watercleave
Feb 9 at 17:22


















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f473612%2fline-break-without-page-break-using-poetry-package%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents