2

I want to align some lines within a verse environment horizontally to the right, as the MWE bellow shows.

For this, neither \hfill nor \flushright work properly.

I show my best approach in the MWE: It aligns correctly but doesn't show verse numbers. Moreover, you have to manually enter the number of verses in that part. In conclusion: The numbering routine doesn't work there.

\documentclass{article}
\usepackage{verse}

\poemlines{2} 

\begin{document}

\begin{verse}
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\!
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
{\raggedleft
Lorem ipsum \\
Lorem ipsum dolor sit amet, \\
consectetur adipiscing elit\\
\raggedright}
\addtocounter{poemline}3
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
\end{verse}

\end{document}

Any other way to achieve this?

enter image description here

2 Answers 2

2

Use “more infinite” glue: you need filll to kill the \hfill introduced by verse, which is the same as \hspace{0pt plus 1fill} (see https://tex.stackexchange.com/a/186154/4427)

\documentclass{article}
\usepackage{verse}

\newcommand{\rightverse}{\hspace{0pt plus 1filll}}

\poemlines{2}

\begin{document}

\begin{verse}
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\!
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
\rightverse Lorem ipsum \\
\rightverse Lorem ipsum dolor sit amet, \\
\rightverse consectetur adipiscing elit\\
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
\end{verse}

\end{document}

enter image description here

1
  • Because to John Kormylo's explanation, I can now understand why you say "plus infinite glue". Thanks.
    – e_moro
    May 28, 2023 at 16:27
2

It seems that verse uses \hfill instead of \hfil to perform centering. One can however use \makebox on each line to right align them within the given length. Experiments indicate that \dimexpr \linewidth+\leftmargini is close to the length at which the line will break automatically.

\documentclass{article}
\usepackage{verse}

\newcommand{\moveit}[1]{\makebox[\dimexpr \linewidth+\leftmargini][r]{#1}}

\poemlines{2} 

\begin{document}

\begin{verse}
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\!
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
\moveit{Lorem ipsum}\\
\moveit{Lorem ipsum dolor sit amet,}\\
\moveit{consectetur adipiscing elit}\\
Lorem ipsum dolor sit amet, \\
Lorem ipsum dolor sit amet, consectetur adipiscing elit\\
\end{verse}

\end{document}
1
  • Excellent. And thanks for the explanation. I choose the egreg's solution because I preferer the sentence way, similar to \hfill, etc.
    – e_moro
    May 28, 2023 at 16:24

You must log in to answer this question.

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