3

On my Mac running TeXlive 2012 when I do

pdflatex testpage
\papertype=a4paper
\doublesided=n

and open the resulting PDF file in preview, I can see that the margins are completely wrong in the produced PDF.

margins are wrong

If I leave out the a4paper and do

pdflatex testpage
\papertype=
\doublesided=n

I get a PDF with the expected layout, as shown here:

correct margins

What am I doing wrong here and how can I make pdflatex perform correctly while using the correct paper size? I have also done the same test with xelatex, with exactly the same results.

4

This is normal behavior of the "testpage.tex" package. To quote from its documentation (Section 5.1):

By far the most common cause of incorrect margins and/or incorrect indicated paper sizes is that pdfTEX and/or dvips and/or ghostscript (ps2pdf) have been configured for a default paper size that is different from that used in the LaTeX document.

Thus, the "testpage.tex" package relies on the default paper size being the same as the one that you specified. If you have a look at the PDF files that you produced, you will see that your PDF reader will tell you that they actually both are in letter format. That is because when using PDF output, "testpage.tex" will not adapt the page size for you.

Note that this is not a problem. When you actually use PdfLaTeX to write your own documents, you can still use the option "a4paper" for most document classes or whenever that does not work, use a package such as "geometry" to change the page size manually.

4

My TeX Live is configured for A4 paper and the test is good with a4paper, while it fails with letterpaper.

So the conclusion is that your TeX distribution is configured for US Letter paper. However you're not necessarily forced to use this paper format with pdflatex.

You can easily make a pdflatex version of testpage.tex by adding the proper choice of paper size.

Make a copy of testpage.tex (changing its name) and modify it so that it reads

\documentclass[\papertype]{article}

\usepackage{ifthen,ifpdf}

\ifpdf
  \pdfpagewidth=\paperwidth
  \pdfpageheight=\paperheight
\fi

\pagestyle{empty}

Your test should now work with both paper sizes.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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