Scores Without Margins

While the capabilities of LaTeX are such that you can make pretty much any kind of document you desire within it, there are occasions where it's useful to prepare a Gregorian chant score for insertion into another work flow which doesn't use LaTeX. In these instances, it's often useful if the score's margins are eliminated to prevent the score from having excess padding around it in the final document. Fortunately, this actually isn't too difficult in LaTeX as shown in the following example:

% !TEX program = LuaLaTeX+se

% This document produces a pdf containing the score with no margin.
% It is based on this solution:
% http://tex.stackexchange.com/questions/291630/best-way-to-know-bottom-line-height-of-a-pdf/291664#291664
%
% It contains advanced commands quite difficult to understand, but should be straightforward
% to adapt to your needs.
%
\documentclass[11pt]{article}
\usepackage{gregoriotex}
\usepackage{libertine}
% Do not load geometry, fullpage, or any package changing width
% or margins.

\hoffset-1in
\voffset-1in
\newbox\scorebox

% using the "commentary" header of the gabc file
\gresetheadercapture{commentary}{grecommentary}{string}

\begin{document}

% here the final "9" of the commentary would be cut too sharp. The reason is that
% the italic "9" glyph in the libertine font is larger than its bounding box, the
% dimension of which that TeX is actually aware (which is normal for italic), so we
% have manually insert the italic correction (`\/`), the small kern which is normally
% used when switching from italics to upright fonts.
% In the libertine font, the “f” is also slightly taller than its bounding box, so we have
% to prevent it from getting cut off too.  Unfortunately, there isn’t a convenient
% measure of this built in, so we have to fudge this ourselves with a strut.  Adjust the
% 0.8em to your taste.
% We use an admittedly strange trick to fix these, redefining grecommentary.
\let\grevanillacommentary\grecommentary
\def\grecommentary#1{\grevanillacommentary{#1\/\rule{0pt}{0.8em}}}

\setbox\scorebox=\vbox{\hsize=10cm\relax % change the width of the score here
	\gregorioscore[a]{PopulusSion}
}
\pdfpagewidth\wd\scorebox
\pdfpageheight\dimexpr\ht\scorebox+\dp\scorebox\relax
\shipout\box\scorebox
\end{document}

Once compiled, this code will produce a pdf file like this one.

Works with Version:

4.1.0