以下 LaTeX 代码\tikzexternalize
显然由于\ctrref{alldifferent}
图 1 标题中的宏的使用而无法编译(但注释掉的标题有效:宏\constraint
不使用“indexuse”,而宏\ctrref
使用“indexuse”)
\documentclass[]{article}
\usepackage{index}
\usepackage{tikz}\usetikzlibrary{calc,external}
\tikzexternalize
\def\ctrref#1{$\constraint{#1}$\index{#1@$\constraint{#1}$|indexuse}}
\def\constraint#1{\textsc{#1}}
\begin{document}
\title{Title}
\author{Author}
\maketitle
\begin{figure}[!h]
\centering
{\footnotesize
\begin{tikzpicture}
\foreach \i in {1,2,3,4,5,6,7,8} \draw (\i-1,0) node[rectangle,draw,fill=cyan!45] (var\i) {\scriptsize$V_{\i}$};
\foreach \j in {1,2,3,4,5,6,7,8,9} \draw (\j-1,1.2) node[rectangle,draw,fill=pink!50] (val\j) {\scriptsize$\j$};
\foreach \i/\j in {1/1,1/2,2/1,2/2,3/3,3/4,4/3,4/4,4/5,5/4,5/5,6/6,6/7,7/6,7/7,8/8} \draw[->] (var\i) -- (val\j);
\foreach \j/\i in {1/1,2/2,3/3,4/4,5/5,6/6,7/7} \draw[->] ($(val\j)+(-0.1,-0.18)$) -- ($(var\i)+(-0.1,0.22)$);
\foreach \i/\j in {7/8} \draw[blue!70,thick,->] (var\i) -- (val\j);
\foreach \i/\j in {8/9} \draw[thick,->] (var\i) -- (val\j);
\foreach \j/\i in {8/8} \draw[thick,->] ($(val\j.south west)+(0.08,0)$) -- ($(var\i.north)-(0.107,0)$);
\foreach \i/\j in {2/3} \draw[thick,red!90,->] (var\i) -- (val\j);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var1.south west)-(0.1,0.1)$) rectangle ($(val2.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var3.south west)-(0.1,0.1)$) rectangle ($(val5.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var6.south west)-(0.1,0.1)$) rectangle ($(val7.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var8.south west)-(0.1,0.1)$) rectangle ($(val8.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var8.south east)+(0.4,-0.1)$) rectangle ($(val9.north east)+(0.17,0.1)$);
\node at ($(var1)+(0.2,-0.5)$) (scc1) {\scriptsize s.c.c.~1};
\node at ($(var3)+(0.2,-0.5)$) (scc2) {\scriptsize s.c.c.~2};
\node at ($(var6)+(0.2,-0.5)$) (scc3) {\scriptsize s.c.c.~3};
\node at ($(var8)+(0,-0.5)$) (scc4) {\scriptsize s.c.c.~4};
\node at ($(var8)+(1.05,-0.5)$) (scc5) {\scriptsize s.c.c.~5};
\node at ($(val4)+(0.5,0.6)$) {$\color{black!80}\overbrace{\hspace*{210pt}}^{\texttt{\scriptsize {\color{black}matched values: values $1$, $2$, $3$, $4$, $5$, $6$, $7$ and $8$}}}$};
\node at ($(val9)+(0,0.8)$) (unmatched) {\scriptsize unmatched};
\node at ($(val9)+(0,0.5)$) (unmatched) {\scriptsize value: $9$};
\node at (-1,0.7) (gm) {$\overrightarrow{G}_M$};
\end{tikzpicture}
\caption{\label{fig:alldifferent_scc_filtering}
DONT WORK: Illustration of the filtering for \ctrref{alldifferent}.
%WORK: Illustration of the filtering for \constraint{alldifferent}.
}}
\end{figure}
\end{document}
在图 1 的标题中写\protect\ctrref{alldifferent}
而不是写\ctrref{alldifferent}
并没有帮助。因为我想把的参数放在\ctrref
索引中,所以\ctrref
定义如下:
\def\ctrref#1{$\constraint{#1}$\index{#1@$\constraint{#1}$|indexuse}}
\def\constraint#1{\textsc{#1}}
答案1
您缺少 \makeindex 命令,它应该在 之前\tikzexternalize
。我还将使用 \caption 的可选参数。
\documentclass[]{article}
\usepackage{index}
\usepackage{tikz}\usetikzlibrary{calc,external}
\makeindex
\def\ctrref#1{$\constraint{#1}$\index{#1@$\constraint{#1}$|indexuse}}
\def\constraint#1{\textsc{#1}}
\tikzexternalize
\begin{document}
\title{Title}
\author{Author}
\maketitle
\begin{figure}[!h]
\centering
{\footnotesize
\begin{tikzpicture}
\foreach \i in {1,2,3,4,5,6,7,8} \draw (\i-1,0) node[rectangle,draw,fill=cyan!45] (var\i) {\scriptsize$V_{\i}$};
\foreach \j in {1,2,3,4,5,6,7,8,9} \draw (\j-1,1.2) node[rectangle,draw,fill=pink!50] (val\j) {\scriptsize$\j$};
\foreach \i/\j in {1/1,1/2,2/1,2/2,3/3,3/4,4/3,4/4,4/5,5/4,5/5,6/6,6/7,7/6,7/7,8/8} \draw[->] (var\i) -- (val\j);
\foreach \j/\i in {1/1,2/2,3/3,4/4,5/5,6/6,7/7} \draw[->] ($(val\j)+(-0.1,-0.18)$) -- ($(var\i)+(-0.1,0.22)$);
\foreach \i/\j in {7/8} \draw[blue!70,thick,->] (var\i) -- (val\j);
\foreach \i/\j in {8/9} \draw[thick,->] (var\i) -- (val\j);
\foreach \j/\i in {8/8} \draw[thick,->] ($(val\j.south west)+(0.08,0)$) -- ($(var\i.north)-(0.107,0)$);
\foreach \i/\j in {2/3} \draw[thick,red!90,->] (var\i) -- (val\j);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var1.south west)-(0.1,0.1)$) rectangle ($(val2.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var3.south west)-(0.1,0.1)$) rectangle ($(val5.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var6.south west)-(0.1,0.1)$) rectangle ($(val7.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var8.south west)-(0.1,0.1)$) rectangle ($(val8.north east)+(0.17,0.1)$);
\draw[draw=black!65, line width=0.6pt, densely dashed, rounded corners=5pt] ($(var8.south east)+(0.4,-0.1)$) rectangle ($(val9.north east)+(0.17,0.1)$);
\node at ($(var1)+(0.2,-0.5)$) (scc1) {\scriptsize s.c.c.~1};
\node at ($(var3)+(0.2,-0.5)$) (scc2) {\scriptsize s.c.c.~2};
\node at ($(var6)+(0.2,-0.5)$) (scc3) {\scriptsize s.c.c.~3};
\node at ($(var8)+(0,-0.5)$) (scc4) {\scriptsize s.c.c.~4};
\node at ($(var8)+(1.05,-0.5)$) (scc5) {\scriptsize s.c.c.~5};
\node at ($(val4)+(0.5,0.6)$) {$\color{black!80}\overbrace{\hspace*{210pt}}^{\texttt{\scriptsize {\color{black}matched values: values $1$, $2$, $3$, $4$, $5$, $6$, $7$ and $8$}}}$};
\node at ($(val9)+(0,0.8)$) (unmatched) {\scriptsize unmatched};
\node at ($(val9)+(0,0.5)$) (unmatched) {\scriptsize value: $9$};
\node at (-1,0.7) (gm) {$\overrightarrow{G}_M$};
\end{tikzpicture}
\caption[Illustration of the filtering]{\label{fig:alldifferent_scc_filtering}blub
DONT WORK: Illustration of the filtering for \ctrref{alldifferent}.
%%%WORK: Illustration of the filtering for \constraint{alldifferent}.
}}
\end{figure}
\end{document}