Pgfplotstable 和 etoc 不会重新编译

Pgfplotstable 和 etoc 不会重新编译

我的文档编译正常,但似乎包 etoc 和 pgfplots 之间不兼容。latex 编译,但不能重新编译以获取参考文献和目录。我写了这个 MWE。(热图代码来自使用 TikZ 绘制热图

\documentclass{report}
\usepackage{pgfplotstable}
\pgfplotsset{compat=1.10}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{colortbl}
\usepackage{tikz}
\usetikzlibrary{matrix,positioning}
\usepackage{etoc}
\usepackage{appendix}

\pgfplotstableset{
    /color cells/min/.initial=0,
    /color cells/max/.initial=1000,
    /color cells/textcolor/.initial=,
    %
    % Usage: 'color cells={min=<value which is mapped to lowest color>, 
    %   max = <value which is mapped to largest>}
    color cells/.code={%
        \pgfqkeys{/color cells}{#1}%
        \pgfkeysalso{%
            postproc cell content/.code={%
                %
                \begingroup
                %
                % acquire the value before any number printer changed
                % it:
                \pgfkeysgetvalue{/pgfplots/table/@preprocessed cell content}\value
                \ifx\value\empty
                    \endgroup
                \else
                \pgfmathfloatparsenumber{\value}%
                \pgfmathfloattofixed{\pgfmathresult}%
                \let\value=\pgfmathresult
                %
                % map that value:
                \pgfplotscolormapaccess
                    [\pgfkeysvalueof{/color cells/min}:\pgfkeysvalueof{/color cells/max}]
                    {\value}
                    {\pgfkeysvalueof{/pgfplots/colormap name}}%
                % now, \pgfmathresult contains {<R>,<G>,<B>}
                % 
                % acquire the value AFTER any preprocessor or
                % typesetter (like number printer) worked on it:
                \pgfkeysgetvalue{/pgfplots/table/@cell content}\typesetvalue
                \pgfkeysgetvalue{/color cells/textcolor}\textcolorvalue
                %
                % tex-expansion control
                % see https://tex.stackexchange.com/questions/12668/where-do-i-start-latex-programming/27589#27589
                \toks0=\expandafter{\typesetvalue}%
                \xdef\temp{%
                    \noexpand\pgfkeysalso{%
                        @cell content={%
                            \noexpand\cellcolor[rgb]{\pgfmathresult}%
                            \noexpand\definecolor{mapped color}{rgb}{\pgfmathresult}%
                            \ifx\textcolorvalue\empty
                            \else
                                \noexpand\color{\textcolorvalue}%
                            \fi
                            \the\toks0 %
                        }%
                    }%
                }%
                \endgroup
                \temp
                \fi
            }%
        }%
    }
}

\begin{document}

\etoctableofcontents

\part{SOCIOECONOMIC}
\localtableofcontents
\chapter{EDUCATION}

Look the Table \ref{tab:mediatur}.

\begin{table}
\centering
\caption{Average class size - students per class}
\label{tab:mediatur}
\pgfplotstabletypeset[%
    color cells={min=28,max=35, textcolor= - mapped color!100! black},
    /pgfplots/colormap={whiteblue}{rgb255(0cm)=(255,255,255); rgb255(1cm)=(255,50,0)},
%
    col sep=&,
    row sep=\\,
% fix number format
    /pgf/number format/precision=1,
    /pgf/number format/fixed,
    /pgf/number format/fixed zerofill,
    /pgf/number format/set decimal separator = {,},
    columns/EMPTY/.style={
        column name={},
        assign cell content/.code={
            \ifnum\pgfplotstablerow=0
                \pgfkeyssetvalue{/pgfplots/table/@cell content}{\multirow{2}{*}{##1}}%
            \else
                \pgfkeyssetvalue{/pgfplots/table/@cell content}{}%
            \fi},reset styles, string type},
% row formatting
    every row no  0/.style = {before row = \bfseries Kindergarten\\\cmidrule{1-1}},
    every row no  2/.style = {before row = \bfseries Primary Education\\\cmidrule{1-1}},
    every row no 11/.style = {before row = \bfseries High School\\\cmidrule{1-1}},
%
    every head row/.style={before row=\toprule
\multirow{2}{*}{\bfseries Series} & \multicolumn{7}{c}{\bfseries Period}\\\cmidrule{2-8} ,after row=\midrule},
    every last row/.style={after row=\bottomrule},
% columns formatting
    display columns/1/.style={column type = r},%
    display columns/2/.style={column type = r},%
    display columns/3/.style={column type = r},%
    display columns/4/.style={column type = r},%
    display columns/5/.style={column type = r},%
    display columns/6/.style={column type = r},%
    display columns/7/.style={column type = r},%
    display columns/8/.style={column type = r},%
]{
   EMPTY & 2007 & 2008 & 2009 & 2010 & 2011 & 2012 & 2013\\
%Kindergarten &  &  &  &  &  &  &  &  & 
Nursery     & 15.7 & 17.5 & 15.8 & 17.7 & 18.7 & 17.4 & 17.1\\
Pre School & 20.0 & 20.0 & 20.1 & 20.9 & 19.5 & 20.2 & 19.9\\
%Primary Education 8 and 9 years  &  &  &  &  &  &  &  &  & 
 1st year    & 23.6 & 21.9 & 24.4 & 22.1 & 20.7 & 23.5 & 20.4\\
 2nd year    & 21.7 & 23.3 & 26.7 & 23.0 & 22.3 & 24.0 & 22.7\\
 3rd year    & 27.2 & 25.7 & 20.6 & 24.4 & 23.9 & 24.4 & 23.2\\
 4th year    & 24.8 & 24.6 & 24.7 & 24.2 & 24.4 & 23.9 & 24.4\\
 5th year    & 25.4 & 29.0 & 27.7 & 27.1 & 22.3 & 24.1 & 24.1\\
 6th year    & 31.7 & 33.5 & 29.7 & 29.8 & 31.4 & 26.5 & 26.3\\
 7th year    & 32.2 & 32.8 & 33.3 & 30.1 & 29.1 & 29.3 & 25.8\\
 8th year    & 31.3 & 34.2 & 33.1 & 30.8 & 28.9 & 29.6 & 30.3\\
 9th year    & 33.7 & 36.6 & 33.2 & 32.1 & 32.4 & 29.6 & 29.5\\
%High School  &  &  &  &  &  &  &  &  & 
 1st grade  & 39.1 & 38.9 & 36.3 & 34.2 & 32.4 & 35.1 & 31.2\\
 2nd grade  & 33.2 & 34.8 & 28.7 & 32.0 & 30.3 & 25.6 & 26.9\\
 3rd grade  & 29.6 & 30.4 & 29.5 & 28.2 & 29.5 & 28.7 & 27.6\\
 4th grade  &   0  & 28.0 & 23.7 & 18.7 & 20.7 & 24.3 & 17.8\\
}
\end{table}


\appendix

\part*{APPENDICES}

\etoctoccontentsline*{appendixplaceholder}{APPENDIX}{-1}
\etocsettocdepth{chapter}
\renewcommand{\thechapter}{\Alph{chapter}}
\setcounter{chapter}{0} 

\localtableofcontents

\chapter{Document One}
Test 1.

\chapter{Document Two}
Test 2.

\end{document}

我该如何解决?

答案1

问题在于你的

\etoctoccontentsline*{appendixplaceholder}{APPENDIX}{-1}

文档末尾附近。问题很简单,appendixplaceholder代表一些虚拟的分区单元,但尚未声明为etoc。要解决这个问题,您可以添加:

\etocsetlevel{appendixplaceholder}{6} % 6 = invisible

在序言中,然后\localtableofcontents 在附录部分之前,或者更确切地说,在主目录之后,您将插入\etocsetlevel{appendixplaceholder}{-1}。(我犹豫是因为我不确定您想要实现什么;避免Appendix出现在主目录中TOC,但仍然列出两个附录?)

话虽这么说,一个更精简的解决方案是完全忘记这个appendixplaceholder\etoctoccontentsline*业务,然后简单地这样做:

\appendix

\part*{APPENDICES}

\addcontentsline{toc}{part}{APPENDIX}% add unnumbered part to TOC

\etocsettocdepth{chapter}
\renewcommand{\thechapter}{\Alph{chapter}}
\setcounter{chapter}{0} 

\localtableofcontents % works because there is the APPENDIX as part in TOC

这将产生以下全局目录:

带附录的全球目录

以及附录部分的本地文件。hyperref也可以与 loaded 一起使用。

相关内容