Using TL 2023, this command works
lualatex --shell-escape --file-line-error index.tex
Gives no error:
...
/usr/local/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "images/my_image_file" "\def\tikzextern
alrealjob{index}\input{index}"' ========
This is LuaHBTeX, Version 1.16.0 (TeX Live 2023)
system commands enabled.
[1{/usr/local/texlive/2023/texmf-var/fonts/map/pdftex/updmap/pdftex.map}<./imag
es/my_image_file.pdf>] (./index.aux))
But this gives error
lualatex --shell-escape --file-line-error -jobname=LUA index.tex
This error happens when the latex file is trying to save tikzpicture to pdf file using the externalization package of tikz. It give this error
/usr/local/texlive/2023/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg))
===== 'mode=convert with system call': Invoking 'lualatex -shell-escape -halt-o
n-error -interaction=batchmode -jobname "images/my_image_file" "\def\tikzextern
alrealjob{LUA}\input{LUA}"' ========
This is LuaHBTeX, Version 1.16.0 (TeX Live 2023)
system commands enabled.
./index.tex:15: Package tikz Error: Sorry, the system call 'lualatex -shell-esc
ape -halt-on-error -interaction=batchmode -jobname "images/my_image_file" "\def
\tikzexternalrealjob{LUA}\input{LUA}"' did NOT result in a usable output file '
images/my_image_file' (expected one of .pdf:.jpg:.jpeg:.png:). Please verify th
at 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 c
ommand simply failed? Error messages can be found in 'images/my_image_file.log'
. If you continue now, I'll try to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.15 \end{tikzpicture}
?
It is using the jobname which is causing the problem. Otherwise externalization works, and the pdf of the tikzpicture is created correctly.
I needed to use -jobname option because I also build tex4ht in same folder and this option helps keeps auxiliary and temp file names separated and not clash when I compile to pdf and html in same folder.
In images/my_image_file.log it says
......
Inserting `luaotfload.rewrite_fontname' in `luaotfload.patch_font'.
Inserting `tracingstacklevels' in `input_level_string'.
! Emergency stop.
<read *>
<*> \def\tikzexternalrealjob{LUA}\input{LUA}
I think the problem is that it looking for LUA.tex file in the above command, but there is no LUA.tex file. This is supposed to be just the jobname, not not the input file name ! So the above command should have been
\def\tikzexternalrealjob{LUA}\input{index}
Below is MWE to reproduce this. This is on Linux virtual box running latest TL 2023
\documentclass[12pt]{article}
\usepackage{shellesc} %need for lualatex!
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[prefix=images/]
\begin{document}
%this command saves pic to images/my_image_file.pdf
%make sure to create images/ folder first as it will not do it
\tikzsetnextfilename{my_image_file}
\begin{tikzpicture}
\node[] at (0,0) {some text};
\end{tikzpicture}
\end{document}
When running these commands, please make sure to have images/ folder created and empty each time in order to see the problem.
I found that if I have the image file there before, then no error shows up when using jobname option because it sees the pdf image file already and will not attempt to create it again.
Question is: It is possible to use -jobname with lulatex and also use tikz externalization?
images/folder, and then give each pic an image file name. The document could have 10 pics, and each is saved to different pdf file in theimages/folder. But I tried what you showed and got an error./index.tex:18: Package tikz Error: Sorry, image externalization failed: the re sulting image was EMPTY. I tried to externalize 'LUA', but it seems there is no such image in the document!?What does\tikzexternalize[]{index}supposed to actually do? – Nasser Oct 25 '23 at 02:17[]rather than bothering to copy your prefix option i.e.[]is just whatever you want. So you need to specify the entire externalisation command, I think. This has nothing to do with latexmk. See 52.4.5. – cfr Oct 25 '23 at 02:29\tikzexternalize[prefix=images/]{index}and got error also. so far only solution I found is not to use-jobnamewhen using tikz externalization. – Nasser Oct 25 '23 at 02:31\tikzset{external/system call={lualatex -shell-escape -halt-on-error -interaction=batchmode -jobname "images/my_image_file" "\def\tikzextern alrealjob{LUA}\input{index}"}}maybe? I haven't tested this either yet. – cfr Oct 25 '23 at 02:32externallibrary can't? – cfr Oct 25 '23 at 02:53images/folder. I use\tikzsetnextfilename{my_image_file}before each tikzpicture. I could have 10 or 20 different tikzpics in the file and each will have different name. In the MWE I have above, I only showed one tikzpic. This all works now if I do not use-jobnamewith latexmk. – Nasser Oct 25 '23 at 03:00external.) It's not as bad as TikZ because inserting images doesn't cause later images to be renamed but, still, it would be easier, for sure. – cfr Oct 25 '23 at 03:07latexmkand might get more attention to the problem in that case. – cfr Oct 25 '23 at 04:53