1

In verse package, one can write anything before a line using \flagverse{}. This command, however, must also come before the line. This causes some trouble to read the lines in the source, since it's confusing to distinguish what is line and what is flag; so I was thinking to modify it in order to put the \flagverse{} command after the line, but still in such a way that it displays the flag before the line in the pdf.

The source for this command is:

\newcommand{\flagverse}[1]{%
\hskip-\vleftskip\llap{#1}\hskip\vleftskip
\ignorespaces
}

What I need is a \newcommand such that

\begin{verse}
this is a line \\
this is another line \flagverse{this is a flag} \\
\end{verse}

produces

                  this is a line
this is a flag    this is another line 

1 Answers1

1

You can measure where the flag is positioned (in a zero width box) and add a suitable kern to move the text to the left.

\documentclass{article}
\usepackage{verse}
\usepackage{zref,zref-user,zref-savepos}
\usepackage{showframe}

\usepackage{lipsum}

\newcounter{postflagverse} \makeatletter \newcommand{\postflagverse}[1]{% @bsphack \stepcounter{postflagverse}% \zlabel{pfv@\thepostflagverse @page}% \zsaveposx{pfv@\thepostflagverse @pos}% \makebox[0pt][r]{% #1% \kern\dimexpr \zposx{pfv@\thepostflagverse @pos}sp - \ifodd\zref@extractdefault{pfv@\thepostflagverse @page}{pagevalue}{\number\c@page} % \oddsidemargin \else \evensidemargin \fi - 1in - \leftmargin + 2\vleftskip \relax }% @esphack \ignorespaces } \makeatother

\begin{document}

\lipsum[1][1-4]

\begin{verse} \flagverse{flag} this is a line \ \flagverse{this is a flag} this is another line \ this is another line \postflagverse{this is a flag} \end{verse}

\begin{verse}[10em] \flagverse{flag} this is a line \ \flagverse{this is a flag} this is another line \ this is another line \postflagverse{this is a flag} \end{verse}

\end{document}

enter image description here

egreg
  • 1,121,712
  • Do you know how to make all flags italics by default, without having to write \postflagverse{textit{}} every time. I suppose there is a way to do this in the source of this new-command itself, right? – Rhythmical Diphthong Aug 19 '22 at 13:17
  • @RhythmicalDiphthong Add \itshape in front of #1 in the definition of \postflagverse. – egreg Aug 19 '22 at 13:43