Überlege Dir einfach mal, wie das mit dem \ref bei Externalisierung funktionieren soll. Die Fehlermeldung in test-figure_crossref0.log:
! Package tikz Error: Sorry, image externalization failed: the resulting image
was EMPTY. I tried to externalize 'test-figure_crossref0', but it seems there i
s no such image in the document!?
You are currently using 'mode=convert with system call'. This problem can ha
ppen if the image (or one of the images preceeding it) was declared inside of a
\label{} (i.e. in the .aux file): 'convert with system call' has no access to
the main aux file.
Possible solutions in this case:
(a) Try using 'mode=list and make',
(b) Issue the externalization command 'pdflatex -shell-escape -halt-on-error
-interaction=batchmode -jobname "test-figure_crossref0" "\def\tikzexternalreal
job{test}\input{test}"' *manually* (also check the preceeding externalized imag
es, perhaps the file name sequence is not correct).
Repeat: the resulting image was EMPTY, your attention is required .
See the tikz package documentation for explanation.
Type H <return> for immediate help.
...
l.79 \end{document}
sagt ja auch, dass Externalisierung mit einer Tikz-Grafik in einem Label so nicht funktioniert. Die Abbildungen werden ja nicht mehr im eigentlichen Dokument verarbeitet, sondern als (virtuelles) eigenes Dokument übersetzt. Also sind alle Information nur dort vorhanden und ggf. der dortigen aux-Datei vorhanden.
Wenn man aber, wie in der Fehlermeldung angegeben mit mode=list and make arbeitet:
\documentclass[
a4paper,11pt,oneside,fleqn,
bibliography=totoc,listof=totoc,
headlines=2.1,headsepline,
numbers=noenddot
]{scrreprt}
\usepackage[a4paper,left=3.2cm,right=2.2cm,top=1.5cm,bottom=1.5cm,includeheadfoot]{geometry}
\usepackage{graphicx} % Grafiken einbinden
\usepackage{color} % Farben ermöglichen
\usepackage{siunitx}
\usepackage{subcaption}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[mode=list and make]
\usepackage{etoolbox}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{Five Paths on Bread Board\label{fig:sweep_5}}
{
\begin{tikzpicture}
\begin{axis}[
legend columns=-1, %start Legendeneinträge
legend entries={Sensor 1;,Sensor 2;,Sensor 3;,Sensor 4;,Sensor 5},
legend to name=sensor, %ende Legendeneinträge
width=156mm, height=6.5cm,
grid = major,
grid style={dashed, gray!30},
xmin=-6,
xmax=6,
ymin=-6,
ymax= 8,
axis background/.style={fill=white},
ylabel=Voltage {[}V{]},
xlabel=Time {[}\SI{}{\us}{]},
tick align=outside]
\addplot{x};
\addplot{x+1};
\addplot{x+2};
\addplot{x+3};
\addplot{x+4};
\end{axis}
\end{tikzpicture}
}\\[15pt]
\subcaptionbox{Six Paths\label{fig:sweep_6}}
{
\begin{tikzpicture}
\begin{axis}[
width=156mm, height=6.5cm,
grid = major,
grid style={dashed, gray!30},
xmin=-6,
xmax=6,
ymin=-6,
ymax= 8,
axis background/.style={fill=white},
ylabel=Voltage {[}V{]},
xlabel=Time {[}\SI{}{\us}{]},
tick align=outside]
\addplot{x^2};
\addplot{(x+1)^2};
\addplot{(x+2)^2};
\addplot{(x+3)^2};
\addplot{(x+4)^2};
\end{axis}
\end{tikzpicture}
}\\
\ref{sensor}
\caption{Sweeps over Setups}
\label{fig:sweep_paths}
\end{figure}
\end{document}
Und nach dem ersten pdflatex-Lauf make -f foo.makefile aufruft, dann einen weiteren pdflatex-Lauf macht, dann bekommt man auch tatsächlich was man will:
Und auch wenn du es nicht glauben magst: [H] ist falsch und war es schon immer! Vor LaTeX 2015/01/01 hat LaTeX das schlicht ignoriert, solange man nicht
fixltx2e geladen hat, seit LaTeX 2015/01/01 wird es in der Voreinstellung als Fehler gemeldet.