# Automatically generate fitted pdfs

I'm writing some kind of a notebook using LaTex. I'd like to have basically one page for each note, the page being fitted to the text of the note. For the moment I'm using a very long page by default, generate the pdfs using pdflatex, and then crop them using pdfcrop, and finally merge them using gs. Everything runs fine, but the links inside the cropped pdfs are broken.

Can I generate fitted pdf directly from pdflatex? Otherwise, can I crop the pdfs and preserve the links? Thanks!

Next code was taken from this answer and slightly modified adding multi=task, border=2mm options.

It uses standalone class as cropping tool and tcolorbox to produce notes (task in this case).

\documentclass[multi=task,border=2mm]{standalone}

\usepackage[theorems]{tcolorbox}% version 2.51 (2013/09/16)
\usepackage{lipsum}

\begin{document}

\lipsum[3]

\lipsum[3]

\end{document}


This code produces a pdf file with to pages like:

• Thanks! One issue however is that my notes are not LaTeX environments like the newtcbtheorem in your example. So apparently standalone doesn't seem to understand that it needs to crop the file. Do you see any solution? Thanks again. – Martin Jan 29 '15 at 10:31
• @Martin Please read page 9 from standalone documentation. You need to fix some environment to be cropped. But it can be something like \newenvironment{note}{}{}. If you could post some example with your notes ... – Ignasi Jan 29 '15 at 11:29
• Thanks Ignasi. Finally I created an environment for my notes, now it works just perfectly. Thanks again! – Martin Jan 30 '15 at 12:23