# Why are there two seemingly redundant page dimension specifications: paperwidth pdfpagewidth (and height)?

We have

\paperwidth
\pdfpagewidth


then

\paperheight
\pdfpageheight


My understanding is that they both refer to the physical page dimensions. Please correct my understanding and/or provide necessary background information.

• Could someone tell me why this distinguishment is made?
• Why does TikZ use one over the other?
• Does it have to do with xdvipdfmx?
• Does it make a difference which compiler is used?

# Related

• The link you posted does seem to contain at least some answers, especially the compiler related ones. And also one reason why this difference was introduced. Could you please clarify which of the questions are not answered or what is really unclear? – TeXnician Jan 11 '18 at 16:34
• I have summarized it in an answer. – TeXnician Jan 11 '18 at 16:54

The variables \paperheight and \paperwidth are the size of the page that LaTeX is 'working with': the area it expects to have available to fill. In contrast, \pdfpageheight and \pdfpagewidth are the size of the PDF being produce (the 'physical' size of the stock). As such, both need to be in accord to have a well laid-out PDF.

As noted in \pageheight just inside layout package?, \paperheight/\paperwidth predate the \pdf... primitives by some time. The latter were originally introduced for direct PDF production only, and did not have a relevance to DVI-based routes. Today, DVI drivers (and XeTeX) support \pdfpageheight/\pdfpagewidth and so one could use a single pair. However, changing the names/behaviours in LaTeX2e is not possible at this stage. (See for example the fact that without the a4paper option, a standard \documentclass{article} LaTeX document uses a layout appropriate for letter paper, even if the PDF produced is A4.)

• Is it reasonable, then, to write a macro to switch page dimensions, for example, \global\def\setwidth#1{\paperwidth=#1\pdfpagewidth=\paperwidth} and \global\def\setheight#1{\paperheight=#1\pdfpageheight=\paperheight}? – Jonathan Komar Jan 12 '18 at 10:15

So just to summarize what is written in the other post: \paperwidth and \paperheight were introduced by LaTeX (the old latex/dvips days). These options were kind of unimportant as there was still the DVI driver to configure the page size.

With pdftex one had to setup page dimensions as required by the PDF format and the values were taken into the LaTeX format (as \pdfpageheight and width). For a real change in dimensions you may adjust \pdfpageheight (or width) later on; adjusting \paperheight is insufficient. So the pdf thing was introduced to really change the output.

And therefore this has nothing to do with xdvipdfmx, but XeTeX for instance understands the pdf commands for compatibility. And yes, as you could read above, there is a difference between the compilers.

The only question not answered in the other thread is the TikZ question. But why TikZ chooses one value over the other should be the question of compatibility to other engines. Especially those which do not respect the pdf commands.