# How to Automatically Center Verse

Consider the following code:

\documentclass{book}
\textwidth 5.75in
\usepackage{verse}

\begin{document}
\thispagestyle{empty}
\LARGE

\vskip 25pt

\begin{center}
\textbf{Casey at the Bat}
\end{center}

\vspace*{5pt}

\begin{center}
\begin{verse}
Oh, somewhere in this favoured land \\
the sun is shining bright, \\
The band is playing somewhere, \\
and somewhere hearts are light;

\vskip 10pt

And somewhere men are laughing, \\
and somewhere children shout, \\
But there is no joy in Mudville--- \\
mighty Casey has struck out.
\end{verse}
\end{center}
\end{document}


which produces

As you can see, despite the \begin{center} \end{center} I've used, the stanzas of verse are not centered.

I know that I can approximate what I want if I uncomment the command %\addtolength{\leftmargini}{60pt} and then visually adjust the amount until I get something which looks acceptable; however, I would like to do this automatically such as one would do to center a minipage or a tikzpicture.

QUESTION: Is there a way to center stanzas of verse in a reasonably simple and automatic way? If so, how may I do this this?

Thank you.

Is there a way to center stanzas of verse in a reasonably simple ... way?

If the verse package is loaded, the verse environment takes an optional argument, which informs LaTeX about the average length of a stanza which, in turn, influences the horizontal positioning of the stanzas. The argument should be a length variable or macro; the verse package provides a macro called \versewidth for this purpose. This mechanism should be used in conjunction with a center environment. (Aside: If you want to allow page breaks inside the verse environment, you should use \centering, not \begin{center}...\end{center}.)

Your query further asked if there's an automatic way to center the stanzas horizontally. The \versewidth mechanism is not fully automatic; however, I believe that's quite alright and not a shortcoming at all, as what you should really want to achieve -- typographically speaking -- is "optical" rather than "mathematical" centering. Whether a bunch of stanzas "looks centered" depends on several factors, and not just on the widest or average length of the stanzas in the verse. In the following example, after some trial runs, I chose the length of the second-longest stanzas as the basis for \versewidth. Your aesthetic preferences may well differ from mine.

The framelines in the following screenshot are drawn by the showframe package.

\documentclass{book}
\setlength{\textwidth}{5.75in}
\usepackage{verse}
\usepackage{showframe} % draw framelines around text block

\begin{document}

\begingroup % localize scope of '\centering' and '\LARGE' directives
\centering
\LARGE
\settowidth{\versewidth}{And somewhere men are laughing,} % 2nd-longest stanza
\textbf{Casey at the Bat}

\vspace{0.5\baselineskip}

\begin{verse}[\versewidth] % <-- note the optional argument
Oh, somewhere in this favoured land \\
the sun is shining bright, \\
The band is playing somewhere, \\
and somewhere hearts are light;

And somewhere men are laughing, \\
and somewhere children shout, \\
But there is no joy in Mudville--- \\
mighty Casey has struck out.
\end{verse}
\endgroup

\end{document}