# [pstricks] includegraphics page of pdf, pst-pdf, auto-pst-pdf

Alan Ristow ristow at ece.gatech.edu
Thu Mar 20 17:12:05 CET 2008

exelnet at exelnet.de wrote:
> Hi!
>
> Im trying to include a pdf page.
>
> \listfiles
> \documentclass[11pt,a4paper]{report}
> \usepackage[utf8]{inputenc}
> \usepackage{graphicx}
> \usepackage{pst-pdf}
>
> \begin{document}
>
> \includegraphics[page=1,width=\linewidth]{graphicx}
>
> \end{document}
>
> This wont work. It will end with the following compile error:
>
>
> latex test.tex

You need to use pdflatex to make your example work -- the "page" key is
really only useful when your graphic is a multi-page pdf, which regular
latex cannot handle.

> Ideally i would like to use auto-pst-pdf package. I ve been working with it
> for a while and it did work fine for everything except the \includegraphics[page=...
> command.

Since your pstricks code has to be processed using latex (as opposed to
pdflatex), the \includgraphics command will continue to be a problem
even with pst-pdf. I don't generally use \includegraphics so I haven't
run into this problem before, but the obvious workaround that occurs to
me is to use the ifpdf package so the \includgraphics statement is only
executed on pdflatex runs. Something like this:

\ifpdf
\includgraphics[...]
\else
\relax
\fi

Since the latex runs are used only to generate graphics for your later
pdflatex run, this shouldn't affect your final output.

I don't see a more straightforward or elegant solution than this in the
pst-pdf docs, but if I've missed something I'm sure somebody will be by
to fill us in.

> my \listfiles output:

Your pstricks and pst-pdf are outdated. It has nothing to do with this
problem -- your example should work just fine without
\usepackage{pst-pdf} -- but I thought I would mention it.

Alan