2

I want to define a command that applies to all text within the current scope, like \bfseries. I need this, because the leadsheets package allows me to pass a label-format command to an environment, which will then be inserted at the start of the label (in my case the numbering in front of a verse). I'd like to draw a circle around the number. For this, I found this code

\usepackage{tikz}
\newcommand*\circled[1]{\tikz[baseline=(char.base)]{
        \node[shape=circle,draw,inner sep=2pt] (char) {#1};}}

which works great when I'm able to directly wrap it around the text I want to circle. The problem is now, that if I just pass label-format=\circled tex complains that a } is missing and if I use label-format=\circled{} the compiler is fine, but obviously nothing happens.

How can I achieve the effect described above? label-format=\bfseries works perfectly, so I need a command that automatically wraps around the following text.

Unfortunately, I don't know how you call such commands in LaTeX so I couldn't search for it.

  • 1
    That's not possible, \circled cannot be written font switch command. Hacking the leadsheets package seems the better approach. But the package is not on CTAN. A MWE and a link to the package would be useful. – Heiko Oberdiek Jul 18 '18 at 17:30
  • I expected that it would be hard/impossible. Too bad :/ By the way: The package can be found on ctan: ctan.org/pkg/leadsheets?lang=en – Taxel Jul 18 '18 at 17:32
  • I had searched for leedsheets instead of leadsheets. – Heiko Oberdiek Jul 18 '18 at 17:59
  • 2
    This requires a small change in \leadsheets_verse_label:n I think. Probably worth a feature request... – clemens Jul 18 '18 at 19:08
  • 2
    An MWE would give you a better chance of an answer. – cfr Jul 19 '18 at 2:12
2

Starting with v0.6 (2019/10/02) leadsheets allows that the last formatting command of verse labels may accept a mandatory argument:

\documentclass{article}
\usepackage{tikz}
\newcommand*\circled[1]{%
  \tikz[baseline=(char.base)]{
    \node[shape=circle,draw,inner sep=2pt] (char) {#1};
  }%
}

\usepackage{leadsheets}[2019-10-02]
\setleadsheets{
  verse/numbered,
  verse/label-format = \circled
}

\begin{document}

\begin{song}{title=My Song}
\begin{verse}
  bla bla
\end{verse}
\begin{verse}
  blub blub
\end{verse}
\end{song}

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.