# ShareLaTeX and auto-pst-pdf

In my code I'm using chemnum to number chemical compounds on ShareLaTeX. Since now I was compiling setting latex as compiler, but, for a list of reasons, I would like to switch to pdflatex. So I added the line

\usepackage[run=2, crop=off]{auto-pst-pdf}


and switched the compiler to pdflatex, but the compilation failed, because auto-pst-pdf couldn't create output-pics.pdf. The complete log is here.

If I compile the same code locally on my machine with pdflatex, the compilation ends with no errors. Here you can find the log of my local successful compilation.

Thinking about an issue with the ShareLaTeX compiler, I wrote to the ShareLaTeX support team, but they replied saying they are "not able to help with in-depth LaTeX questions" and recommended "asking this question on tex.stackexchange.com". So I'm here! :D

Here is my MWE: you can find the file ammide.eps here.

\documentclass[a4paper, 11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{newfloat}
\usepackage[run=2, crop=off]{auto-pst-pdf}
\usepackage{chemnum}

\DeclareFloatingEnvironment[
listname={Elenco degli Schemi},
name=Schema,
placement=htbp,
]{scheme}

\begin{document}
\begin{scheme}[htbp]
\replacecmpd{tiofencarbossilato}
\replacecmpd{cloruroacido}
\replacecmpd{ammide}
\includegraphics{ammide.eps}
\caption{Sintesi N,N-dietiltiofen-3-carbossiammide}
\end{scheme}
\end{document}


An even-more-minimal working example is simply

\documentclass[a4paper, 11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[run=2, crop=off]{auto-pst-pdf}

\begin{document}
Some text
\end{document}


which, on ShareLaTeX using pdflatex, produces the output file correctly, but still has the warning Package auto-pst-pdf Warning: Could not create output-pics.pdf. Auxiliary files not deleted. This warning occured on input line 124. which, in the end, is the main problem I'm addressing.

The surprising thing in your log-file is that your sharelatex seems to use texlive 2015 (I still see TL2014), and that it seems to activate --shell-escape.

The source of the problem is that sharelatex sets \jobname to "output" and this confuses auto-pst-pdf. E.g. it tries to run latex output.tex. You can reproduce the problem locally by running pdflatex --jobname=output --shell-escape yourfile.

You could try to redefine \jobname in the document. But it is possible that this confuses other packages, so I would advise to use it in small documents to create the pictures which you then include normally in your main document.

\documentclass[a4paper, 11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage{newfloat}
\usepackage[run=2, crop=off]{auto-pst-pdf}
\usepackage{chemnum}

\DeclareFloatingEnvironment[
listname={Elenco degli Schemi},
name=Schema,
placement=htbp,
]{scheme}

\begin{document}
\begin{scheme}[htbp]
\replacecmpd{tiofencarbossilato}
\replacecmpd{cloruroacido}
\replacecmpd{ammide}
\includegraphics{ammide.eps}
\caption{Sintesi N,N-dietiltiofen-3-carbossiammide}
\end{scheme}
\end{document}

• Great! I simply added that line to my main document as you suggested and everything compiles perfectly now! No other package has been confused as you feared. Apr 9 '16 at 13:43
• A biibliography and an index maybe a problem.
– user2478
Apr 9 '16 at 14:00
• My document has a (manual) bibliography and a \tableofcontents, but I've had no problems so far with \def\jobname{main} on ShareLaTeX. Apr 11 '16 at 10:17