1

If I compile my document (see below for MWE) with XeLaTeX I get a pagesize of 595.28 x 841.89 pts. If I compile the same document using LuaLaTeX or pdfLaTex I get a page size of 595.276 x 841.89 pts.

It makes no difference if I set a4paper in \documentclass[a4paper]{article} or \usepackage[a4paper]{geometry}.

This actually is causing a test case to fail, but in all honesty it probably has no practical meaning (or?).

Can the page size be made the same for all compilers, or can the test case be changed so that it passes for these two cases?

Minimal Working Example

\documentclass{article}
\usepackage[a4paper]{geometry}

\begin{document}

Lorem ipsum.

\end{document}

Logs

lualatex mwe.tex > /dev/null && pdfinfo -box -f 1 -l 1 mwe.pdf | grep Page
Pages:          1
Page    1 size: 595.276 x 841.89 pts (A4)
Page    1 rot:  0
Page    1 MediaBox:     0.00     0.00   595.28   841.89
Page    1 CropBox:      0.00     0.00   595.28   841.89
Page    1 BleedBox:     0.00     0.00   595.28   841.89
Page    1 TrimBox:      0.00     0.00   595.28   841.89
Page    1 ArtBox:       0.00     0.00   595.28   841.89

xelatex mwe.tex > /dev/null && pdfinfo -box -f 1 -l 1 mwe.pdf | grep Page
Pages:          1
Page    1 size: 595.28 x 841.89 pts (A4)
Page    1 rot:  0
Page    1 MediaBox:     0.00     0.00   595.28   841.89
Page    1 CropBox:      0.00     0.00   595.28   841.89
Page    1 BleedBox:     0.00     0.00   595.28   841.89
Page    1 TrimBox:      0.00     0.00   595.28   841.89
Page    1 ArtBox:       0.00     0.00   595.28   841.89

pdflatex mwe.tex > /dev/null && pdfinfo -box -f 1 -l 1 mwe.pdf | grep Page
Pages:          1
Page    1 size: 595.276 x 841.89 pts (A4)
Page    1 rot:  0
Page    1 MediaBox:     0.00     0.00   595.28   841.89
Page    1 CropBox:      0.00     0.00   595.28   841.89
Page    1 BleedBox:     0.00     0.00   595.28   841.89
Page    1 TrimBox:      0.00     0.00   595.28   841.89
Page    1 ArtBox:       0.00     0.00   595.28   841.89

Test case

require 'pdf/reader'

describe 'xelatex-lualatex' do
  reader = PDF::Reader.new('mwe.pdf')

  it 'Should be A4 sized' do
    expect(reader.pages[0].attributes[:MediaBox]).to eq([0, 0, 595.28, 841.89])
  end

end

Run using rspec mwe.rb.

  • 2
    \paperwidth is 597.50787pt so ‭595.27558655043586550435865504359‬ postscript points, xdvipdfmx (for xetex) or lualatex and pdftex round it slightly differently but that's not unexpected surely – David Carlisle Feb 18 at 19:02
  • @DavidCarlisle the main difference seems to be that lualatex has three digits and xelatex only two in the media box. I do have a faint memory that I saw this somewhere already. – Ulrike Fischer Feb 18 at 19:09
  • @UlrikeFischer yes years of mathematical training, I can count to 3 :-) – David Carlisle Feb 18 at 19:09
  • @DavidCarlisle ;-). I meant I think that there is a setting to set the number of digits. – Ulrike Fischer Feb 18 at 19:10
  • 2
    The problem with normalizing this is that all engines allow to modify their rounding, but that isn't always effective. E.g. The XeTeX option does not apply to the mediabox which is hardcoded to two digits after the comma, while LuaTeX also has a setting which must specify at least three digits after the comma... – Marcel Krüger Feb 18 at 19:11

Your Answer

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

Browse other questions tagged or ask your own question.