101

I appreciate that in the past, latex was faster than pdflatex, but computer speeds being what they are nowadays, I can't see any difference in how quickly documents compile...

So, given that the end product I want is the PDF, are there good reasons not to always compile to pdf?

Martin Scharrer
  • 262,582
Seamus
  • 73,242
  • 7
    Closely related question: http://tex.stackexchange.com/questions/349/what-is-the-practical-difference-between-latex-and-pdflatex – provides many good reasons for using pdflatex instead of latex (and one good reason for using latex instead of pdflatex). – Jukka Suomela Sep 06 '10 at 21:25
  • 1
    “given that the end product I want is the PDF…” — one reason for compiling to DVI is when the end product you want is not the PDF. (Example: SVG.) – ShreevatsaR Mar 23 '17 at 23:45

6 Answers6

46

Unless you are a heavy PSTricks user, I think the answer is no, you can always go to pdf directly. Actually, in modern TeX distributions, latex is pdflatex in dvi mode; the underlying engine is the same.

Display Name
  • 46,933
  • latex is pdflatex in dvi mode; the underlying engine is the same - I think I'd say, one program, two engines. – Charles Stewart Sep 06 '10 at 20:20
  • 13
    as a side note: and tikz/pgf which works well with pdflatex and is a kind of substitute for pstricks, thus there is probably no reason to use pstricks today – maxschlepzig Sep 06 '10 at 20:52
  • @Charles Stewart: AFAIK, the only difference between latex and pdflatex formats is the value of \pdfoutput, on *nix both are just symlinks to pdftex, and each will load the appropriate format, so it is the same engine and the same program (whatever the difference is supposed to be). – خالد حسني Sep 06 '10 at 23:59
  • 4
    @Khaled: There are two overlapping, but basically different layout implementations in Pdftex. Pdftex came from the work Hàn Thế Thành did towards his Phd thesis on microptypography, and it isn't a conservative change to Tex's layout: microtypography only works with the PDF layout engine, not the DVI engine. Pdftex keeps track of state associated with Pdf generation, whilst the DVI engine just injects raw Postscript code into PS specials. They're quite different. – Charles Stewart Sep 07 '10 at 08:20
  • @Charles Stewart: AFAIK, no, internally it is basically the same, just different output routine, and microtypographic features of PDFTeX works just fine with the DVI mode. Source specials has nothing to do with the engine, packages that need such stuff (e.g. hyperref), detects whether the engine is running in PDF or DVI modes and inserts pdf literals or source specials, respectively. – خالد حسني Sep 07 '10 at 09:41
  • 2
    @Khaled: I'm less sure of what I've been saying... Some details though: the microtype package says that font expansion, not surprisingly, doesn't work with the DVI engine/pathway. There's stuff to do with page geometry that Pdftex has to keep track of to generate PDFs which, to be conservative over Tex, it should not bother with in DVI mode. – Charles Stewart Sep 07 '10 at 12:41
  • 4
    @Khaled: Be very careful with your conclusion that, since latex and pdflatex are symlinks to the same command, they must be the same. This is simply not true: a program can check how it was invoked (i.e. via which symlink/command name) and act accordingly. Many applications do that, and so does pdftex – clearly at least for the purpose of loading the LaTeX macro packages when invoked via [pdf]latex. (But you could still be right.) – Konrad Rudolph Sep 08 '10 at 08:43
  • What pdftex will do when invoked as foo is looking for foo.fmt and loading it (there is also a command line switch -fmt to explicitly select the format), and the difference between the two format is what output mode is active, it is still pdftex doing all the work with all its features available. – خالد حسني Sep 08 '10 at 09:47
  • @Khaled: no, they are not all available. For example, it should be clear that none of the pdfTeX features that involve adding "objects" to PDF files can be used in DVI mode; any such thing must instead be done using \special in some way that is supported by whatever "driver" the DVI will be passed on to... – SamB Nov 30 '10 at 01:04
  • 2
    xelatex compiles to PDF and can handle PSTricks (and eps,png,jpg,...). – Dean Serenevy Jun 02 '11 at 13:01
28

There is a reason: pdflatex's lack of support for eps figures. If you have a program that only outputs eps graphics and wants to include them in your document, the best alternative is to use latex + dvipdf; if you use pdflatex you have to convert them somehow, and the most practical way is to use epstopdf, whose output is underwhelming.

EDIT: My point is: the pdf outputted by epstopdf is buggy and ugly; so if you can't generate the picture in pdf, your best shot is using latex instead of pdflatex.

  • 3
    Then I'd like to ask the question "Is there any reason to create EPS rather than PDF these days?" :) – topskip Sep 06 '10 at 18:04
  • 1
    matlab, for instance, can't output correct pdf (although it is only a matter of cropping). gri only outputs ps. also, there are journals (like Optics Express) that only accept submissions with its graphics in eps. – Mateus Araújo Sep 06 '10 at 18:24
  • 7
    It's way easier to create EPS from a program than to create PDF. Plus EPS file are editable with a texteditor if your picture is vector graphics and you know what you're doing. – lhf Sep 06 '10 at 18:43
  • 14
    epstopdf seems to make this answer irrelevant? – Seamus Sep 06 '10 at 20:16
  • 22
    Not only that, but starting with TeXlive 2010, epstopdf will be called automatically when you run pdflatex, so for all intents and purposes, pdflatex will support .eps. (XeLaTeX already does.) – frabjous Sep 06 '10 at 20:28
  • Already discussed here in more detail: http://tex.stackexchange.com/questions/2092/which-figure-type-to-use-pdf-or-eps – Jukka Suomela Sep 06 '10 at 21:27
  • 2
    I've never had epstopdf produce bad pictures. Do you have an example of an eps where it fails? – TH. Sep 07 '10 at 00:58
  • 3
    Matlab can create cropped PDF output (need to set paperposition, I think), but the other reason EPS is still desirable is for psfrag output. No way to get (good) LaTeX labels in Matlab/Mathematica without (resp.) matlabfrag and mathpsfrag. – Will Robertson Sep 07 '10 at 01:10
  • Several, unfortunately. The following matlab code produces such an eps: [x,y] = meshgrid(-3:1/8:3); z = peaks(x,y); surfl(x,y,z); shading interp; – Mateus Araújo Sep 07 '10 at 02:10
  • In this example dvipdf also fails to convert the picture; but I have some examples where this is not the case at my lab, if you're interested. – Mateus Araújo Sep 07 '10 at 02:18
  • 5
    Taco is writing a PostScript interpreter in Lua (http://escrito.luatex.org/), so I think it is going to eliminate the stated two reasons (PStricks and EPS) for luatex based formats). – خالد حسني Sep 07 '10 at 09:43
  • 14
    it's not just that pdflatex doesn't have support for eps figures. once inside a pdf file, it may not be possible to determine what's a figure and what's text. so a check for, say, line thickness (very thin lines disappear in printing) is no longer possible. but that's easy with dvi+eps. – barbara beeton Sep 07 '10 at 16:29
16

Some of the journals I use require figures to be submitted separately in eps or tiff format, so that they can deal with not just the latex work, but also the archiving of the figures in higher resolution for the journal website. I don't know why they prefer eps and tiff to pdf, but they do, and they are "the boss".

dank
  • 2,189
  • 12
    Some humanities journals don't even accept submissions in LaTeX, so consider yourself lucky that the journals you use are savvy enough to even think of specifying what image formats to use... – Seamus Sep 08 '10 at 12:34
15

There is another reason: PDF files produced with latex and dvipdfmx are much smaller than those produced with pdftex. The reason is that dvipdfmx embeds fonts as CFF (Compact Font Format). For short texts the difference is big. You can achive the same (and more, such as image compression) by using pdfsizeopt. I always use dvipdfmx instead of pdflatex. A short text that has 73 KB with pdflatex has only 9 KB with latex and dvipdfmx.

user14744
  • 161
9

One reason I can think of: xdvi is supposed to support reverse search (a.k.a. inverse search). I.e. you click in xdvi on some text and directly jump to the corresponding location in the text-editor.

I never tried it, but it sounds neat.

It seems that some xdvi clones support that feature for dvi files, too.

I guess that current PDF viewer/pdflatex combinations does not support reverse search ...

maxschlepzig
  • 12,082
  • 1
    See the question http://tex.stackexchange.com/questions/2006/output-viewers-for-use-with-latex . SumatraPDF is said to support it. – Roman Plášil Sep 07 '10 at 20:03
  • 6
    TeXWorks, Evince and Okular also support reverse search, if you are using a sufficiently recent engine with synctex support (all the popular three engine have synctex support for a while now). – خالد حسني Sep 08 '10 at 02:08
  • @Khaled: Cool, do you have some nice link in your back pocket that show how to use synctex and reverse search? – Johan Sep 08 '10 at 05:31
  • 3
    @Johan: You need to activate synctex for your document by either passing --synctex=1 at command line or the primitive \synctex=1 in your document, how to reverse search now depends on your viewer/editor (in TeXWorks you press ctrl while clicking the target either in source or pdf). – خالد حسني Sep 08 '10 at 09:54
  • 1
    I must try that :) – Johan Sep 08 '10 at 15:17
3

You can render DVI really fast.

My custom, plain TeX, DVI renderer (which is essentially a combination of dvipng for rendering and KerTex for compiling .tex files) runs at ~60 fps for single-page documents (1920x1080), and the DVI renderer alone runs at ~120 fps (1920x1080) and ~250 fps (960x1080) for more pages. And that's that pure CPU rendering, single-threaded.

So not only is there a huge advantage in pure DVI; there's also a huge advantage is plain TeX. (Eventually you'll probably want to extend it, but it should be done without the massive LaTeX bloat. You can get a working TeX distribution for ~6 MB. Here's some of the stuff you can do with such a distribution. I haven't figured out a nice way of inserting images, though.)

A major disadvantage of DVI is that, as far as I know, it doesn't support embedding the fonts in the file itself. (You should be able to embed them yourself, but, if DVI doesn't allow that, then that'd be a custom extension.)