Kuro5hin.org: technology and culture, from the trenches
create account | help/FAQ | contact | links | search | IRC | site news
[ Everything | Diaries | Technology | Science | Culture | Politics | Media | News | Internet | Op-Ed | Fiction | Meta | MLP ]
We need your support: buy an ad | premium membership

[P]
Why PDF doesn't suck: Guide for LaTeX users

By The Writer in Technology
Wed Jun 05, 2002 at 03:06:42 PM EST
Tags: Software (all tags)
Software

I thought I knew all there was to know about making PDF's from LaTeX documents. And from the little I do know, I incorrectly concluded that PDF's suck.

Well, here's a little eye-opener for you LaTeX fans out there. Some day, you might want to show off LaTeX's superior formatting to people who only know how to view PDF's. And you'll want to know this so that you don't make a fool of yourself (and give them a bad impression of LaTeX).


My First (Mistaken) Impression: PDF sucks

I have always been a LaTeX fan ever since I read Leslie Lamport's excellent LaTeX2e book. Emphasizing logical structure rather than visual formatting, it gives great power to the learned user. Its professional quality output is praised by scientific and academic journals all over the world. Well, LaTeX and the underlying TeX engine was developed in the days when PostScript was prevalent. Although its standard output format was DVI, LaTeX documents mostly come as PostScript because that is the most widely-accepted portable printer-friendly format then.

And then, along came PDF, the funky new format published by Adobe. My initial experiences with PDF were less than pleasant. Being a LaTeX fan, I tried my hand at creating some PDF's of my LaTeX documents. And guess what -- most of it doesn't show up properly in earlier versions of Acrobat Reader, sometimes it even crashes Acrobat Reader -- and when it does show up correctly (in later versions of Acrobat Reader), the font looks smudged, blurred, pixelated, and just plain unreadable. Furthermore, when I view the original PostScript on GSView, it looks just great.

So, my initial reaction was, oh well, PDF can't handle LaTeX's superior formatting. It sucks!

And so I thought, until one day, I read this page.

The Problem

The problem with converting LaTeX-produced PS into PDF, is that the usual program used to perform the initial conversion to PostScript, dvips, simply calls METAFONT (LaTeX's font engine) to rasterize your document's fonts at 300dpi, and then loads the bitmapped results into the PS file. This is known as a Type 3 font, which will also get propagated into the PDF once you convert the PostScript.

The problem with Type 3 fonts is that Acrobat Reader does not handle it in a sane way. Unlike other utilities (like GSView, which apparently does a good job at scaling bitmapped fonts), Acrobat Reader was not designed to handle Type 3 fonts well, and it does a minimal, unreadable job at scaling these 300dpi bitmapped fonts (and does so at turtle-crawling speeds, too).

This may seem like PDF's fault, but it really isn't. The real problem comes from dvips embedding type 3 fonts in the PostScript. Type 3 fonts aren't particularly great either -- although 300dpi is good for printing on low-end printers, high-end printers with 600dpi resolution won't show any difference with these fonts, because the bitmaps are 300dpi. Type 1 fonts, however, are infinitely scalable fonts; and there are type 1 fonts that you can use with LaTeX!

The Solution

To create from a LaTeX document a PDF that doesn't suck, what you need is to force dvips to embed Type 1 fonts in the PostScript, and not use any type 3 fonts at all.

In order to do this, you need to make sure that you have installed the Type 1 versions of all the fonts that you used in your document. Usually, if you don't mind using Times or one of the other common fonts, all it takes is to do something like \usepackage{times} which will cause LaTeX to typeset your document in the Times font. Since there is only a Type 1 version of Times, dvips will always produce Type 1 fonts in the PostScript.

But, if you're like me, and you just must use the default Computer Modern font, you'll need to install the Type 1 version of the CM font. After you install these fonts, you'll need to configure dvips to not use Type 3 fonts. Here are the instructions for doing this. You may also want to consult the documentation for your particular LaTeX distribution -- it may have a slightly different mechanism for adding new Type 1 fonts. Now, run dvips again to produce a PostScript, convert it to PDF using Distiller or any of the other PDF writing tools, and check it out on Acrobat Reader. It should look great now.

But... if you're like me (again), you've used some of the more esoteric features of LaTeX, such as diacritics, dotless i's and j's, etc.. If your document uses these symbols, you may find that your PDF still looks butt-ugly. That's because these diacritics are from the EC (European Common) font, and the Type 1 CM fonts don't include these characters. What you need at this point, is to google for "cm-super" (or search for it on CTAN). cm-super is a Type 1 font that includes all the EC characters missing from the default type 1 CM fonts. Install this font, and configure dvips accordingly.

Troubleshooting

If for some reason your PDF refuses to show up with clear, readable fonts, go to the Info menu in Acrobat Reader, and look up exactly what fonts are being used by your PDF file. You may find that there are still some Type 3 fonts in there. If you're lucky, it may display the name of the font, in which case you should search for the Type 1 versions of the font and install it.

But sometimes, Acrobat Reader just uses a non-descript single- or double-letter designation for the font, which is no help in identifying what it is.

One way to find out what font it is, if your distribution of LaTeX supports it, is to run dvips -Ppdf. This will force dvips to not use any Type 3 fonts; if there are any missing Type 1 fonts, it will try to invoke METAFONT (mf on the command-line) with a very high magnification factor. Most likely, METAFONT will get confused, and will just print an error message and do nothing. Examine the line that calls mf, and you should see the name of the font -- e.g., ecbx71, etc.. Once you identified the mystery fonts, google for them, and install the appropriate Type 1 fonts.

Epilogue

Armed with this array of Type 1 fonts, you should now be able to produce PostScript that only contains type 1 fonts. Distiller, or any of the other PDF-writing software, should now be able to create a PDF of your original document that looks decent, and is actually readable on-screen using Acrobat Reader.

Now you can show off LaTeX's beautiful output to those PDF-only people!

Sponsors

Voxel dot net
o Managed Hosting
o VoxCAST Content Delivery
o Raw Infrastructure

Login

Poll
Best output file format for LaTeX documents:
o PS (long live PostScript!) 30%
o DVI 14%
o PDF 38%
o plain text 7%
o plain TeX... 4%
o MS Word document 5%

Votes: 70
Results | Other Polls

Related Links
o Google
o this page
o Type 1 version of the CM font.
o instructio ns for doing this
o google
o CTAN
o Also by The Writer


Display: Sort:
Why PDF doesn't suck: Guide for LaTeX users | 114 comments (92 topical, 22 editorial, 0 hidden)
Ah ha! (3.00 / 6) (#12)
by ka9dgx on Wed Jun 05, 2002 at 12:01:33 PM EST

I always wondered why online scientific articles looked like shit, now I know. Thanks for solving a puzzle for me.

Next question, what can I do about it if I have the PDF file in hand, and want to be able to read it without losing my vision?

--Mike--

Does it work with Truetype fonts? (n/t) (3.75 / 4) (#17)
by gordonjcp on Wed Jun 05, 2002 at 12:35:48 PM EST


Give a man a fish, and he'll eat for a day. Teach a man to fish, and he'll bore you rigid with fishing stories for the rest of your life.


dvipdfm (4.75 / 12) (#18)
by dj51d on Wed Jun 05, 2002 at 12:44:22 PM EST

Why convert from postscript to pdf? Using dvipdfm you can convert directly from dvi to pdf, and it uses type 1 fonts by default. I've never had a problem with the quality of output from dvipdfm.

Or use pdfLaTeX instead and be done. [n/t] (4.40 / 5) (#19)
by hesk on Wed Jun 05, 2002 at 12:45:54 PM EST



Don't care. PDF still sucks. (3.75 / 8) (#32)
by NFW on Wed Jun 05, 2002 at 02:30:03 PM EST

Sucks mightily, and gracefully importing documents created with LaTeX won't change that one bit.

If something is intended for print alone, you gotta do what you gotta do. I guess PDF, LaTeX, DVI, PostScript, etc, are not bad tools, but they sure do get abused. What really sucks is viewing stuff on a screen that was packaged for a printer.

Note to companies whose web sites consist largely of PDFed sales brochures: that's crap. If you have competitors, I will make every effort to find and patronize them.

(pause for deep breath)

I feel much better now. Decent article. +1 SP.


--
Got birds?


VTeX (4.00 / 4) (#33)
by theElectron on Wed Jun 05, 2002 at 03:10:11 PM EST

If you don't want to screw around with teTex or the like, you might try VTeX. It's a commercial product that is free for Linux/x86 (pretty nice of them, huh?). Its primary output is PDF files (no .dvi .ps etc.) and they always looks great.

--
Join the NRA!
pdf sucks anyway you put it! (1.83 / 6) (#37)
by dinu on Wed Jun 05, 2002 at 03:37:16 PM EST

What is wrong with ASCII? :)

PCL (2.00 / 1) (#38)
by awgsilyari on Wed Jun 05, 2002 at 03:38:29 PM EST

What about PCL?

--------
Please direct SPAM to john@neuralnw.com
TrollTech's QT and PS (3.00 / 1) (#44)
by tzanger on Wed Jun 05, 2002 at 04:00:19 PM EST

I was getting butt-ugly pdf files out of my KDE apps until I changed src/kernel/qpsprinter.cpp to read #define Q_PRINTER_USE_TYPE42 instead of the default #undef Q_PRINTER_USE_TYPE42 in the QT source tree.

I've never understood why they default to disallowing TrueType fonts in the PS output. It works fine and it looks beautiful onscreen and in print.



XML (2.00 / 8) (#49)
by axxackall on Wed Jun 05, 2002 at 04:42:31 PM EST

XML is the best format - you don't worry about syntax parsers and you translate it to any further format.

The best (at least good enough) semantic vocabulary for XML documents (documents in terms of human readable, human editable and printer printable documents) is the one from Open Office.

Make a translation from LaTeX to Open Office XML and OO users will get very good tools for mocking up - LyX and TeXmacs while LaTeX users will become more opened for communication with the rest of the world.

Make a translation back from OO to LaTeX and OO users will get very good printing/publishing platform, while LaTeX user again will become more opened for communication with the rest of the world.

1995 anybody? (4.25 / 4) (#50)
by arthurpsmith on Wed Jun 05, 2002 at 04:42:45 PM EST

None of this is exactly new... We're one of the largest users of LaTeX anywhere (over 15,000 latex files received and processed every year) and we've been producing PDF's directly from it using Type-1 fonts for at least the last 6 years. Why the teTeX etc. installations haven't switched to using the freely available Type 1's as the default is a mystery to me - it would make a lot of documents look a lot nicer and really take advantage of what TeX can do.

Energy - our most critical problem; the solution may be in space.


Editorial (2.50 / 2) (#59)
by Bnonn on Wed Jun 05, 2002 at 07:31:19 PM EST

I didn't check this article in the queue, but "PDF's" is possessive. It means, "belonging to the PDF". If you're looking for the plural it's "PDFs".

Curious mistake coming from someone called "The Writer"...

Excellent! (5.00 / 1) (#62)
by phliar on Thu Jun 06, 2002 at 12:26:13 AM EST

Some of this I knew -- for instance about Type 3 fonts. Luckily I hated the look of Knuth's beloved CM* fonts, and I figured out how to make TeX use printer-resident Type 1 fonts (this was back in '91 or so, before NFSS -- the "new font selection scheme" which was finally included by default in LaTeX2e).

However, a lot of the special characters and diacriticals didn't show up correctly for me; fortunately this was not a problem for my dissertation since it was computer science and not math. It always bugged me though. Now, armed with the links you put in the article, I can tackle that problem again!

Another thing that pisses me off: many Linux distributions do a piss-poor job of installing TeX and LaTeX. Broken font metric files, printer config files etc. (You mention dvips -Ppdf -- this implies that there must be a config file config.pdf, and these files live in .../texmf/dvips/config/ so you can see what your installation has.)

Also, Y&Y have always had excellent hinted Type 1 fonts. If you really must have some special font and you can pay, they're for you.


Faster, faster, until the thrill of...

Bug-free too (4.83 / 6) (#63)
by phliar on Thu Jun 06, 2002 at 12:34:38 AM EST

Oh, one other thing -- when you're showing off that beautifully typeset document, don't forget to mention that there are no bugs in TeX.

I also find the version numbering scheme Knuth came up with amusing, since it emphasises that you can never have perfection. (Even though TeX is the closest that any program has come -- we're up to version 3.14159, right? And what's Knuth's bug bounty up to?)

(Man, I still can't believe that people accept the crap that programs like MS-Word turn out and think that's good typesetting.)


Faster, faster, until the thrill of...

pdflatex (3.00 / 1) (#67)
by mjl on Thu Jun 06, 2002 at 03:50:49 AM EST

i've been using pdflatex for a while, and it generates nice looking pdf's. does it do much the same things?

pdflatex already uses type-1 Fonts. (4.66 / 3) (#71)
by Ghost Shrew on Thu Jun 06, 2002 at 08:34:24 AM EST

At least, according to this page. That's a link that I found incredibly useful for doing lots of PDF tricks, such as bookmarks and such. I had no trouble finding out how to do the PStricks and such, but PDF information is a little scarce.


Free tabletop RPG!! Grey Lotus

PDF and hyperlinks? Anyone? C'mon, someone? (3.00 / 1) (#74)
by BrodieBruce on Thu Jun 06, 2002 at 10:38:02 AM EST

Hi,

I do some part-time work for a computer science department, and I ended up learning LaTeX about a month ago since that's the defacto standard around here for making ps or pdf. However, there's one problem that I can't seem to find an answer to anywhere. Is it possible to embed hyperlinks (not hyper-references) within a pdf?

I have downloaded pdf documents which contain hyperlinks to other webpages, but I can never get these links to work. Regardless of whether I'm using acrobat reader (windows or unix), ghostview, or xpdf. The viewers all seem to regard the hyperlink as being regular text.

I have heard myths of the possibility of linking to other files from within a pdf. For example, let's say that I have a paragraph on how to spot memory leaks in C++, and then I want to distribute some example code for students to download. Is it possible to have an embedded hyperlink to the relevant code (assuming it's in a separate .cpp file on the server)?

Thanks

no adobe ;) (1.50 / 2) (#76)
by rss on Thu Jun 06, 2002 at 10:55:22 AM EST

support skylarov dump adobe ;)

(LaTeX) Distributions (5.00 / 2) (#95)
by hry on Thu Jun 06, 2002 at 10:44:21 PM EST

To be onest I am surprised about this article. The pdf creation have been more or less settled years ago.
AFAIK AMS have bought type 1 CM (and other) fonts and then made them freely available years ago.
Unfortunately it is true that some distributions had them turned off by default.
The most notorious is tetex as included in redhat up to 7.2. Check:
/usr/share/texmf/dvips/config/udpmap
for "type1_default=...".
Comment/uncomment as appropriate and rerun the script.
One should use the type 1 version everywhere. These fonts are of high quality and most important have the same metric as the original metafont ones. And thanks to AMS (American Mathematical Society) for releasing them.

Why PDF doesn't suck: Guide for LaTeX users | 114 comments (92 topical, 22 editorial, 0 hidden)
Display: Sort:

kuro5hin.org

[XML]
All trademarks and copyrights on this page are owned by their respective companies. The Rest © 2000 - Present Kuro5hin.org Inc.
See our legalese page for copyright policies. Please also read our Privacy Policy.
Kuro5hin.org is powered by Free Software, including Apache, Perl, and Linux, The Scoop Engine that runs this site is freely available, under the terms of the GPL.
Need some help? Email help@kuro5hin.org.
My heart's the long stairs.

Powered by Scoop create account | help/FAQ | mission | links | search | IRC | YOU choose the stories!