12

I'd like to make something like a songbook - just chords and lyrics. I have found several packages, but I also wanted to improve my TeXing skills by making my own commands/environmnets etc. Now I am struggling with this: I want to put chords above certain parts of lyrics, for example.

Gm
Remember when you were young,

Gb                 Bb
You shone like the sun.

Eb   Dm   Cm   Bb    F
Shine on you crazy diamond.

But I don't want to do this manually for maybe hundreds of songs. I'm hoping for a better way than counting the space between each two chords, something like this:

% ... TeX code
Eb\hspace*{XYpt}Dm\hspace*{XYpt}Cm\hspace*{XYpt}Bb\hspace*{XYpt}F
Shine on you crazy diamond.
% .. TeX code

or:

% .. TeX code
Eb\verb=   =Dm\verb=   =Cm\verb=   =Bb\verb=    =F
Shine on you crazy diamond.
% .. TeX code

I would be happy to find solution that would look like:

% .. TeX code
\chord{Eb}Shine\chords{Dm} y\chord{Cm}ou cr\chord{Bb}azy di\chord{F}amond
% .. TeX code

Maybe it looks more "messy", bud I think the result would be more precise. And as soon as I will find the solution to this problem, I will write some script in C or Python to format the songs for me.

4
  • do you still have your C or Python script for formatting the songs? In the end it would be most awesome to be able to input text files from ultimate-guitar.com, detect the chord positions and then placing them by a method like in one of the two answers below Mar 8, 2016 at 18:16
  • 1
    I did not finish the scripts before and started working on it again few days ago. I am not aiming for ultimate-guitar.com, but I like that idea quite a lot. If anything worth mentioning comes out from my work, I'll let you know.
    – quapka
    Apr 8, 2016 at 9:54
  • thanks! ultimate-guitar.com was an example, but similar input (monospace font where the chord position is decoded by the number of spaces) would be a great thing. Anyway, I'm interested about any outcome! Apr 8, 2016 at 14:03
  • I think, that with the assumption about monospace font (and decoding the position of chords based on number of white spaces) it would be quite easy. I don't know much about ultimate-guitar.com, this looks like monospace (at least Libre Writer interprets it that way). I am currently working on maybe worse scenario, where sample input looks like this: $Eb$Shine $Dm$on you$Cm$ cr$Bb$azy di$F$amond. So chords are enclosed in $$ signs (later parsed with regex \$\w+\$).
    – quapka
    Apr 8, 2016 at 18:01

5 Answers 5

10

enter image description here

\documentclass{article}

\newcommand\chord[2][l]{%
  \makebox[0pt][#1]{\begin{tabular}[b]{@{}l@{}}#2\\\mbox{}\end{tabular}}}

\begin{document}


\chord{Eb}Shine \chord[c]{Dm}on you\chord[r]{Cm} cr\chord{Bb}azy di\chord{F}amond

\end{document}
6
  • Thanks, I think it precisely satisfies my need. I understand most of it, but could you next time explain some of your steps? Well, it's just lack of my knowledge about \makebox and \mbox.
    – quapka
    Dec 1, 2013 at 11:32
  • @quapka I could but you learn more from looking them up, given the hint of running code:-) Dec 1, 2013 at 11:34
  • That's totally true, I'm probably just lazier today:)
    – quapka
    Dec 1, 2013 at 11:36
  • 2
    Come on you target for faraway laughter, come on you stranger, you legend, you martyr, and shine! Dec 2, 2013 at 9:13
  • 2
    @David: \chord{Eb}Come on you target for \chord{C7}faraway laughter, \chord{Bb}come on you stranger, you \chord{Dm}legend, you \chord{D7}martyr, and \chord{Gm}shine! :) Dec 2, 2013 at 10:14
12

The code from my other answer was the beginning for my leadsheets package which is on CTAN and in TeX Live since January 2015 (and which I now use extensively myself).

\documentclass{article}
\usepackage{leadsheets}

\definesongtitletemplate{empty}{} 

\begin{document}

\begin{song}{title=Nobody Knows You When You're Down And Out}
\begin{verse}
  ^*{C}O nce I lived the ^{E7}life of a ^*{A7}mil lionaire \\
  ^{Dmi} Spent all my ^*{A7}mon ey, didn't ^{Dmi}have any cares \\
  ^{F}Took all my ^{F#dim}friends out for a ^*{C}migh ty good ^{A7}time \\
  ^{D7} Bought bootleg liquor, ^*{G7}cham pagne and wine
\end{verse}
\end{song}

\setleadsheets{
  title-template = empty ,
  song-format = \ttfamily ,
  chords/sharp = \# ,
  chords/flat = b
}

\begin{song}{title=Nobody Knows You When You're Down And Out}
\begin{verse}
  ^*{C}O nce I lived the ^{E7}life of a ^*{A7}mil lionaire \\
  ^{Dmi} Spent all my ^*{A7}mon ey, didn't ^{Dmi}have any cares \\
  ^{F}Took all my ^{F#dim}friends out for a ^*{C}migh ty good ^{A7}time \\
  ^{D7} Bought bootleg liquor, ^*{G7}cham pagne and wine
\end{verse}
\end{song}

\end{document}

enter image description here

4
  • skimming through the documentation your package seems like a strong competitor of the songs package that I mentioned, I'll need to try it out later. Do you know the songs package? If yes, could you list a few differences (where which package is stronger)? It's okay if you're biased ;-) Apr 16, 2016 at 11:45
  • 3
    @riddleculous I don't know the songs package very much but I believe that one of the biggest advantages of leadsheets is that the user has complete control over layout (through the template mechanism)
    – cgnieder
    Apr 17, 2016 at 9:57
  • The songs package is indeed very restricted in that aspect. Luckily the syntax for the chords is quite so I can test and compare both. I'll give you some feedback in case I notice anything that works better in the songs package (I guess that one is more suited for the creation of congregational song books which I intend to do, too) Apr 17, 2016 at 10:43
  • @riddleculous for what it's worth: I used leadsheets to create a few songbooks for my personal use already and use it extensively to create the leadsheets for my band.
    – cgnieder
    Apr 17, 2016 at 10:50
4

There exists a package for this, too, an example can be found here, I steal an example from there:

\documentclass[letterpaper]{article}
\usepackage[chorded]{songs}
\newindex{titleidx}{cbtitle}

\begin{document}
\begin{songs}{titleidx}
\beginsong{Amazing Grace}[
  by={John Newton},
  sr={Luke 15:4; 2 Corinthians 4:8,9; Ephesians 2:8; Revelation 14:3},
  cr={Public domain.}]
\beginverse
A\[E]mazing \[E/D#]grace! How \[A/C#]sweet the \[E/B]sound
That \[E]saved a \[E/C#]wretch like \[B7]me!
I \[E]once was \[E/D#]lost, but \[A/C#]now am \[E/B]found;
Was \[A]blind, but \[A/B]now I \[E]see.
\endverse
\beginverse
T'was ^grace that ^taught my ^heart to ^fear,
And ^grace my ^fears re^lieved;
How ^precious ^did that ^grace ap^pear
The ^hour I ^first be^lieved!
\endverse
\endsong
\end{songs}
\end{document}

Songbook output you'll get the right image by replacing chorded in the package option by lyric.

4

Every now and then I create a lead sheet. For that purpose I created an environment Verse that enumerates its contents (it is an enumerate environment, really) and a command \chord with the following syntax:

\chord*{<chord symbol>}<text><space>

where the star and <text> are optional. The starred version gobbles the trailing space and the unstarred doesn't. If <text> is empty \quad is inserted for some horizontal space.

Below is the code I used. (The second example uses my realbookchords package for typesetting the chords and needs XeLaTeX or LuaLaTeX and of course the package and the font installed.)

enter image description here

% arara: xelatex
\documentclass{article}
\usepackage{fontspec}
\usepackage{realbookchords}
\newfontfamily\Augie[Ligatures=TeX]{Augie}

\makeatletter

% \chord*{<chord>}<word><space>
%  * gobbles following space
%  <chord> chord symbol specification
%  <word> chord is placed above this (optional)
%  <space> mandatory end of argument

\newcommand*\printchord[1]{#1}

\newif\if@chord@gobble
\newcommand*\chord{%
  \@ifstar
    {\@chord@gobbletrue\@chord}
    {\@chord@gobblefalse\@chord}%
}
\newcommand*\@chord[1]{%
  \@chord@aux{#1}%
}
\newcommand*\@chord@aux{}
\def\@chord@aux#1#2 #3{%
  \placeabove{\printchord{#1}}{\ifemptyquad{#2}}%
  \if\relax\detokenize{#3}\relax
  \else
    \if@chord@gobble\else\space\fi
  \fi
  #3%
}
\newcommand*\ifemptyquad[1]{%
  \if\relax\detokenize{#1}\relax
    \quad\expandafter\@gobble
  \else
    \expandafter\@firstofone
  \fi
  {#1}%
}

\newcommand*\placeabove[2]{%
  \begingroup
    \linespread{1}\selectfont
    \begin{tabular}[b]{@{}c@{}}#1\\#2\end{tabular}%
  \endgroup
}

% \begin{Verse}[<text>]
% if <text> is not present then the Verse is enumerated, else <text> is
% inserted as a label

\newcounter{Verse}
\renewcommand\theVerse{\arabic{Verse}.}
\newcommand*\Versefont{\normalfont}

% enumerated:
\newenvironment{Verse}[1][]
  {%
    \if\relax\detokenize{#1}\relax
      \stepcounter{Verse}%
      \enumerate\item[\theVerse]\relax
    \else
      \enumerate\item[{#1}]\relax
    \fi
    \par\Versefont
  }
  {\endenumerate}

% not enumerated:
\newenvironment{Verse*}[1][]
  {%
    \if\relax\detokenize{#1}\relax
      \itemize\item[]\relax
    \else
      \itemize\item[{#1}]\relax
    \fi
    \par\Versefont
  }
  {\enditemize}
\makeatletter

\begin{document}

\begin{Verse*}
  \chord*{C}O nce I lived the \chord{E7}life of a \chord*{A7}mil lionaire \\
  \chord{Dmi} Spent all my \chord*{A7}mon ey, didn't \chord{Dmi}have any
    cares \\
  \chord{F}Took all my \chord{F\#dim}friends out for a \chord*{C}migh ty
    good \chord{A7}time \\
  \chord{D7} Bought bootleg liquor, \chord*{G7}cham pagne and wine
\end{Verse*}

\renewcommand*\printchord[1]{{\footnotesize\rbc{#1}}}
\renewcommand*\Versefont{\Augie}

\begin{Verse*}
  \chord*{C}O nce I lived the \chord{E7}life of a \chord*{A7}mil lionaire \\
  \chord{Dmi} Spent all my \chord*{A7}mon ey, didn't \chord{Dmi}have any
    cares \\
  \chord{F}Took all my \chord{F\s dim}friends out for a \chord*{C}migh ty
    good \chord{A7}time \\
  \chord{D7} Bought bootleg liquor, \chord*{G7}cham pagne and wine
\end{Verse*}

\renewcommand*\printchord[1]{\texttt{#1}}
\renewcommand*\Versefont{\ttfamily}

\begin{Verse*}
  \chord*{C}O nce I lived the \chord{E7}life of a \chord*{A7}mil lionaire \\
  \chord{Dmi} Spent all my \chord*{A7}mon ey, didn't \chord{Dmi}have any
    cares \\
  \chord{F}Took all my \chord{F\#dim}friends out for a \chord*{C}migh ty
    good \chord{A7}time \\
  \chord{D7} Bought bootleg liquor, \chord*{G7}cham pagne and wine
\end{Verse*}

\end{document}

Remark: the above is now implemented in a more general way in my leadsheets package…

5
  • Pretty cool! Thanks. Momentarily I am working on the coding part, but I'll come back later and take a better look at you answer.
    – quapka
    Dec 1, 2013 at 17:19
  • No Pink Floyd? :) I'll let you pass this time because it's Clapton. :) Dec 2, 2013 at 9:15
  • @PauloCereda lol :) It has a bigger variety of chords. But it's Jimmy Cox, actually: en.wikipedia.org/wiki/…
    – cgnieder
    Dec 2, 2013 at 9:47
  • @cgnieder: ooh! ❤ Dec 2, 2013 at 10:15
  • @cgnieder Didn't know that, thanks. Also one of the songs i enjoy!
    – quapka
    Dec 2, 2013 at 23:16
0

You can type your songs in both lyrics and chord template, https://patacrep.fr/en/static1/downloads , its a gui software using latex

You must log in to answer this question.

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