1

This is LuaHBTeX, Version 1.15.0 (TeX Live 2022)

Hello. I'm attempting to typeset some verses in lualatex. This is what I'd like to obtain: enter image description here given the following mwe:

\documentclass{book}
\usepackage{showframe}
\usepackage{verse}

\newcommand{\attrib}[1]{%
\nopagebreak{\raggedleft\footnotesize #1\par}}
\renewcommand{\poemtitlefont}{\normalfont\large\itshape\centering}

\begin{document}

\settowidth{\versewidth}{We do injuriously by licensing and prohibiting,}
\begin{verse}[\versewidth]
    \begin{center}
        Though all the winds of doctrine\\
        Were let loose to play upon the earth;\\
        So Truth be in the field,\\
        We do injuriously by licensing and prohibiting,\\
        to misdoubt her strength.\\
        Let her and falsehood grapple,\\
        Who ever knew Truth put to the worse,\\
        In a free and open encounter.
    \end{center}
\end{verse}
\attrib{Milton}

\end{document}

I obtain the following: enter image description here

As you can see, the first line is entirely misaligned with the rest of them, and even were it aligned, the entire block is misaligned with the normal print area, in fact, with the showframe package it appears to be right aligned.

1
  • do you need verse at all, it seems you want a standard center environment Commented Jan 4, 2023 at 20:59

2 Answers 2

1

The optional width argument is intended to set a left-aligned verse centered. To actually center the lines themselves you should not use this argument and use only \begin{center} and \end{center} or the more flexible \centering.

This works except for the first line, which is still sort of left-aligned. You can center this line by manually adding horizontal space the size of the width of the longest line minus the width of the first line divided by two.

MWE:

\documentclass{book}
\usepackage{showframe}
\usepackage{verse}

\newcommand{\attrib}[1]{%
\nopagebreak{\raggedleft\footnotesize #1\par}}
\renewcommand{\poemtitlefont}{\normalfont\large\itshape\centering}

\newlength{\firstline}
\begin{document}

\settowidth{\versewidth}{We do injuriously by licensing and prohibiting,}
\settowidth{\firstline}{Though all the winds of doctrine}
\begin{verse}
\centering
\hspace{\dimexpr(\versewidth-\firstline)/2}Though all the winds of doctrine\\
Were let loose to play upon the earth;\\
So Truth be in the field,\\
We do injuriously by licensing and prohibiting,\\
to misdoubt her strength.\\
Let her and falsehood grapple,\\
Who ever knew Truth put to the worse,\\
In a free and open encounter.
\end{verse}
\attrib{Milton}
\end{document}

enter image description here

But indeed as noted in a comment not using the verse package or environment, i.e.,

\documentclass{book}
\usepackage{showframe}
\newcommand{\attrib}[1]{%
\nopagebreak{\raggedleft\footnotesize #1\par}}
\begin{document}
\begin{center}
Though all the winds of doctrine\\
Were let loose to play upon the earth;\\
So Truth be in the field,\\
We do injuriously by licensing and prohibiting,\\
to misdoubt her strength.\\
Let her and falsehood grapple,\\
Who ever knew Truth put to the worse,\\
In a free and open encounter.
\end{center}
\attrib{Milton}
\end{document}

is easier.

1

The verse environment is not compatible with center, as you found out.

Here I propose a modified center environment that guarantees no page break between verses and the (optional) attribution.

\documentclass{book}
\usepackage{showframe}

\NewDocumentEnvironment{centerverse}{o}
 {%
  \parindent=0pt
  \par\addvspace{\topsep}
  \leftskip=0pt plus 1fill \rightskip=0pt plus 1fill
  \let\\\break
  \interlinepenalty10000
 }
 {%
  \par\nobreak
  \IfValueT{#1}{\makebox[\columnwidth][r]{\footnotesize#1\qquad}}\par
  \addvspace{\topsep}
 }

\begin{document}

%\vspace*{34\baselineskip}
%\vspace*{34.5\baselineskip}

Noted for his desire to diffuse the truth throughout the
world, he penned these words:

\begin{centerverse}[Milton]
Though all the winds of doctrine\\
Were let loose to play upon the earth;\\
So Truth be in the field,\\
We do injuriously by licensing and prohibiting,\\
to misdoubt her strength.\\
Let her and falsehood grapple,\\
Who ever knew Truth put to the worse,\\
In a free and open encounter.
\end{centerverse}

\end{document}

enter image description here

If you uncomment the first \vspace* line, the poem will be at the bottom of the page. Uncommenting the second one, instead, will push the whole poem to the next page.

This might be improved to allow page breaks at selected points and to provide space between stanzas.

You must log in to answer this question.

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