3

This code:

\documentclass[11pt,openright]{book}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage[british]{babel}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix={"C:/Users/MyName MySurname/Documents/LaTeX/Figures/"}] 
%\tikzexternalize[prefix={Figures/}] 

\begin{document}
\begin{tikzpicture}
    \draw (0,0) circle (1cm);
\end{tikzpicture}
\end{document}

gives me the error:

! I can't write on file `"C:/Users/MyName MySurname/Documents/LaTeX/Figures/MyMWE-figure0.md5"'.

I'm working with Windows 10, MiKTeX 2.9 distibution.

Following the advice Tarass gave me on a comment of this question: Absolute path for pgf externalisation and as indicated here: http://docs.miktex.org/manual/localadditions.html I've registered a user-managed TEXMF directory but I still get the same error.

With \tikzexternalize[prefix={Figures/}] all works perfectly but, since I'm using LyX, the files are stored in a LyX temp dir, hence I loose them when I close the program (making externalization useless), so I need to use an absolute path.

  • Sorry that you seem to be getting less help than you hoped for. Maybe your question is an instance of the XY problem? (meta.stackexchange.com/questions/66377/what-is-the-xy-problem) If this is the case then you might get better answers by telling us your original problem. – G.M. Jul 21 '16 at 15:54
  • @G.M. Maybe. Should I post another question or edit this one? – CarLaTeX Jul 21 '16 at 16:03
  • Similar to G.M.'s comment, can you discuss what your end goal is? You can get the PDF file you want, but you also want the individual files that contain the picture's files? Is that right? – scottkosty Jul 26 '16 at 21:53
  • @scottkosty I get the complete PDF file correctly, but I'd like to have the picture's file not delete when I close LyX, otherwise every time I reopen it they are recreated, even if they're not changed. I've written also to lyx-devel: mail-archive.com/lyx-devel@lists.lyx.org/msg195803.html, let me know if this explanation is sufficient or you need more info, thank you! – CarLaTeX Jul 27 '16 at 4:40
  • @CarLaTeX I see, now I understand. So it is not just a matter of saving them, but you want TikZ to realize that it doesn't have to regenerate them. This is important to know. – scottkosty Jul 27 '16 at 4:51
1
+50

As mentioned in a comment in the question you linked too, one can allow miktex to write to absolute pathes by creating the environment variable

  MIKTEX_ALLOWUNSAFEOUTPUTFILES

and setting it to the value 1.

Then externalization to an absolute path works fine for me if I avoid to use a path with spaces in it.

But I don't recommend this. This is very unsafe, you are allowing miktex to write everywhere and this means it can destroy data in other folders without warnings.

Setting TEXINPUTS or creating some local texmf tree is useless -- your problem is about writing not reading.

  • But if MIKTEX_ALLOWUNSAFEOUTPUTFILES=1 is not recommended, there is no alternative? – CarLaTeX Jul 21 '16 at 15:01
  • 1
    Ask the lyx support. Or don't use lyx. – Ulrike Fischer Jul 21 '16 at 15:15
  • @UlrikeFischer assuming that CarLaTeX is using -shell-escape when compiling TikZ, isn't -shell-escape a much worse security issue than the one described here? – scottkosty Jul 26 '16 at 22:08
  • @scottkosty, @UlrikeFischer: BTW, I am using -shell-escape. I'm accepting the answer to not waste the bounty – CarLaTeX Jul 27 '16 at 5:27
  • @scottkosty: --shell-escape is a security issue too, and I'm using it with care, but at least normally you can easily enable and disable it. Environment variables have a tendency to get forgotten. Also imho it is much easier to destroy something by accident with the variable, only type once ../ instead of ./ . – Ulrike Fischer Jul 27 '16 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.