for simple use I've written an environment wrapping the tikzpicture environment. So far no trouble. Now I realized I've got a huge amount of tikzpictures in my document and I've read once about tikz externalization, so I thought that would be a good idea. So I've got this code
\documentclass{article}
\usepackage{tikz}
% place in preamble and add "--shell-excape" to latex-run (for cluttex --shell-escape)
\usetikzlibrary{external}
\tikzexternalize[prefix=figures/] % activate and define figures/ as cache folder
\newenvironment{step}{
\newcommand{\myCmd}[1]{\node[draw] {##1};}
\tikzpicture[]
\scope[local bounding box=output]
}{
\endscope
\endtikzpicture
}
\begin{document}
\begin{step}
\myCmd{lore ipsum}
\end{step}
\end{document}
which spits out
(/usr/share/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg)))
Runaway argument?
! File ended while scanning use of \tikzexternal@laTeX@collect@until@end@tikzpi
cture.
<inserted text>
\par
<*> main.tex
?
I think this ia related to 53.2 (Requirements) of the tikz manual. Is there a way for me to still use externalization but don't give up the simplicity of the environment declaration?
(on each picture I draw some nodes in the beginning, put all of the things from inside my step env in a tikz-scope and draw some nodes after the termination of the scope. Replacing all step-env occurrences with that declaration (which actually is always the same) would be ...unpleasant)
EDIT: Some way to e.g. use \begin{tikzpicture}[myTikz] which in turn will automatically put my things at the beginning/end of the tikzpicture content would suffice too, but I'm not sure if there's a way to do that with tikz.
tikzpictureenvironment itself. – user202729 Dec 10 '21 at 11:02directluaexpanded before the search for begin/endtikzpicture? (otherwise the problem of not having the literal begin/end tikzpicture statements would remain, at least from what I know of). – atticus Dec 10 '21 at 11:58tex.sprintback. (not necessary in this case, but that would be the easiest one that works with verbatim or catcode-changing environments) – user202729 Dec 10 '21 at 12:29environsolution has the problem that the detection of change doesn't really work anymore (using thediffoption of tikzexternal showed that only\begingroup \toks 0={macro:->[font=\scriptsize ] \scope [local bounding box=output] \BODY \endscope }\xdef \tikzexternallastkey {\the \toks 0 }\endgroup %is stored which makes kinda sense since the expansion in this stage is limited). So I decided to go with https://tex.stackexchange.com/questions/361738/how-to-handle-verbatim-material-in-lualatex (without this whole catcode stuff) – atticus Mar 11 '22 at 21:15\missing in"\noexpand\\EndVerbatim"(lua part) and an\noexpandmissing in}% \EndVerbatim \printverbatim(tex part) – atticus Mar 11 '22 at 21:17