Lilypond generated with MuseScore does not fit the width of the page in XeTeX doc

lilypond-book is just a complicated way of producing cropped PDF images of each of your examples and then automatically including them in a LaTeX file.

You can do the same thing by hand, in my opinion much more simply, by using the EPS backend of lilypond to produce an image cropped to the size of the music.

Then the only real LaTeX component is to include the PDF images using the graphicx package. The main point is that you can set the width of the image in the lilypond source and then just include it at its natural size in the LaTeX document.

In the example below, you can \include the example.ly file in all your music example .ly source files, and when compiled they will produce cropped PDFs.


Three files for this example:

    1. example.ly -- Page layout for cropped musical examples in lilypond
    1. score.ly -- Your musical example, which \includes the page layout commands from example.ly
    1. analysis.tex -- Sample TeX file showing how the image is included.

FILE 1, example.ly

% STYLE SHEET FOR IN-TEXT EXAMPLES

\version "2.18.2"

#( ly:set-option 'backend 'eps )

\paper{
  indent = 0.75\in
  line-width = 6.5\in
    top-margin = 1\in
    bottom-margin = 2\in
    ragged-bottom = ##t
    ragged-last-bottom = ##t
  oddFooterMarkup=##f
  oddHeaderMarkup=##f
  bookTitleMarkup = ##f
  scoreTitleMarkup = ##f
}

FILE 2 -- score.ly

\version "2.18.2"
\include "example.ly"

Music = { 
    \clef "tenor"
    \time 3/4
    c4 d4 e4 |
    f2 g4~ |
    g4 a2 |
    b2. |
    c'2. |
    \bar "||"
}

\score{
    <<
        \new Staff { \Music }
    >>
    \layout {}
}

FILE 3 - analysis.tex

\documentclass{article}
\usepackage[letterpaper,margin=1in]{geometry}
\usepackage{graphicx}
\usepackage{lipsum}

\begin{document}

\section{Music Example}

\lipsum[1]
See example~\ref{fig:score1}.

%*******************
\begin{figure}
\includegraphics{score}\centering
\caption{Score example 1}
\label{fig:score1}
\end{figure}
%*******************

\lipsum[2]


\end{document}

enter image description here