[Tex/LaTex] Compile latex to pdf directly, skipping ps

compilingpdfps

Up until now, I have been using the MikTeX compiler along with the TeXnicCenter editor to compile latex documents to pdf via ps, i.e., LaTeX ==> PS ==> PDF.

However, I recently run into the printing problem of rotated pages (using the sidewaysfigure environment) inside twosided documents, as exactly described here: Page upside down?

The question is, is it OK to compile directly to PDF, thus skipping PS, in order to have the rotated pages print properly in an easy manner? For reference, I am compiling a large document including a number of .eps figure (either vector-only or mixed vector/image content). Am I missing some functionality by skipping the PostScript creation?

Best Answer

In principle you can switch from .eps files to .pdf without much ado, as long as there is no other direct PostScript code in your document, e.g. pstricks or psfrag.

The formats of .pdf and .eps files are completely different and pdflatex can handle inclusion of .jpg, .png, .gif and .pdf (recognized ones) files, but not .eps or .ps files.

In order to use such files in your .tex document, those .eps files has to be converted to .pdf (or one of the recognized ones). This can be done

  • either beforehand, using a direct converter of a graphics programe or epstopdf perl script (see http://www.ctan.org/pkg/epstopdf), ideally having a file named foo.eps to become foo.pdf, so nothing has to be changed in *.tex file, as long as no direct extension is given. This means direct inclusion after direct conversion.
  • or let pdftex or pdflatex do the job by converting the graphics file while compilation. In this case the file foo.eps will be converted to foo-eps-converted-to.pdf, having really that longer name. There is the package epstopdf (not to be confused with epstopdf perl script!), giving some options how the conversion is done etc. Automatic conversion requires the shell-enable feature, i.e. pdflatex --shell-escape. This is called on-the-fly-conversion

Regarding the aspects of including rotated pictures or (via sidewaysfigure): Some .eps generators produce already rotated pictures, so they have to be either rotated again (to the other direction) or can be included correctly, depending on the particular application.

The package graphicx allows for \DeclareGraphicsPath and \DeclareGraphicsExtension commands.

Generally said, it is better to omit the file extension in \includegraphics, such that \includegraphics can search a list of possible extensions and include the first match. If you rather prefer to include foo.jpg instead of foo.pdf, then say \includegraphics{foo.jpg} explicitly.

Regarding such PostScript specific code from psfrag or pstricks: In my personal point of view, it is better to generate a standalone .eps file from that code with latex in an other *.tex document and include it in the current .tex file, with one of two possibilities mentioned above. In this case pstricks package pst-eps might help, in conjunction with dvips -E -o option.

\documentclass{article}%

\usepackage{graphicx}%
\usepackage{epstopdf}%  Not necessary, actually, please see http://www.ctan.org/pkg/epstopdf-pkg


\begin{document}

\begin{figure}
\includegraphics{ctanlion.eps}  % will not work always, since restricted to `.eps`

\includegraphics{ctanlion}  % will work always, since file extensions will be added appropiately
\caption{CTAN lion draw­ing by Duane Bibby; thanks to www.ctan.org}
\end{figure}

\begin{figure}
\begin{tabular}{ll}
\begin{tabular}{l}
\includegraphics[scale=0.5,angle=0]{ctanlion} 
 \end{tabular} &
\begin{tabular}{l}
\includegraphics[scale=0.5,angle=-90]{ctanlion} 
 \end{tabular} \tabularnewline
\begin{tabular}{l}
\includegraphics[scale=0.5,angle=-270]{ctanlion} 
 \end{tabular} &
\begin{tabular}{l}
\includegraphics[scale=0.5,angle=-180]{ctanlion} 
 \end{tabular}
\end{tabular}
\caption{CTAN lion draw­ing by Duane Bibby; thanks to www.ctan.org}
\end{figure}


\end{document}

enter image description here

Related Question