8

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
  • @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
12

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

|improve this answer|||||
6

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. However, 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} % letterpaper: 8.5" wide, 11.0" tall
    \begin{document}
    \obeylines
    \the\paperheight
    \the\pdfpageheight 
    \the\paperwidth
    \the\pdfpagewidth
    \end{document}
    

    through pdfLaTeX, I get 794.96999pt and 614.295pt -- the equivalent of 11" and 8.5" -- for \paperheight and \paperwidth. However, I get 845.04684pt and 597.50787pt -- the equivalent of 297mm and 210mm, or 11.69" and 8.27" -- for \pdfpageheight and \pdfpagewidth, respectively. (Aside: 297mm and 210mm are the correct values for A4 paper.) Put differently, selecting the document class option letterpaper managed to change the values of \paperheight and \paperwidth, but not those of \pdfpageheight and \pdfpagewidth.

  • 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, by default, both undefined. The values of \pagewidth and \pageheight will either coincide or differ from \paperwidth and \paperheight depending on whether your system settings coincide 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.

|improve this answer|||||
1

Do you want to read or to write those dimensions?

In PdfLatex and XeLatex changing \pdfpageheight and \pdfpagewidth will actually change the document page size beginning with the current page. In LuaLatex you have to use \pageheight and \pagewidth i.e. without pdf.

\paperheight and \paperwidth seem to be copies or preliminary variables for the real ones. Which package/option/macro reads or sets which during what is better explained in the other answers.—Having two pairs might make sense if you want margins etc. to be calculated having different paper dimensions in mind than the actual output area. Maybe.

By the way, only the PDF path allows mid-document changes. DVI and Postscript do not support this.

|improve this answer|||||

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.