# What is the difference between \paperheight, \paperwidth and \pdfpageheight, \pdfpagewidth?

I couldn't find any existing answers to this question.

So, what's the difference? Are there any advantages to using one duo over the other?

• Please tell us which TeX engine you use: pdfTeX, XeTeX, or LuaTeX? – Mico Apr 9 '18 at 17:23
• do you mean \pdfpaperheight or \pdfpageheight ? (the first one is not defined as far as I know) – David Carlisle Apr 9 '18 at 17:23
• @DavidCarlisle yes..that's what i meant to type. sorry about that. edited. – Zac Apr 9 '18 at 17:26
• @Mico sorry for the late response - i had no idea so i had to check. it's PdfLaTeX. – Zac Apr 9 '18 at 17:39
• I deleted the macros tag as none of these commands are macros. – David Carlisle Apr 9 '18 at 18:16

\pdfpageheight was introduced by pdftex (and it prefixes most of its "new" commands with \pdf) It sets the vertical size of the mediabox in the resulting PDF. xetex also supports this primitive and passes the information to the xdvipdfmx dvi driver. luatex has a command with identical functionality but it is called \pageheight

LaTeX has a command \paperheight that is usually set with documentclass options such as a4paper it is used mainly for adjusting the size of the text block, eg \textheight is \paperheight minus some space for too and bottom margin. If packages that "know" about driver-specific code (graphics, hyperref, geometry) are loaded then by default \(pdf)pageheight will be set based on the value of \paperheight by the package code.

So, setting \paperheight in the preamble will normally have no efffect at all, as the value has already been used to set \textheight and changing it has no effect. The exception, as noted above is if a package uses the value of \paperheight in the preamble to set \(pdf)pageheight at \begin{document}. Conversely setting \(pdf)pageheight has an immediate effect of changing the dimensions of the generated PDF, although again if a package re-sets the value at \begin{document} then the value you set directly may not be used.

Yes, there's a big difference between \paperheight and \paperwidth on the one hand and \pdfpageheight and \pdfpagewidth on the other. The differences are engine-specific:

• With pdfLaTeX, all four macros are defined, but whether or not \paperheight and \pdfpageheight (and \paperwidth and \pdfpagewidth) coincide depends on your system settings. E.g., my MacOS-based computer is currently configured to treat A4 as the "standard" paper size. But if I run

\documentclass[letterpaper]{article}
\begin{document}
\obeylines
\the\paperheight
\the\pdfpageheight
\the\paperwidth
\the\pdfpagewidth
\end{document}


through pdfLaTeX, I get 11" and 8.5" for \paperheight and \paperwidth, but I get different numbers -- 297mm and 210mm, or 11.69" and 8.27", which correspond to A4 dimensions -- for paperheight and \pdfpageheight, respectively.

• Under XeLaTeX, the macros \pdfpagewidth and \pdfpageheight both exist, but they are both set to 0pt by default.

The values of \paperheight and \paperwidth both depend on whether a4paper or letterpaper is provided as a documentclass-level option.

• Under LuaLaTeX, \pdfpagewidth and \pdfpageheight are both undefined by default. The values of \pagewidth and \pageheight will either coincide or differ from \paperwidth and \paperheight depending on whether your system settings conincide with the paper-size option (a4paper or letterpaper) you specify at the document class level.

The values of \paperheight and \paperwidth both depend on whether a4paper or letterpaper is provided as a documentclass-level option.

• the definition of \paperheight is in latex (and set by the class) so is the same in all engines (and in particular not undefined in lualatex) – David Carlisle Apr 9 '18 at 17:43
• Arrgh! A bad copy-and-paste mistake; thanks for noticing it! I've changed \paperheight to \pdfpagewidth under the 2nd and 3rd bullet points. – Mico Apr 9 '18 at 17:45