In the MWE below, there is a custom arrow defined as a separate drawing using \tikz. The arrow is used as an edge node so that it can be sloped automatically.
I am also using the TikZ external package because this is part of a book-length project with many TikZ figures.
MWE:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\newcommand{\myarrow}{\tikz{\draw[->] (0,0)--(10pt,0)}}
\begin{document}
\begin{tikzpicture}
\node[draw] (1) at (0,0) {};
\node[draw] (2) at (1,1) {};
\draw (1) to[edge node={node [sloped,above] {\myarrow}}] (2);
\end{tikzpicture}
\end{document}
If I try to compile the MWE as-is, I get an error message:
/mwe.tex:18: Package tikz Error: Sorry, the system call 'pdflatex -shell-escap
e -halt-on-error -interaction=batchmode -jobname "mwe-figure0" "\def\tikzextern
alrealjob{mwe}\input{mwe}"' did NOT result in a usable output file 'mwe-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 a
lso named 'write 18' or something like that. Or maybe the command simply failed
? Error messages can be found in 'mwe-figure0.log'. If you continue now, I'll t
ry to typeset the picture.
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.18 \end{tikzpicture}
?
[1{/usr/local/texlive/2021/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./mwe.aux) )</usr/local/texlive/2021/texmf-dist/fonts/type1/public/amsfonts/cm
/cmr10.pfb>
Output written on mwe.pdf (1 page, 8538 bytes).
SyncTeX written on mwe.synctex.gz.
Transcript written on mwe.log.
If I comment out the \tikzexternalize line, it compiles fine:
And if I comment out the \draw (1) ... line, it compiles fine too. Any suggestions?


\draw (1) to[edge node={node [sloped,above] {$\longrightarrow$}}] (2);– Zarko May 06 '21 at 21:54slopedpicfor the sloped arrow. This avoids nesting and gives you all the arrow heads and line styles you want. – May 06 '21 at 22:24slopedpic? – LarrySnyder610 May 06 '21 at 22:32