pgfplots 冲突

pgfplots 冲突

我正在使用此代码

\documentclass{article}

\usepackage{pgfplots}
\usepgfplotslibrary{external}
\tikzexternalize[prefix=figures/]

\usepackage[theorems,skins]{tcolorbox}
\tcbset{red eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex, 
        left=0.1ex,right=0.1ex,
        overlay={\fill[red!10] (frame.south west) to[bend left] 
            (frame.north west) --  (frame.north east) to[bend left]
            (frame.south east) -- cycle;},
        boxrule=0pt},
    blue eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex, 
        left=0.1ex,right=0.1ex,
        overlay={\fill[blue!10] (frame.south west) to[bend left] 
            (frame.north west) --  (frame.north east) to[bend left]
            (frame.south east) -- cycle;},
        boxrule=0pt},
    highlight math style=red eqbox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

\begin{equation}
    \tcbhighmath{\int x \,e^{-x}\, x}
\end{equation}

\end{document}

它会产生这样的错误:

File ended while scanning use of \tikzexternal@laTeX@collect@until@end@tikzpicture.

但是,如果我注释\tikzexternalize[prefix=figures/]\tcbset{...}命令,文件就会正确编译。

笔记:我已经figures在我的文件旁边创建了文件夹.tex

答案1

这是因为,如果你想使用externalizetcolorbox你需要采取特别的预防措施。它们并不是专门针对 的tcolorbox,覆盖层tikzpicture通常有同样的问题。然而,tcolorbox在其库中有一个非常好的修复程序external(你可以在第节中阅读到4.23 外化手册tcolorboxv4.30 版本):

\tcbset{shield externalize}

你的代码将变成

\documentclass{article}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\usepackage{pgfplots}
\usepgfplotslibrary{external}
\usepackage[theorems,skins,external]{tcolorbox}
\tikzexternalize[prefix=figures/]

\tcbset{shield externalize}
\tcbset{red eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex, 
        left=0.1ex,right=0.1ex,
        overlay={\fill[red!10] (frame.south west) to[bend left] 
            (frame.north west) --  (frame.north east) to[bend left]
            (frame.south east) -- cycle;},
        boxrule=0pt},
    blue eqbox/.style={enhanced,top=0.2ex, bottom=0.2ex, 
        left=0.1ex,right=0.1ex,
        overlay={\fill[blue!10] (frame.south west) to[bend left] 
            (frame.north west) --  (frame.north east) to[bend left]
            (frame.south east) -- cycle;},
        boxrule=0pt},
    highlight math style=red eqbox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\begin{equation}
    \tcbhighmath{\int x \,e^{-x}\,\diff x}
\end{equation}

\end{document}

在此处输入图片描述

相关内容