3

Is there a way to create the following layout using the verse package?

\documentclass{article}
\usepackage{verse}
\usepackage[utf8]{inputenc}
\usepackage[margin=1.3in]{geometry}

\newcommand{\attrib}[1]{\nopagebreak\noindent
  \makebox[\dimexpr(\versewidth)+2em][r]{\footnotesize#1\hspace{-2em}}}

\begin{document}

\settowidth\versewidth{What if tomorrow the war could be over?}

\begin{flushright}
\parbox{\versewidth}{
This is a war and we are soldiers. \\
What if tomorrow the war could be over? \\
Isn't that worth fighting for? \\
Isn't that worth dying for? \\
\attrib{Morpheus}
}
\end{flushright}

\begin{flushleft}
\parbox{\versewidth}{
This is a war and we are soldiers. \\
What if tomorrow the war could be over? \\
Isn't that worth fighting for? \\
Isn't that worth dying for? \\
\attrib{Morpheus}
}
\end{flushleft}

\end{document}

Is this possible to do it without using the \makebox for positioning the author (\attrib) ?

I'm just a beginner in both typography and LaTeX. I have experience only in website development.

Moriambar
  • 11,466
BTakacs
  • 131

1 Answers1

2

You should use the widest verse as the argument of \settowidth\versewidth; here's my proposal:

\documentclass{article}
\usepackage{verse}

\newcommand{\attrib}[1]{\nopagebreak\noindent
  \makebox[\dimexpr(\textwidth+\versewidth)/2][r]{\footnotesize#1\hspace{-2em}}}

\begin{document}

\settowidth\versewidth{What if tomorrow the war could be over?}
\begin{verse}[\versewidth]
This is a war and we are soldiers. \\
What if tomorrow the war could be over? \\
Isn't that worth fighting for? \\
Isn't that worth dying for? \\
\end{verse}

\attrib{Morpheus}

\end{document}

You can control the "outdent" of the attribution by acting on the spacing in the definition.

enter image description here

David Carlisle
  • 757,742
egreg
  • 1,121,712
  • Nice, but I cannot flush the poem to the left or right – BTakacs Feb 21 '13 at 09:52
  • Ok, with some modifications it nearly does what I wanted... But now I have to use \parbox, and I cannot use \verse inside it. And I don't see the single point that is responsible for the width of the whole box (max_verse_line_width + xem). And what is that \makebox just to indent the \attrib? – BTakacs Feb 21 '13 at 14:06
  • Now I don't believe that this could be solved only with absolute positioning of a smaller box (\makebox) inside the bigger box (\parbox). In html it is considered as a hackish solution :-) Is that the ordinary solution in LaTeX? – BTakacs Feb 21 '13 at 18:16
  • Sorry, but it's you that want to use the verse package without looking at its documentation. You're free not to believing into something; I surely have helped as much as I could. – egreg Feb 21 '13 at 18:34
  • If you really want me to read the documentation, this leads back to: \begin{flushright}\settowidth\versewidth{What if tomorrow the war could be over?} \begin{verse}[\versewidth] This is a war and we are soldiers. \What if tomorrow the war could be over? \Isn't that worth fighting for? \Isn't that worth dying for? \\attrib{Morpheus} \end{verse} \end{flushright} which is not a working solution. Or what do you mean? If you are aware of a part which addresses my problems (positioning both the verse and the author) please tell me, which part of the documentation you are pointing to. – BTakacs Feb 22 '13 at 08:43