I have a document that is about 1/3 to 1/2 page long. I want to compile it to a PDF document. That PDF document will be included in another document, so I want it to be short - it should contain only the contents of the document, without white space below it. How can I do this?
Asked
Active
Viewed 782 times
12
-
Related Question: Automate Fixed Width Page, length > some minimum length, but only as long as needed. – Peter Grill Nov 12 '18 at 08:50
2 Answers
12
You could use the standalone class in combination with a minipage of the same width as the text in your main document:
\documentclass{standalone}
\usepackage{lipsum}
\begin{document}
\begin{minipage}{345pt}
\lipsum[2]
\end{minipage}
\end{document}
To find out what the width of the text in your main document is, the showdim package offers the \tenthpt macro:
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{showdim}
\begin{document}
\tenthpt{\textwidth}
\lipsum[2]
\noindent\includegraphics[width=\textwidth]{document}
\end{document}
(the vertical space between the text and the image might need a bit of adjustment)
samcarter_is_at_topanswers.xyz
- 158,329
10
Use pdfcrop:
\documentclass{article}
\usepackage{lipsum} % for mock text
\pagestyle{empty} % no page ornaments
\begin{document}
\lipsum[1]
\end{document}
Save this as shortdoc.tex and run
pdflatex shortdoc
pdfcrop shortdoc
This will produce shortdoc-crop.pdf, that you can include with \includegraphics.
egreg
- 1,121,712
