# Place two Lilypond examples side by side

I need help here: I am trying to place two Lilypond musical examples side-by-side. How can I achieve that? Any help is appreciated.

This is the code I am using:

\usepackage{float}
...
\begin{document}
...
\begin{minipage}
\begin{example}
\centering
\begin{lilypond}[staffsize=12]

Musical Example 1 comes here

\end{lilypond}
\caption{Caption 1}
\label{ex1}
\end{minipage}
\begin{minipage}
\begin{example}
\centering
\begin{lilypond}[staffsize=12]

Musical Example 2 comes here

\end{lilypond}
\caption{Caption 2}
\label{ex2}
\end{minipage}
\end{document}

By the way, TexShop with the Lilypond-Book implementation is a life saver!

Your MWE is missing some information, but this seems to work fine for me:

\documentclass{article}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\begin{lilypond}[fragment]
c4
\end{lilypond}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\begin{lilypond}[fragment]
c4
\end{lilypond}
\end{minipage}
\end{figure}

\end{document}

(Compiled with lilypond-book --output=out --pdf file.lytex, cd out, and pdflatex file.tex.)

• This solution works fine, except I can't get captions for both musical examples. Thank you, though. – Lotto May 11 '17 at 2:46
• @Lotto In that case, you may want to unaccept my answer and accept Tiuri's answer instead. – Richard Jun 14 '17 at 20:05

Typesetting two lilypond examples side by side with the option of giving captions to them (that seems to be important for you) can easily be done with the subfigure package:

\documentclass{article}
\usepackage{subfigure}
\begin{document}
\begin{figure}
\centering
\subfigure[First example.]{\begin{lilypond}[fragment]
c4
\end{lilypond}}
\hspace{0.1\textwidth}
\subfigure[Second example.]{\begin{lilypond}[fragment]
c4
\end{lilypond}}
\caption{Here are two music examples.}
\end{figure}
\end{document}

If you don't want to have a common caption for the two examples together, but rather treat them caption-wise as seperate figures, you can stick with Richard's solution and just add \caption beneath both examples:

\documentclass{article}
\begin{document}
\begin{figure}
\centering
\begin{minipage}{.5\textwidth}
\centering
\begin{lilypond}[fragment]
c4
\end{lilypond}
\caption{First example.}
\end{minipage}%
\begin{minipage}{.5\textwidth}
\centering
\begin{lilypond}[fragment]
c4
\end{lilypond}
\caption{Second example.}
\end{minipage}
\end{figure}
\end{document}