1

Dear ladies and gentlemen,

I have been typesetting verse and prose recently, and I am having trouble with dates. Specifically, I want to have the date follow the preceding text immediately, and stick to it (e.g., no pagebreak). This seems to be obvious whenever prose is being typeset---see this workaround:

\newcommand{\dated}[1]{\nobreak\par\noindent\null\hfill\textit{#1}}

However, with verse in verse environment, it becomes virtually impossible since LaTeX thinks that a break is always favourable after the \end{verse}, the end of the environment. I have been googling, but could not find the way to prevent it from breaking after the environment.

With prose, it works like a charm:

\documentclass[12pt, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[papersize={11cm, 15cm}, textwidth=10cm, textheight=11.2cm]{geometry}
\usepackage{lipsum}
\newcommand{\dated}[1]{\nobreak\par\noindent\null\hfill\textit{#1}}

\begin{document}
\null\vspace{2.3cm}
\lipsum[1]
\dated{30.01.2018}
\end{document}

Correct breaking

However, with poetry, not so much:

\documentclass[12pt, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[papersize={11cm, 15cm}, textwidth=10cm, textheight=11.2cm]{geometry}
\usepackage{lipsum}
\newcommand{\dated}[1]{\nobreak\par\noindent\null\hfill\textit{#1}}

\begin{document}
\lipsum[1]

\begin{verse}
    THERE was a young lady of Niger \\
    Who smiled as she rode on a Tiger; \\   
    They came back from the ride    \\
    With the lady inside,   \\
    And the smile on the face of the Tiger.
\end{verse}
\dated{30.01.2018}
\end{document}

Incorrect break

I cannot use \needspace because all verse goes in between those \begin{verse} ... \end{verse}, and there are several hundred poems, so I cannot paste \needspace for each last line of verse.

Maybe it is possible to redefine verse somehow? Or any other trick to make \nobreak work after \end{verse}?

Any help is appreciated!

  • Actually, I doubt \nobreak has any effect on \par. IIRC, \nobreak increases the penalties for line breaking. \nopagebreak increases the penalties for breaking a paragraph between pages, but must be applied at the beginning of the paragraph. There ARE no penalties for breaking pages between paragraphs. – John Kormylo Feb 12 '18 at 15:37
2

This solution puts the date INSIDE the verse environment and attaches it to the last line. While one can use \unskip or \vskip-\lastskip to remove some of the space at the end of the verse environment, if you are already on the next page it won't do you any good.

\documentclass[12pt, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[papersize={11cm, 15cm}, textwidth=10cm, textheight=11.2cm, showframe]{geometry}
\usepackage{lipsum}
\newcommand{\dateverse}[1]{\hfill\rlap{\hspace{\rightmargin}%
  \llap{\raisebox{-\baselineskip}{\textit{#1}}}}}
\begin{document}
\lipsum[1]

\begin{verse}
    THERE was a young lady of Niger \\
    Who smiled as she rode on a Tiger; \\   
    They came back from the ride    \\
    With the lady inside,   \\
    And the smile on the face of the Tiger.
    \dateverse{30.01.2018}
\end{verse}
\end{document}

It occurred to me that \raisebox was turning the date into a descender, and LaTeX only aligns baselines at the bottom of the page, not descenders. To move the baseline, one must include the previous line inside a box.

\documentclass[12pt, oneside]{article}
\usepackage[utf8]{inputenc}
\usepackage[papersize={11cm, 15cm}, textwidth=10cm, textheight=11.2cm, showframe]{geometry}
\usepackage{lipsum}
\newcommand{\dated}[1]{\ifvmode\else\newline\fi
  \null\hfill\rlap{\hspace{\rightmargin}\llap{\textit{#1}}}}
\begin{document}
\lipsum[1]

\begin{verse}
    THERE was a young lady of Niger \\
    Who smiled as she rode on a Tiger; \\   
    They came back from the ride    \\
    With the lady inside,   \\
    \parbox[b]{\dimexpr \linewidth-\itemindent}%
    {And the smile on the face of the Tiger.
    \dated{30.01.2018}}
\end{verse}
\end{document}
  • Thank you! I guess one should put up with the text going outside the text area, as shown by your frames... I accept your answer, but it still remains an open question: can a page break be suppressed after the end of an environment? – Andreï Kostyrka Feb 11 '18 at 23:20
  • Not when it ends with \endtrivlist. – John Kormylo Feb 12 '18 at 2:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.