Created
April 11, 2018 21:55
-
-
Save lucaswerkmeister/17f1daeed0e6faae3366a4b08c1e29a9 to your computer and use it in GitHub Desktop.
Example of combining LilyPond, LaTeX, listings and beamer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\relative c' { | |
c d e f | | |
g2 g | | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{beamer} | |
\usepackage[utf8]{inputenc} | |
\usepackage{txfonts} | |
\usepackage{xcolor} | |
\usepackage{subcaption} | |
\usepackage{listings} | |
\DeclareUnicodeCharacter{2665}{{\ensuremath\color{red}\varheartsuit}} | |
\beamertemplatenavigationsymbolsempty | |
\lstset{basicstyle=\ttfamily} | |
\begin{document} | |
\begin{frame}[fragile] | |
\frametitle{$\text{LilyPond} + \text{\LaTeX} = ♥$} | |
You can include LilyPond source code using \lstinline{listings} | |
and the corresponding musical notation using \lstinline{lilypond-book}. | |
\begin{figure} | |
\centering | |
\begin{subfigure}[b]{0.4\textwidth} | |
\lstinputlisting{entchen.ly} | |
\caption{The source code.} | |
\end{subfigure} | |
\begin{subfigure}[b]{0.4\textwidth} | |
\lilypondfile{entchen.ly} | |
\caption{The resulting notation.} | |
\end{subfigure} | |
\caption{A simple example melody.} | |
\end{figure} | |
The source code can be included inline | |
(\lstinline{lstlisting} and \lstinline{lilypond} environments) | |
or, even better, from a separate file | |
(\lstinline[language=tex]{\lstinputlisting} and \lstinline[language=tex]{\lilypondfile}). | |
\end{frame} | |
\end{document} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.PHONY: all | |
all: lilypond.pdf | |
%.tex: %.lytex | |
lilypond-book --pdf $< | |
%.pdf: %.tex | |
pdflatex $< |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment