I currently making a songbook and thus I want to display chords above lyrics. I have found several packages but I want to improve my TeXing skills so I wrote everything from scratch.

Until now, everything works fine apart from one thing: some chords are too long and overlaps with the next one.

I have some way to do it, by explaining each time what text correspond to each chord (see the second part of the minimal example) but it would mean rewriting all song I already have. So I wanted to know if there was a way to automatically add space when needed, without having to specify which text correspond to which chord!

Here is a minimal example (the whole code is much longer but I don't think it's needed here):


  \leavevmode\hbox to 0pt{\vbox{\hbox{\strut\tt#1}\kern.25cm}\hss}%


  \ch{A}Lorem ipsum \ch{B}dolor sit amet, \ch{C}consectetuer \ch{D}adipiscing elit.

  \ch{A}Ut purus elit, vesti\ch{B}bulum \ch{C}ut, placerat ac, adipiscing vitae, \ch{D}felis.

  \ch{A}Curabi\ch{B7sus4}tur \ch{C}dictum \ch{D7sus4}gravi\ch{E}da mauris.

  \textit{I would want to have something that look like this:}\par
    \leavevmode\vbox{\hbox{\strut\tt#1 }\hbox{#2}}%
  \foo{A}{Curabi}\foo{B7sus4}{tur} \foo{C}{dictum}  \foo{D7sus4}{gravi}\foo{E}{da mauris}.


which gives results

Note: I know that this might not be possible on justified multi-line paragraph, but we only have flushed/centered paragraph here (or even single lines), so the space between words should be fixed (I guess?).

  • 1
    You could programmatically build a tabular for each verse with l-type columns and no space between them (@{} in tabular header). Important is to decide on a convenient input syntax that is easy to parse, yet flexible enough. Maybe something like this? \begin{myverse} {A}{Curabi}, {B7sus4}{tur }, {C}{dictum }, {D7sus4}{gravi}, {E}{da mauris.} \end{myverse}. You could possibly use one such environment for the whole, separating verses with \\, but this might make it more difficult to have explicit line breaks within verses later (unless you decide to use a different separator).
    – frougon
    Dec 27, 2019 at 11:59
  • tabular is a very good place to start. Put each phrase/chord pair into its own tabular: \documentclass{article} \usepackage{stackengine} \renewcommand\stackalignment{l} \begin{document} \stackon{Curabi}{A}%no space \stackon{tur}{B7sus4} %<--space \stackon{Dictum}{C} \stackon{gravi}{D7sus4} \stackon{da mauris.}{E} \bigskip \begin{tabular}{l}A\\Curabi\\\end{tabular}\kern-1.2em \begin{tabular}{l}B7sus4\\tur\\\end{tabular}% \begin{tabular}{l}C\\Dictum\\\end{tabular}% \begin{tabular}{l}D7sus4\\gravi\\\end{tabular}% \begin{tabular}{l}E\\da mauris.\\\end{tabular}% \end{document}
    – Cicada
    Dec 27, 2019 at 12:54
  • Hmm, those solution doesn't really suit me as I would have to rewrite every song I already have... This wasn't clear so I will edit my question, sorry!
    – Vinzza
    Dec 27, 2019 at 13:18
  • why don't you use the form you use with \foo with two arguments that works? It would be only a trivial edit in an editor to change \ch{[^{}]*}[a-zA-Z]* to the two argument form \foo{...}{..} Dec 27, 2019 at 21:57
  • You're right! This is probably the easier solution and I might end up doing it! (I hadn't thought about regexp, thanks for the reminder!) :)
    – Vinzza
    Dec 28, 2019 at 15:22

2 Answers 2


May I suggest using a package like leadsheets:


  align-chords=l ,


\begin{song}{title=Lorem Ipsum}
  ^{A}Lorem ipsum ^{B}dolor sit amet, ^{C}consectetuer ^{D}adipiscing elit. \\
  ^{A}Ut purus elit, vesti^{B}bulum ^{C}ut, placerat ac, adipiscing vitae,
  ^{D}felis. \\
  ^*{A}Curabi ^{B7sus4}tur ^{C}dictum ^{D7sus4}gravi ^{E}da mauris.  


enter image description here

Inside the song environment chords are placed with the shortcut ^: ^{chord}word.

For two chords over one word you'd need to split the word ^*{A}Curabi ^{B7sus4}tur and let the starred version ^*{chord}word gobble the following blank.

  • It seems to do exactly what I wanted! I'm going to look at the sources of the package, as I'm curious to know how it's done! Thanks!
    – Vinzza
    Dec 28, 2019 at 15:34

There is also a simple package called musixguit to create chords with the guitar...Here I add a MWE with the my preferite singer:


\textbf{Gloria - Umberto Tozzi -}
Great Umberto \dSmiley\dSmiley.
\chord{SI}Gloria, manchi tu nell'\chord{MI}aria

\chord{SI}manchi ad una mano che lavora \chord{MI}piano

\textit{with bold chords}

\textbf{\chord{SI}}Gloria, manchi tu nell'\textbf{\chord{MI}}aria

\textbf{\chord{SI}}manchi ad una mano che lavora \textbf{\chord{MI}}piano


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.