Computer Laboratory

The traditional route of generating PDF files from LaTeX output (latex/dvips/ps2pdf) has a problem where ps2pdf adds JPEG artifacts to bitmap images, typically screenshots. This is because the AutoFilterColorImages option of ps2pdf uses JPEG compression if an image has 8 bits per component and doesn't use an indexed colour space. Unfortunately xv and other programs output in this format, meaning ps2pdf assumes they're photos.

This can be ameliorated at the expense of larger filesize by doing:

ps2pdf -dPDFSETTINGS=/prepress
which still has JPEG artifacts, but smaller ones. When doing this it's also helpful to run dvips thus:
dvips -Ppdf -G0 -t a4 -o foo.ps foo.dvi
which will ensure the fonts in the resulting PDF antialias correctly in Acrobat Reader.

Better is to use pdflatex. This has the advantage of also producing a PDF index for navigation of the document in Acrobat Reader.

To do this, insert this code at the top of your .tex file:

\newif\ifpdf
\ifx\pdfoutput\undefined
  \pdffalse % we are not running PDFLaTeX
\else
  \pdfoutput=1 % we are running PDFLaTeX
  \pdftrue
\fi
%%Then use your new variable \ifpdf
\ifpdf
  \usepackage{graphicx}
  \pdfcompresslevel=9
  \DeclareGraphicsExtensions{.jpg,.pdf,.mps,.png} 
  \graphicspath{{pdf/}}
\else
\usepackage{graphicx}
\DeclareGraphicsExtensions{.eps,.ps,.bmp,.tif,.tiff,.tga}  
\graphicspath{{eps/}} 
\fi

pdflatex can't handle EPS or PostScript file graphics (vtex, a commercial version of it, can) so we have to convert graphics to PDF first before we include them. In doing so we can avoid JPEG artifacts by specifying which images to use JPEG compression and which to use Flate compression. This relies on 'convert' from ImageMagick, which must be installed.

To convert a non-photo image to PDF, run ~atm26/bin/cartoon2epspdf:

mkdir eps
mkdir pdf
cartoon2epspdf file.gif lateximage

will convert the image to EPS and save it as eps/lateximage.eps and convert it to PDF and save it as pdf/lateximage.pdf. It works out which type the incoming file is from the extension, so make sure it has a recognised extension. For ease of use you can symlink this to all the possible conversions you might want to do (gif2epspdf, png2epspdf etc).

Similarly to convert a JPEG to PDF, run ~atm26/bin/jpeg2epspdf.

Then you should be able to run pdflatex foo and produce a PDF which picks up images from the pdf/ directory and latex foo to pick images from the eps/ directory and produce DVI (which you can convert to PostScript).

rf's TeX FAQ has other means to achieve this, as does mgk25.