9

verse package has \settowidth command to center a poetry. Example:

\settowidth{\versewidth}{There was an old party of Lyme}
\begin{verse}[\versewidth]
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{verse}

I have a lot of poetries, and it's impossible to do this for everyone.

Is there a method to do the same thing without the specification of \versewidth?

Like, for example, this:

\begin{verse}
\start{unknown_command}
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{unknown_command}
\end{verse}
3
  • Incidentally, is this limerick one of Edward lear's?
    – Bernard
    Jul 21, 2014 at 1:14
  • Are you always using the first line for setting \versewidth?
    – egreg
    Jul 21, 2014 at 8:18
  • @egreg No, the largest line is what should be used. Sep 23, 2014 at 23:13

2 Answers 2

7

The final \cenverse seems to be the command you are expecting. Certainly, it can be transformed into an environment. The first two occurences of your limerick are for the comparision.

\documentclass{article}

\usepackage{verse}
\begin{document}


I have a lot of poetry, and it's impossible to do this for everyone.
I have a lot of poetry, and it's impossible to do this for everyone.

\settowidth{\versewidth}{There was an old party of Lyme}
\begin{verse}[\versewidth]
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{verse}


I have a lot of poetry, and it's impossible to do this for everyone.
I have a lot of poetry, and it's impossible to do this for everyone.

\begin{verse}
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{verse}


\def\cenverse#1\\{\settowidth{\versewidth}{#1}\begin{verse}[\versewidth]#1\\}

I have a lot of poetry, and it's impossible to do this for everyone.
I have a lot of poetry, and it's impossible to do this for everyone.


\cenverse
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{verse}

\end{document}

enter image description here

2
  • Is there a method to use this in a poetry without //? For example if I use boldfirst [tex.stackexchange.com/a/192468/59415 ] I not insert // and it doesn't work!
    – ᴜsᴇʀ
    Jul 21, 2014 at 11:24
  • 2
    And how can I turn the code into a \newenvironment for using it like \begin{cenverse} ..text... \end{cenverse}?
    – ᴜsᴇʀ
    Jul 21, 2014 at 13:02
5

This will use the widest verse for deciding the width and center the poem.

\documentclass{article}
\usepackage{verse,varwidth,environ}

\usepackage{lipsum} % just for the example

\newsavebox{\versebox}
\NewEnviron{cverse}{%
  \setlength{\leftmargini}{0pt}%
  \begin{lrbox}{\versebox}
  \begin{varwidth}{\textwidth}
  \begin{verse}
  \BODY
  \end{verse}
  \end{varwidth}
  \end{lrbox}%
  \begin{verse}[\wd\versebox]
  \BODY
  \end{verse}
}

\begin{document}

\lipsum[2]

\begin{cverse}
There was an old party of Lyme \\
Who married three wives at one time. \\
\vin When asked: ‘Why the third?’ \\
\vin He replied: ‘One’s absurd, \\
And bigamy, sir, is a crime.’
\end{cverse}

\begin{cverse}
Clof, clop, cloch,\\
cloffete,\\
cloppete,\\
clocchette,\\
chchch\dots\\
\`E gi\`u,\\
nel cortile,\\
la povera\\
fontana\\
malata;\\
che spasimo!\\
sentirla\\
tossire.\\
Tossisce,\\
tossisce,\\
un poco\\
si tace\dots\\
di nuovo.\\
tossisce.
\end{cverse}

\end{document}

The second poem is the start of Aldo Palazzeschi's “La fontana malata” (The sick fountain).

enter image description here

I used varwidth for measuring the width; because of how verse works, we need to set \leftmargini to zero (the setting is inside cverse, so it's local).

If you need footnotes in poems, change the code above into

\newsavebox{\versebox}
\newcounter{mockfootnote}
\NewEnviron{cverse}{%
  \setlength{\leftmargini}{0pt}%
  \begin{lrbox}{\versebox}
  % remember the current value of footnote
  \setcounter{mockfootnote}{\value{footnote}}%
  % disable footnotes in the first pass over the poem
  \renewcommand\footnote[1]{\stepcounter{mockfootnote}\textsuperscript{\themockfootnote}}%
  \begin{varwidth}{\textwidth}
  \begin{verse}
  \BODY
  \end{verse}
  \end{varwidth}
  \end{lrbox}%
  \begin{verse}[\wd\versebox]
  \BODY
  \end{verse}
}
5
  • This gives me a runaway argument error: file ended while scanning use of cverse. Sep 24, 2014 at 0:21
  • @JohnPeyton Are you perhaps using cverse in the definition of another environment?
    – egreg
    Sep 24, 2014 at 9:07
  • I don't think I was. However, I tried it again and it is working now­ … sorry that my problem was irreproducible. Sep 25, 2014 at 2:32
  • I’ve also found that this fails when the poem contains footnotes. In such a case the entire block is aligned left. This is probably testable using your example. Sep 26, 2014 at 0:06
  • 1
    @JohnPeyton I added a new definition of cverse to cope with footnotes.
    – egreg
    Sep 26, 2014 at 9:12

You must log in to answer this question.

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