[Tex/LaTex] How to check paper size

paper-sizepdftex

Is there a way to check what paper size my LaTeX document is set to?

I'm aware I can set the paper size using the geometry package, but I want some type of 'check' on this. I don't see anything obvious in the log file.

When I manually check the meta data of the PDF, it gives me the "Resolution" in some type of point system. I can do a bit of math with 72 on it, but I'd rather find some type of "LaTeX-only" way of getting the paper size.

For what it's worth, I am not actually using the geometry package in my document. I am not against using it, though, so long as it does not alter the dimensions of my document (which others have reported, even with pass).

Best Answer

How fancy (and accurate) do you need? If you're not using geometry, you could do something like this:

\documentclass[a4paper]{article}
%\documentclass{article}
% if you don't load a package like geometry or hyperref (who doesn't use hyperref?), then you could add these two lines
\pdfpagewidth=\paperwidth
\pdfpageheight=\paperheight


\makeatletter
\newcommand\usemm[1]{%
  \strip@pt\dimexpr0.3514598\dimexpr #1\relax\relax mm%
}
\newcommand\usein[1]{%
  \strip@pt\dimexpr0.013837\dimexpr #1\relax\relax in%
}
\makeatother

\begin{document}
\the\paperheight \par
\the\paperwidth  \par
\the\hsize       \par % or \textwidth
\the\vsize       \par % or \textheight

\usemm{\the\paperheight} \par
\usemm{\the\paperwidth}  \par
\usemm{\the\hsize}       \par
\usemm{\the\vsize}       \par

\usein{\the\paperheight} \par
\usein{\the\paperwidth}  \par
\usein{\the\hsize}       \par
\usein{\the\vsize}       \par
\end{document}

Note that there is also this very useful test (for which I always forget the name):

latex testpage # or: pdflatex testpage

which will prompt you about whether you mean to test for a4paper or letterpaper and whether you want one- or two-sided printing. After the compiling is finished, open the resulting .dvi or .pdf and see if the hash marks line up to the edge of the page properly. If they do not then you'll need to care about using A4 paper settings or letterpaper documentclass settings in various document classes (unless you load a package that fixes LaTeX's defaul deficiency).