5

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.

2 Answers 2

5

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.

1

Use

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

Then doi is only loaded when running pdflatex.

4
  • 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
    Commented Sep 16, 2013 at 14:07
  • you get the wrong driver for hyperref when running latex to ceate the image.
    – user2478
    Commented Sep 16, 2013 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). Commented Sep 17, 2013 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
    Commented Sep 17, 2013 at 8:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .