The correct parameters to set are \pdfpageheight
and \pdfpagewidth
:
\pdfpageheight=11in
\pdfpagewidth=8.5in
However, this won't work in the "latex+dvips+ps2pdf" cycle. A code for both cases is
\usepackage{ifpdf}
\ifpdf
\pdfpageheight=11in
\pdfpagewidth=8.5in
\else
\special{papersize=11in,8.5in}
\fi
The geometry way is better:
\usepackage[pass,letterpaper]{geometry}
or, if one wants a different paper size, (I'll use Letter paper sizes as example)
\usepackage[pass,paperwidth=8.5in,paperheight=11in]{geometry}
With the pass
option, geometry won't change the class parameters for pagination, as it would do without it.
Note for BakomaTeX
As far as I know, BakomaTeX doesn't use pdflatex
, so the
\usepackage[pass,letterpaper]{geometry}
should be the one to follow.
I would recommend you use the varwidth
package which is similar to the minipage
environment, but sets its width to match the narrower natural width based on the content.
This can be used either with the standalone
package, or you can directly use the preview
package to get (note that the border shown here is from my image capturing):
Here is the MWE using the standalone
class:
\documentclass[tightpage]{standalone}
\usepackage{varwidth}
\begin{document}
\begin{varwidth}{\linewidth}
\section{One document to display}
How to produce an output without any margin.
\par\noindent
$ E = m c^2 $ but it seems that we can have $ v > c $.
\end{varwidth}
and using the preview
package:
\documentclass{article}
\usepackage[active,tightpage]{preview}
\usepackage{varwidth}
\begin{document}
\begin{preview}
\begin{varwidth}{\linewidth}
\section{One document to display}
How to produce an output without any margin.
\par\noindent
$ E = m c^2 $ but it seems that we can have $ v > c $.
\end{varwidth}
\end{preview}
\end{document}
I suspect that standalone
class internally uses the preview
package to do something like this, so probably not much difference in this case, but might be useful if you needed to use a different class.
If this is something you are going to do often it is worthwhile automating this solution by using \AtBeginDocument
and \AtEndDocument
in the preamble to automate this. Here is the same code with this automation in the preamble and using the book
class:
\documentclass{book}
\usepackage[active,tightpage]{preview}
\usepackage{varwidth}
\AtBeginDocument{\begin{preview}\begin{varwidth}{\linewidth}}
\AtEndDocument{\end{varwidth}\end{preview}}
\begin{document}
\section{One document to display}
How to produce an output without any margin.
\par\noindent
$ E = m c^2 $ but it seems that we can have $ v > c $.
\end{document}
Best Answer
You could use the
preview
package for this. It's basically the "pure (La)TeX variant ofpdfcrop
" you are looking for. You need to set the text height to\maxdimen
e.g. usinggeometry
and wrap every page in\begin{preview}
...\end{preview}
. To do this simply have a\begin{preview}
after\begin{document}
, a\end{preview}
before\end{document}
and define a\newpage
variant as\end{preview}\begin{preview}
. You will loose some of the border which can be readded using the\PreviewBorder
macro. However, AFAIK this doesn't support header and footer.Here now some example code. Apparently
preview
already takes care to suppress automatic page breaks and the modification of the text height is not required.