I’ll give a tutorial, “LaTeX for musicians”, in the next year and certainly I want the to show how to include music in their texts. I’m a musician myself but I never used LaTeX to typeset music.
I found two ways to include music in a LaTeX document (plus: integrate music as image) and I want to share my thoughts and ask for some help (see below). First, let's take a more detailed look at both ways:
ABC
Code
% file abc.tex
\documentclass{scrartcl}
\usepackage{abc}
\begin{document}
Text
\begin{abc}[name=c-dur]
X: 1 % start of header
K: C % scale: C major
"Text"C4 G4 | (3FED c4 G2 |
\end{abc}
\end{document}
Compile
pdflatex --shell-escape abc.tex
Output
LilyPond
Code
% file lp.lytex
\documentclass{scrartcl}
\begin{document}
Text
\begin[staffsize=12]{lilypond}
\relative c' {
c2^"Text" g'2 \times 2/3 { f8 e d } c'2 g4
}
\end{lilypond}
\end{document}
Compile
lilypond-book --output=out-dir --pdf lp.lytex
cd out-dir
pdflatex lp.tex
Output
Comparison
Now let’s talk about the pros and cons.
- The ABC workflow is much easier than the one of LilyPond and it simply needs a call of
pdflatex
. For this it’s preferable for the students of the tutorial since most of them aren't computer geeks. - The ABC syntax seems to bee easier at a first glance.
- LilyPond uses the right font i.e. the font of the LaTeX document.
abc.sty
always produces a display style image, i.e., it starts a new line and centers it’s content. Furthermore there seems to be now option to shorten the line that they fit just the typed notes and not span the whole\linewidth
(workaround: setwidth=0.5\abcwidth
).- As far as I can see LilyPond is more flexible in the number of ways to typeset music (inline, display style, …) and the possibilities of typesetting in general.
- The LilyPond music font looks better except the fat bar lines.
Questions
The numbers are not to give an order. I numbered the questions to make it easy to answer the …
- Which way would you prefer to use? Which one do you suggest for students how a not very good in using computers?
- I wonder if it will be possible to create a package that integrates LilyPond in the same way that
abc.sty
does width ABC notation - Can one change the font of the ABC output so that it matches the LaTeX main font?
- Is there a way to make ABC find a good line length for the given number of notes?
- Can one change the width of LilyPonds bar lines?
Conclusion
I’d prefer to use (and teach) the LilyPond way but I fear the compilation workflow would scare the students. So if question 2 could be solved it would be great :-)
I hope you understand what I want since my english may be not the best. Please ask if something is not clear …
\usepackage{abc}
. How come you don't include any package for the lilypond? I am asking, because i couldn't find the lilypond package myself. – 71GA Apr 14 '12 at 10:22lilypond-book
before you can process it withpdflatex
. The precompiling looks for the{lilypond}
environment. Crates the score as an image and replaces the environment in the precomiledtex
file with commands to include the image. Just process the above example to see how it works. – Tobi Apr 14 '12 at 14:00