我有一个关于拇指指数的后续问题 在每个页边距上显示当前章节编号。当我单独使用它时,它工作正常。但是,当我将它与 tikz 外部化结合使用时,外部化例程首先在文档上每页生成一个空的 pdf 文件,然后以错误结束
包 tikz 错误:抱歉,系统调用‘pdflatex -shell-escape -halt-on-e。
您可以在下面的 MWE 中看到,我\tikzexternalizedisable
在几个地方添加了它,但似乎不起作用。
知道我做错了什么吗?
%%MEW
% !TeX encoding = UTF-8
\documentclass[b5paper]{book}
\usepackage[english]{babel}
\usepackage{graphicx} % Graphics
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
%
%% THUMB INDEX
\usepackage{tikzpagenodes}
\usepackage{totcount}
\usepackage[contents={},opacity=1,scale=1,color=white]{background}
\newif\ifMaterial
\newlength\LabelSize
\setlength\LabelSize{1cm}
\AtBeginDocument{%
\regtotcounter{chapter}%
}
\makeatletter
\tikzexternaldisable
\newcommand\AddChapterBoxes{%
\Materialtrue
\AddEverypageHook{%
\tikzexternaldisable
\ifMaterial
\ifodd\value{page}%
\tikzexternaldisable
\backgroundsetup{
angle=0,
position={current page.east|-current page text area.north east},
vshift=-45-(\thechapter-1)*90pt,
hshift=0*\LabelSize/2,
contents={%
\tikz\node[ch label, inner xsep=\LabelSize/2] {\hspace*{-\LabelSize}\thechapter};
}%
}%
\tikzexternalenable
\else
\tikzexternaldisable
\backgroundsetup{
angle=0,
position={current page.west|-current page text area.north west},
vshift=-45-(\thechapter-1)*90pt,
hshift=0*\LabelSize/2,
contents={%
\tikz\node[ch label, inner xsep=\LabelSize/2] {\thechapter\hspace*{-\LabelSize}\null}; %
}%
\tikzexternalenable
}%
\fi
\BgMaterial
\else\relax\fi
}%
}
\newcommand\RemoveLabels{\Materialfalse}
\tikzexternalenable
\makeatother
\tikzset{
ch label/.style={fill=black,anchor=west,text width=\LabelSize, align=center,minimum height=\LabelSize,minimum width=\LabelSize*2,inner sep=0em,text=white,font=\sffamily\fontsize{15pt}{0pt}\selectfont}
}
%\tikzexternalize[prefix=FiguresTikz/] % uncomment to cause the error
\begin{document}
\tikzexternaldisable
\AddChapterBoxes
\tikzexternalenable
\chapter{Test 1}
\lipsum[1]
\begin{figure}
\tikzsetnextfilename{test_figure}
\centering
\begin{tikzpicture}[draw=black,scale=1, trim left]
\draw[fill=blue!50] (0,0) rectangle (2, 1) node[midway,font=\tiny,align=center] at (0,0) {test figure};
\end{tikzpicture}
\caption{test figure}
\end{figure}
%
%
\chapter{Test 2}
\lipsum[2]
\end{document}
答案1
您可以设置external/only named
密钥,例如通过更改\tikzexternalize[prefix=FiguresTikz/]
为\tikzexternalize[prefix=FiguresTikz/,only named]
仅外部化已明确命名的图片。