[OS X TeX] Using \usepgfplotslibrary{external}
Martin Bergren
martin.berggren at cs.umu.se
Thu Aug 4 20:22:12 CEST 2016
> On 04 Aug 2016, at 18:04, Herbert Schulz <herbs at wideopenwest.com> wrote:
>
>> On Aug 4, 2016, at 10:29 AM, Martin Bergren <martin.berggren at cs.umu.se> wrote:
>>
>>
>>
>>> On 04 Aug 2016, at 17:23, Herbert Schulz <herbs at wideopenwest.com> wrote:
>>>
>>>> On Aug 4, 2016, at 9:35 AM, Martin Bergren <martin.berggren at cs.umu.se> wrote:
>>>>
>>>>>
>>>>> On 04 Aug 2016, at 16:20, Herbert Schulz <herbs at wideopenwest.com> wrote:
>>>>>
>>>>>> On Aug 4, 2016, at 9:09 AM, Martin Bergren <martin.berggren at cs.umu.se> wrote:
>>>>>>
>>>>>>>
>>>>>>> On 04 Aug 2016, at 15:57, Herbert Schulz <herbs at wideopenwest.com> wrote:
>>>>>>>
>>>>>>>> On Aug 4, 2016, at 7:56 AM, Martin Bergren <martin.berggren at cs.umu.se> wrote:
>>>>>>>>
>>>>>>>>> On 04 Aug 2016, at 14:52, Herbert Schulz <herbs at wideopenwest.com> wrote:
>>>>>>>>>
>>>>>>>>>> On Aug 4, 2016, at 7:22 AM, Martin Bergren <martin.berggren at cs.umu.se> wrote:
>>>>>>>>>>
>>>>>>>>>> I would like to be able to use
>>>>>>>>>>
>>>>>>>>>> \usepgfplotslibrary{external}
>>>>>>>>>>
>>>>>>>>>> for pgfplots, which apparently should be able to store the pgfplots or tikz figures as pdfs to shorten latexing time. The problem seem to be write18.
>>>>>>>>>> Is there a way around it?
>>>>>>>>>>
>>>>>>>>>> Cheers,
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Martin Berggren
>>>>>>>>>
>>>>>>>>> Howdy,
>>>>>>>>>
>>>>>>>>> Assuming you are using TeXShop:
>>>>>>>>>
>>>>>>>>> One thing you can use is the sepdflatexmk engine. This is set up to use latexmk so that all processing through bibtex/biber and makeindex is taken care of if necessary and the pdflatex has the --shell-escape flag set. To use it simply place the line
>>>>>>>>>
>>>>>>>>> % !TEX TS-program = sepdflatexmk
>>>>>>>>>
>>>>>>>>> at the top of your file and then typeset the document by simply using Typeset->Typeset (Cmd-T).
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>> But this is not a bibtex/biber and makeindex issue. This is about pgfplots, which I think is running (in my case) lualatex in the background to produce the plots.
>>>>>>>>
>>>>>>>> Cheers,
>>>>>>>>
>>>>>>>> Martin Berggren
>>>>>>>
>>>>>>> Howdy,
>>>>>>>
>>>>>>> If it's really using lualatex you need to somehow have it load the luatex85 package and the shellesc package under lualatex. I don't know if your initial file is run under lualatex but you might try to include
>>>>>>>
>>>>>>> \ifx\directlua\@undefined
>>>>>>> \else
>>>>>>> \RequirePackage{luatex85}
>>>>>>> \RequirePackage{shellesc}
>>>>>>> \fi
>>>>>>>
>>>>>>> before the \documentclass command. Otherwise you need to see how to have that included in the lualatex call.
>>>>>>>
>>>>>>> I think tikz-fct uses gnuplot and, assuming you have gnuplot in your PATH, using the shell escape provided by the sepdflatexmk engine should do the job.
>>>>>>
>>>>>> No, luatex is not the issue (same problem with pdftex), and I don’t think this is a gnuplot issue either. The error I get is the following:
>>>>>>
>>>>>> Package tikz Error: Sorry, the system call 'lualatex -halt-on-error -interact
>>>>>> ion=batchmode -jobname "portoptreport1-figure0" "\def\tikzexternalrealjob{porto
>>>>>> ptreport1}\input{portoptreport1}"' did NOT result in a usable output file 'port
>>>>>> optreport1-figure0' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify that
>>>>>> you have enabled system calls. For pdflatex, this is 'pdflatex -shell-escape'.
>>>>>> Sometimes it is also named 'write 18' or something like that. Or maybe the com
>>>>>> mand simply failed? Error messages can be found in 'portoptreport1-figure0.log'
>>>>>> . If you continue now, I'll try to typeset the picture.
>>>>>>
>>>>>> That’s why I in my first post said that it seems to be a write18 issue. To me it seems like lualatex (or pdflatex) is supposed to run as a system command to produce the picture files.
>>>>>>
>>>>>> (The point with the \usepgfplotslibrary{external} command is that tikz and pgfplot should not need to interpret the figures each time but instead produce a pdf-file, save it to a subdirectory, and use that in order to speed up the process).
>>>>>>
>>>>>> Cheers,
>>>>>>
>>>>>> Martin Berggren
>>>>>
>>>>> Howdy,
>>>>>
>>>>> Pretty confusing message. It says it can't get output from a lulatex command (which doesn't contain --shell-escape --- and even then it would need to include those packages since luatex in TL2016 does system calls through a different mechanism, hence the addition of the luatex85 and shellesc packages) and then talks about pdflatex --shell-escape. The sepdflatex engine in TeXShop does call pdflatex with --shell-escape but has no control over any internal call to lualatex.
>>>>>
>>>>> I'd suggest putting the question on Stack Exchange, <http://tex.stackexchange.com>, which is monitored by many experienced folks.
>>>>
>>>>
>>>> As I understand it, it is only a few system commands that are allowed through \write18{}, namely those explicitly listed in /usr/local/texlive/2016/texmf-dist/web2c/texmf.cnf, which is
>>>>
>>>> shell_escape_commands = \
>>>> bibtex,bibtex8,\
>>>> extractbb,\
>>>> gregorio,\
>>>> kpsewhich,\
>>>> makeindex,\
>>>> mpost,\
>>>> repstopdf,\
>>>>
>>>> I tried to set shell_escape = a in my local texmf.cnf file, but that does not work either. It is regarded a security issue, it seems.
>>>>
>>>> Cheers,
>>>>
>>>> Martin Berggren
>>>
>>> Howdy,
>>>
>>> Not quite... The restricted shell escape list allows pdftex to execute the programs on that list even without --shell-escape being set. If you do set --shell-escape it allows pdftex to execute anything you ask for and is therefore not secure.
>>>
>>> Part of the problem is that luatex in TL2016 no longer uses \write18 to execute external commands even if allowed to using --shell-escape. That is why requiring the luatex85 and shellesc packages in lualatex is necessary to simulate the use of \write18.
>>
>>
>> I tried various version; with -shell-escape option, using luatex85, setting shell_escape = a in my local texmf.cnf file. Nothing helped. I did not try shellesc package, though. Didn’t know about that.
>>
>> Cheers,
>>
>> Martin Berggren
>
> Howdy,
>
> Are you compiling with pdflatex and pgfplots is running lualatex or are you compiling with lualatex directly? It would be helpful if you gave a minimal and compilable example that demonstrates your problem with instructions about compiling it.
>
> Good Luck,
>
> Herb Schulz
> (herbs at wideopenwest dot com)
>
With the combined help of you and stackexchange, I got it to work now. The example code below (testmatriximage.tex) works with the either of the commands
lualatex --shell-escape testmatriximage
lualatex --enable-write18 testmatriximage
The code before \documentclass is needed when running lualatex, but not when using pdflatex. Case closed I guess! Thanks for the swift help!
\ifx\directlua\@undefined
\else
\RequirePackage{luatex85}
\RequirePackage{shellesc}
\fi
\documentclass[tikz]{article}
\usepackage{filecontents}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize
\begin{filecontents*}{temp.dat}
0 0 10
1 0 9
0 1 11
1 1 12
\end{filecontents*}
\begin{document}
\begin{figure}
\begin{tikzpicture}
\begin{axis}[
axis equal,
colorbar,
hide axis,
point meta min=9,
point meta max=12]
\addplot [matrix plot*,point meta=explicit] file [meta=index 2] {temp.dat};
\end{axis}
\end{tikzpicture}
\end{figure}
\end{document}
Martin Berggren
-------------------------------------------------------------------
Department of Computing Science, Umeå Universitet
Campustorget 5, S-901 87 Umeå, Sweden. Ph: +46-70-732 8111
http://www.cs.umu.se/~martinb, Martin.Berggren at cs.umu.se
----------- Please Consult the Following Before Posting -----------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: https://www.esm.psu.edu/~gray/tex/
List Archives: http://dir.gmane.org/gmane.comp.tex.macosx
https://email.esm.psu.edu/pipermail/macosx-tex/
TeX on Mac OS X Website: http://mactex-wiki.tug.org/
List Info: https://email.esm.psu.edu/mailman/listinfo/macosx-tex
More information about the macostex-archives
mailing list