GeneralPackage "songs" - how to align versenum to the right?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
Manuela
Posts: 8
Joined: Thu Dec 16, 2021 7:19 pm

Package "songs" - how to align versenum to the right?

Post by Manuela »

Hi,
I am an absolute newbie, so pls forgive me in advance for asking stupid questions.

I am trying the package songs, the versenumbers are aligned to the left side. I want to have them aligned right of the verse beginning. The documentation says:
Verse numbers are placed flush-left. This is achieved by inserting horizontal gluethat reverses both the\leftskipand the\parindent. The single argument tothis macro is an hbox containing the verse number.

Here is the code

Code: Select all

\newcommand\placeversenum[1]{
\hskip-\leftskip\hskip-\parindent\relax
\box#1
}
I have tried \rightskip instead of \leftskip, this was complete nonsens.

Here is a minimum example, the effect is better visible when using roman numbers

Code: Select all

\documentclass{article}

\usepackage[lyric,noshading,nomeasures,noindexes]{songs}
\settowidth{\versenumwidth}{IVII.\ }
\renewcommand{\theversenum}{\Roman{versenum}}
\begin{document}
\begin{songs}{}
\beginsong{Minimal example song}[
  by={}
  ,sr={}
  ,li={}
  ,cr={}]
\beginverse
Verse 1 row 1
row 2
\endverse
\beginverse
Verse 2 row 1
row 2
\endverse
\beginverse
Verse 3 row 1
row 2
\endverse
\beginverse
Verse 41 row 1
row 2
\endverse
\beginverse
Verse 5 row 1
row 2
\endverse
\beginverse
Verse 6 row 1
row 2
\endverse
\beginverse
Verse 7 row 1
row 2
\endverse
\beginverse
Verse 8 row 1
row 2
\endverse
\beginverse
Verse 9 row 1
row 2
\endverse

\endsong
\end{songs}
\end{document}
How can I change \placeversenum to get the numbers aligned right?
Thank you for your help,
greetings,
--Manuela

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

User avatar
Ijon Tichy
Posts: 640
Joined: Mon Dec 24, 2018 10:12 am

Package "songs" - how to align versenum to the right?

Post by Ijon Tichy »

I would not change \placeversenum, but \versenumstyle (to get Roman numbers) and \printversenum to print the verse number right aligned into a box of the with of a verse number.

Code: Select all

\documentclass{article}

\usepackage[lyric,noshading,nomeasures,noindexes]{songs}
\renewcommand*{\versenumstyle}{\Roman}
\settowidth{\versenumwidth}{\printversenum{VIII.}}% Use the original definition to get the width.
\renewcommand{\printversenum}[1]{\lyricfont\makebox[\versenumwidth][r]{#1.\ }}% Change the original definition to add a box of the previously set width.
\begin{document}
\begin{songs}{}
\beginsong{Minimal example song}[
  by={}
  ,sr={}
  ,li={}
  ,cr={}]
\beginverse
Verse 1 row 1
row 2
\endverse
\beginverse
Verse 2 row 1
row 2
\endverse
\beginverse
Verse 3 row 1
row 2
\endverse
\beginverse
Verse 41 row 1
row 2
\endverse
\beginverse
Verse 5 row 1
row 2
\endverse
\beginverse
Verse 6 row 1
row 2
\endverse
\beginverse
Verse 7 row 1
row 2
\endverse
\beginverse
Verse 8 row 1
row 2
\endverse
\beginverse
Verse 9 row 1
row 2
\endverse

\endsong
\end{songs}
\end{document}
Sorry, but I can no longer participate here as the administrator is trampling on my wishes on one of his other platforms. :cry:
Manuela
Posts: 8
Joined: Thu Dec 16, 2021 7:19 pm

Package "songs" - how to align versenum to the right?

Post by Manuela »

Thank you, this works like a charm.

BTW, Lem is my favourite SF author. I met him in the 80s in Vienna and had him signed some books.
Thank you for your help,
greetings,
--Manuela
Post Reply