我正在使用此代码
\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
这是因为,如果你想使用externalize
,tcolorbox
你需要采取特别的预防措施。它们并不是专门针对 的tcolorbox
,覆盖层tikzpicture
通常有同样的问题。然而,tcolorbox
在其库中有一个非常好的修复程序external
(你可以在第节中阅读到4.23 外化手册tcolorbox
v4.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}