# Making the document hight size to content

A bit of context to help understand what I want to do. I am working with a project that is using Gregorio to typeset chant. The output is not used in a PDF but rather converted to images to be used in other documents. So the idea is to have pages that fit exactly to the size necessary without any extra white space around it. I have been handed 1000+ files that have been collected from various sources to be used like this.

A template for the .tex file used to convert them would look something like this:

% !TEX program = LuaLaTeX+se
% !TEX encoding = UTF-8 Unicode
\documentclass[11pt]{article}
\RequirePackage[paperheight=2.25in,paperwidth=4in,top=0cm,left=0cm,right=0cm,bottom=0cm]{geometry}

\usepackage[autocompile]{gregoriotex}
\usepackage[savepos]{zref}
\usepackage{libertine}
\pagestyle{empty}
\gresetlastline{justified}
\gresetinitiallines{1}

\begin{document}
\gregorioscore{CHANT_FILE_NAME}
\end{document}


Problem is that I have to manually work out what height should be used for each file. I would rather it be able to workout the height automatically. There are other questions that are similar like this one XeLaTeX: how do I make paper to be exactly the size of the content? but I need to some how specify the width that I want, and \documentclass{standalone} does not seem to allow for that. Other options also seem to result the wrong output, with all the chant on a single line.

Is there any possible solution to what I want to do, or am I going to have to do this manually?

You can use e.g. standalone together with a minipage to force a specific width:

\documentclass{standalone}
\begin{document}
\begin{minipage}{5cm}
blub

\vspace{3cm}

xxx
\end{minipage}
\end{document}


• You might mention the preview option to allow linebreaks outside of boxes. – Skillmon May 29 '17 at 20:29
• @Skillmon I don't see a reason to use preview here. – Ulrike Fischer May 29 '17 at 20:35
• I added my comment just for the sake of completion, but you're right, here it is unnecessary. – Skillmon May 29 '17 at 20:50
• Just needed to add \RequirePackage{luatex85} for LuaLaTex. Otherwise works perfectly and does just what I want. – Michael Buckley May 29 '17 at 21:07