3

Trying to make my own bookmarks, I began with using geometry to get the right dimensions (for some reason this is 20cm x 5.5cm). Using the first two answers to another question, I wrote the following:

\documentclass{article}
\usepackage[margin=0cm,paperheight=20cm,paperwidth=5.5cm]{geometry}
%\usepackage[pass,paperwidth=5.5cm,paperheight=20cm]{geometry}
\begin{document}
\noindent hello world
\end{document}

(Switching between the two geometry lines to test both.) Strangely, this gives a pdf file that is 22cm by 6cm. Compiling to png using the following script (in TeXworks this time, as I don't know how to do it with TeXstudio), it even becomes 2476px x 331px (which would be 41 by 5.5cm).

/C
texify.exe
--tex-option=$synctexoption
$fullname
&
dvipng.exe
-D 300x
$basename.dvi

Why do the dimensions of the output file of the first method differ from the second, and why is neither of them the right size? As this clearly isn't, what would be the right way to define the paper size?

3

The test file test.tex for the examples below is the file from the question:

\documentclass{article}
\usepackage[margin=0cm,paperheight=20cm,paperwidth=5.5cm]{geometry}
\begin{document}
\noindent hello world
\end{document}

The following options of dvipng work for me:

dvipng -D300 -O 1in,1in -T 5.5cm,20cm test

Result: test1.png

identify test1.png
test1.png PNG 649x2362 649x2362+0+0 8-bit PseudoClass 16c 4.66KB 0.000u 0:00.000

Width: 649/300 * 2.54 cm ≈ 5.4949 cm ≈ 5.5 cm
Height: 2362/300 * 2.54 cm ≈ 19.9983 cm ≈ 20 cm

Remarks:

  • The order matters, -D300 has to come first.

  • The papersize special in the .dvi file, set by geometry for dvips, is ignored (special.c):

    if (strncmp(special,"papersize=",10)==0) { /* papersize spec, ignored */
      return;
    }
  • The version of dvipng:
    dvipng --version

    This is dvipng 1.14 Copyright 2002-2010 Jan-Ake Larsson
    dvipng 1.14
    kpathsea version 6.1.1
    Compiled with Freetype 2.4.11
    Using libft 2.4.11
    Using t1lib 5.1.2
    ...

PDF generation

Easy with pdfTeX:

pdflatex test

And the following command reports the page size:

pdfinfo test.pdf
...
Page size:      155.905 x 566.929 pts
...

The pts are points in the PDF/PostScript world, the same as TeX's unit bp.

Width = 155.905 bp / (72 bp/1 in) * (2.54 cm/1 in) ≈ 5.5016 cm ≈ 5.5 cm
Height = 566.929 bp / (72 bp/1 in) * (2.54 cm/1 in) ≈ 19.9993 cm ≈ 20 cm

  • When using the options for dvipng you gave, I get 2329*704, which is close. This might have to do with the if statement you talk about, which I don't know where to paste. One slight problem is that it only solves the png dimensions (unless such a thing can be done in compiling to pdf as well). – Betohaku Apr 18 '14 at 17:51
  • @Betohaku: I have added the version of dvipng. Using the test file from the question you should get the same result. Also I have added an example for the generation of PDF. – Heiko Oberdiek Apr 18 '14 at 18:25
  • Now I see why I thought it went wrong with pdflatex: Acrobat's "100% zoom" actually is 110%, which gave me the 22cm*6cm. It is indeed 7.87*2.17in. Only thing to do seems to be updating dvipng. – Betohaku Apr 18 '14 at 19:00

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.