2

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?

  • 1
    eps images can't be included directly but they can be converted automatically on-the-fly as part of the compilation. If you use postscript specials in your code itself (e.g. pstricks) there are some limitations to what's possible if you compile directly to pdf (pdftricks can't replicate the full functionality). I'm assuming you are thinking of using pdfLaTeX. If you use LuaLaTeX, you can use eps files directly, I believe. – cfr Jun 11 '14 at 3:21
  • You can use epstopdf or auto-pst-pdf packages and then compile using `pdflatex. – user11232 Jun 11 '14 at 3:42
  • @cfr: Can you please elaborate on the "direct inclusion" vs. "on-the-fly conversion" of .eps images? – Christos Oreinos Jun 11 '14 at 4:02
3

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

  • It's interesting that on my setup, I compiled from LaTeX directly to PDF without using the epstopdf package. It run smoothly and with no problem. Is it because the file was already compiled beforehand via PS (i.e., LaTeX ==> PS ==> PDF)? The reason I am not using the angle option of the \includegraphics command is that I want the caption to be rotated as well, according to the orientation of the figure. – Christos Oreinos Jun 11 '14 at 6:47
  • 2
    @ChrisOreinos: It works without the package, yes, because this is done by \includegraphics from graphicx package already. epstopdf provides some additional options and even allows for setting another on-the-fly-converter programme/script – user31729 Jun 11 '14 at 6:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.