next up previous
Next: Avoiding extras space after Up: Creating various file formats Previous: Creating various file formats


Creating good PDF files from Latex

Creating a pdf file from Latex source can be trickier than it ought to be. (Note that this writeup is somewhat old, so while I think much of the guidance here is reasonable, some of it may be out of date - CP - 4/2/06) You have to make certain that both the text and the mathematical symbols show up clearly on screen and that they work on Windows machines and print out from Windows machines. If you're converting from ps to pdf the key issue is getting the fonts right. Here are some options for going from Latex to pdf:

  1. For slides and presentations, recently I've been using Lyx with the foils package and compiling using pdflatex and have found that the slides come out nicely. Here's an example Lyx file for doing this.
  2. Convert directly from Latex to pdf using pdflatex. For presentations, pdflatex does a better job with the thickness of the mathematical symbols than the route below in going through the dvi and ps file to get to pdf.

    1. The main issue is in incorporating figures. pdflatex can't incorporate ps files or use pstricks. Instead, if your figures are from R, create the pdf files directly in R or convert your figures: convert any ps figures to pdf or jpg; to get the figure size right, you may need to crop the figure:

      1. for a jpg figure you can do this with xv
      2. for a pdf figure, convert the ps file to eps >ps2epsi file.ps, so that it has a bounding box and then do >epstopdf file.epsi
    2. include \usepackage[pdftex]{graphics} in the Latex preamble
      also, I think that also using \usepackage{times} gives more clear text for presentations because it seems to be bolder than is otherwise the case
    3. include the figure using \includegraphics{file.pdf} or \includegraphics{file.jpg}
    4. compile the Latex directly into pdf without sojourning in dvi- or ps-land: >pdflatex file.tex
  3. For papers, the following should deal with the text and font issues, and seems to give good representation of the mathematical fonts. However, for presentations, I have found that creating a pdf file in this way may not give mathematical symbols that project well because the lines in the letters are far too thin. In the past, I have solved this to some extent by making all the mathematical symbols bold.

    1. in the Latex preamble, include the line \usepackage{times} (I'm not completely sure this is necessary.)
    2. >latex file.tex
    3. >dvips -Ppdf -G0 file.dvi
    4. Either

      1. >ps2pdf file.ps file.pdf
      2. >convert file.ps file.pdf (you might try convert -enhance)
    5. Now check that only Type-1 fonts are included in the pdf file. To do this open the pdf file using Acrobat (this may only work on Windows). Click on file -> Document Properties -> Fonts and make sure there are only Type-1 fonts. If there are other fonts (like Type-3), they might come from graphics files imported into the document. I don't understand the technicalities, but pdf files with only Type-1 fonts seem to display on-screen and print much better.
  4. A colleague of mine suggests the following recipe, but I've found that the pslatex package seems to cause the greek letters in the output to stand out in a funny way.

    1. include \usepackage{pslatex} in the preamble of the document
    2. compile your Latex file as usual, latex file.tex
    3. dvips -Ppdf -G0 -o file.ps file.dvi
    4. ps2pdf -dCompatabilityLevel=1.3 file.ps
  5. If you're not satisfied with either solution above, you can delve more deeply in the gory details of the fonts. On the CMU stat system (and presumably others), this issue with the fonts seems to be largely solved using approach #1 above.


next up previous
Next: Avoiding extras space after Up: Creating various file formats Previous: Creating various file formats
Chris Paciorek 2012-01-21