已知的故事?

已知的故事?

当使用 hyperref 和外部化时,如何消除命名图的 pgfplotslink.0.0 警告?

已知的故事?

PGFPLOTs 手册(版本 1.13 2016/01/06)第 7.1 节第 512 页明确指出:

\label在主文档中引用的外部化图形中

需要\tikzset{external/mode=list and make},所以我使用 cygwin 中的 make。在 Linux 上,make 已经存在。

该手册第 4.9.6 节第 246 页指出:

\ref{<label name>}

可用于引用带标签的单个图。请参阅上面的示例。

这也可以与 hyperref 链接和 \pageref 一起使用

引文表明支持以下示例:

\documentclass{article}
% Referring to a named plot via~\ref{namedplot} triggers a warning when
% combied with hyperref and externalization.

\usepackage{pgfplots}
\pgfplotsset{compat=1.13} % mute the backwards compatibility warning
\usepgfplotslibrary{external}
\tikzset{external/mode=list and make}
% The warning goes away aswell when externalization is disabled by
% commenting the next line.
\tikzexternalize

% hyperref is needed to trigger the warning
\usepackage{hyperref}

% wrapper of ref{} to avoid externalizing the small ref
\newcommand*{\refne}[1]{\tikzexternaldisable\ref{#1}\tikzexternalenable}

\begin{document}
\begin{figure}
\tikzsetnextfilename{picture_1}%
\begin{tikzpicture}
\begin{axis}[domain=0:10]
\addplot {sin(x^2)};
\label{namedplot}
\end{axis}
\end{tikzpicture}
\caption[alternative caption to keep the ref-stuff away from the lof]
{Referring to the named plot via~\refne{namedplot} triggers the warning.}
\end{figure}
\end{document}

但是无论编译多少次都会出现警告:

name{pgfplotslink.0.0} has been referenced but does not exist, replaced by a fixed one

我的研究

已知问题标题中的图例引用*和*外部化实际上与此相关,legend to name并且解决方案涉及一个包装器以禁用 ref 的外部化,无论如何我都会使用它(参见代码)。

类似建议pgfplots,自定义图例和 tikz 库外部建议的位置\pgfplotslegendfromname{named}。然而,这只适用于图例。

按照建议 hyperref先加载pgfplotsHyperref 不适用于 \subbottom 内的图例标签没有解决。

请求我们可以将引用放入外部化的 pgfplots 图像中吗? 似乎不涉及hyperref。它涉及向出版商或档案馆提交代码。

警告表明链接将指向错误的目标,即包含图片的页面顶部。在这种情况下,读者不会注意到这一点,因为人们很少会从标题内部点击链接。

问题

如何静音pgfplotslink.0.0示例中的 -warning?我不需要hyperref命名图的该功能,但我想将其保留用于文档中的其他引用。放弃外部化不是一种选择。

版本信息:

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (MiKTeX 2.9 64-bit) (preloaded format=pdflatex 2016.5.3) 27 JUL 2017 16:15

Package: pgfplots 2016/01/06 v1.13 Data Visualization (1.13)

Package: pgf 2015/08/07 v3.0.1a (rcs-revision 1.15)

答案1

pgfplots.code.tex我发现的定义中\pgfplotsplotfromname,它解决了这个问题,如下所示:使用\pgfplotsplotfromname而不是\ref引用命名图。警告消失,因为\hyperref被禁用。

警告:\pgfplotsplotfromname没有记录并且将来可能会发生变化。

例如,以下代码可避免警告:

\newcommand*{\refne}[1]{\tikzexternaldisable\pgfplotsplotfromname{#1}\tikzexternalenable}

完整示例为:

\documentclass{article}
% Referring to a named plot via~\ref{namedplot} triggers a warning when
% combied with hyperref and externalization.
% Workaround: \pgfplotsplotfromname instead of \ref

\usepackage{pgfplots}
\pgfplotsset{compat=1.13} % mute the backwards compatibility warning
\usepgfplotslibrary{external}
\tikzset{external/mode=list and make}
\tikzexternalize

\usepackage{hyperref}

% \pgfplotsplotfromname instead of \ref fixes the warning
% use of \tikzexternaldisable\tikzexternalenable is optional
\newcommand*{\refne}[1]{\tikzexternaldisable\pgfplotsplotfromname{#1}\tikzexternalenable}

\begin{document}
\begin{figure}
\tikzsetnextfilename{picture_1}%
\begin{tikzpicture}
\begin{axis}[domain=0:10]
\addplot {sin(x^2)};
\label{namedplot}
\end{axis}
\end{tikzpicture}
\caption[alternative caption to keep the ref-stuff away from the lof]
{Referring to the named plot via~\refne{namedplot} will not trigger the warning, because hyperref is not involed.}
\end{figure}
\end{document}

相关内容