# pstricks-doi package conflict?

The following does not work:

\documentclass{minimal}

\usepackage{doi}
\usepackage[pdf]{pstricks}

\begin{document}
hello world
\begin{pspicture}(1,1)
\psline(0,0)(1,1)
\end{pspicture}
\end{document}


However, loading the doi package after pstricks does:

\documentclass{minimal}

\usepackage[pdf]{pstricks}
\usepackage{doi}

\begin{document}
hello world
\begin{pspicture}(1,1)
\psline(0,0)(1,1)
\end{pspicture}
\end{document}


Why? Particularly, are there any caveats that I should be aware of? Thanks in advance.

doi.sty depends upon hyperref. It is generally recommended that hyperref be the last package you load because of the way it redefines various macros (in order to get hyperreferencing to work). So, this is mostly a similar case where the commands needed to get pstricks to work under pdflatex are also redefined by hyperref.

You might want to check out "Which packages should be loaded after hyperref instead of before?" for further details.

Use

\documentclass{minimal}
\usepackage{ifpdf}
\ifpdf\usepackage{doi}\fi
\usepackage[pdf]{pstricks}
...


Then doi is only loaded when running pdflatex.

• I'm not sure I understand what's happening here. If I run pdflatex -shell-escape on your MWE, everything works fine. But if I run pdflatex -shell-escape on a file without the package ifpdf and without \ifpdf...\fi wrapper, then I get postscript errors. If I'm using pdflatex why should it matter whether I wrap the call to the package in \ifpdf...\fi or not? – A.Ellett Sep 16 '13 at 14:07
• you get the wrong driver for hyperref when running latex to ceate the image. – user2478 Sep 16 '13 at 15:58
• I am confused as well—what do we achieve by loading the doi package only when using pdflatex? I asked my question with the goal of using both the doi and pstricks packages simultaneously (and thus understanding the apparent conflict between them). – nimble agar Sep 17 '13 at 2:07
• @Arman: you do not understand what exactly the option [pdf] does! It loads the package auto-pst-pdf which itself runs in the background latex to create a PDF image which then is used when running pdflatex, instead of the pspicture environment – user2478 Sep 17 '13 at 8:14