1

I'm using the tikzscale package to scale my TikZ and PGFPlots graphics. This packages uses several iterations to get the desired dimensions. If I'm activating the externalization and use a label to be able to reference a plot, this results in a warning of multiply-defined labels.

How can I get rid of those warnings?

Use the following minimal not working example

\documentclass{scrreprt}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{tikzscale}
\usepackage{pgfplots}
\usepgfplotslibrary{external}

\tikzexternalize%

\newcommand{\plotref}[1]{\tikzexternaldisable\ref{#1}\tikzexternalenable}

\begin{document}

\begin{figure}[tbp]
  \centering
  \includegraphics[width=0.5\linewidth]{mnwe.tikz}
  \caption{Test figure with reference~(\protect\plotref{leg:test}).}
  \label{fig:test}
\end{figure}

\end{document}

and the figure file mnwe.tikz

\begin{tikzpicture}
  \begin{axis}
    \addplot[
      domain = -pi:pi,
      samples = 100,
    ]{sin(deg(x))};
    \label{leg:test}
  \end{axis}
\end{tikzpicture}

See this question for the protected plotref command.

  • You could ask the tikzscale author regarding the multiplied labels. But looking at the output there is a more serious problem with the externalization: The page number is not expanded in the label and so you won't be able to use \pageref. This is imho a bug. – Ulrike Fischer Nov 10 '15 at 10:57
  • I already thought about contacting the package author. The missing \pageref support is not a bug, it is already mentioned in the PGFPlots manual in the section 7.1.1: > Note that \pageref is not supported (sorry). – Roos Nov 10 '15 at 11:53
  • Yes, I realized that getting the correct page number is not trivial. But then it is imho not really a good idea to use the standard label system and dump useless (and in your case noisy) code to the aux-file. – Ulrike Fischer Nov 10 '15 at 13:09

Your Answer

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

Browse other questions tagged or ask your own question.