3

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).

  • I always get this from pdfinfo or the document properties in my PDF viewer. The latter gives me mm and, if available, the equivalent standard size e.g. A4 or whatever. – cfr Aug 13 '15 at 21:21
4

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).

  • This won't necessarily match the height and width of the PDF produced, though. – cfr Aug 13 '15 at 22:13
  • @cfr -- Hmm, indeed. I'm not used to thinking about page size in a "minimal" document. Perhaps this edit helps, however. – jon Aug 14 '15 at 0:16
  • Hmm... That's very interesting - never heard of that test. But I'm not quite clear about it. Is there a testpage somewhere in the distribution? Or is that the name of your document? But does this really do anything over-and-above telling you to be careful if you live anywhere other than North America? – cfr Aug 14 '15 at 1:02
  • Well, of course, it wasn't the command latex that I couldn't remember, but the actual file testpage.tex (findable in the normal ways when you know the name of the file). Ad 2: yes: if you've used tlmgr to set your default paper size to A4, then you'd have the opposite problem. Anyway, it is (I think) a useful diagnostic if something seems off and you are unaware of the default bug/feature about the native page dimensions. – jon Aug 14 '15 at 1:09
  • @cfr -- Oops, last comment missed you. (Also, this question explains an early, forgotten episode where I was "burned" when preparing a handout for a European conference -- in which I didn't use either geometry or hyperref. Although I thoughtfully added the a4paper option to the document class, when I printed the handout, it was off. I had no time and less experience then to figure out what was wrong, but I think I understand now!) – jon Aug 14 '15 at 1:44
0

Try the layouts package which will list all the page layout details including the page height and width. For instance:

\documentclass[...]{...}
\usepackage{layouts}
...
\begin{figure}
\centering
\currentpage
\oddpagelayouttrue
\pagedesign
\caption{Odd page layout for this document}
\end{figure}
...

will produce a scale diagram of the various aspects of the current page layout together with a list of all the various values (to the nearest pt).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.