Metropolis beamer 主题和 TikZ 外部化在更改后无法正确重置字体颜色

Metropolis beamer 主题和 TikZ 外部化在更改后无法正确重置字体颜色

使用metropolis beamer主题时,我遇到一个问题,一旦tikzpicture外部化,字体颜色就会恢复为黑色而不是metropolis灰色的默认颜色,如下图所示。

我尝试过lualatexpdflatex(使用--shell-escape),并且我的安装从存储库中是最新的MiKTeX

当然,手动恢复颜色到原来的灰色也是可以的,但是对于复杂的图片来说,这太麻烦了。有没有办法自动恢复成灰色?

梅威瑟:

\documentclass{beamer}
\usetheme{metropolis}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize

\begin{document}

    \begin{frame}

        \centering

        Externalization {\color{red}OFF} \tikzexternaldisable
        \medskip

        \begin{tikzpicture}
            \node at (0,0) {this is gray};
            \node at (0,-0.5) {{\color{blue}this is blue} and this is gray};
        \end{tikzpicture}

        \bigskip

        Externalization {\color{green}ON} \tikzexternalenable
        \medskip

        \begin{tikzpicture}
            \node at (0,0) {this is gray};
            \node at (0,-0.5) {{\color{blue}this is blue} but this is black!};
        \end{tikzpicture}

    \end{frame}

\end{document}

图片显示错误的颜色

答案1

您可以在图片开头添加 \normalcolor 命令:(我使用棕色以获得更好的可见性)

\documentclass{beamer}
\usetheme{metropolis}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize
\tikzifexternalizing{\tikzset{every picture/.style={execute at begin picture = {\normalcolor}}}}{}

\setbeamercolor{normal text}{fg=brown} % for visibility
\begin{document}

    \begin{frame}

        \centering

        Externalization {\color{red}OFF} \tikzexternaldisable
        \medskip

        \begin{tikzpicture}\draw(0,0)--++(1,1);
            \node at (0,0) {this is gray};
            \node at (0,-0.5) {{\color{blue}this is blue} and this is gray};
        \end{tikzpicture}

        \bigskip
\tikzset{external/force remake} %for the test force remake
        Externalization {\color{green}ON} \tikzexternalenable
        \medskip

        \begin{tikzpicture}\draw(0,0)--++(1,1);
            \node at (0,0) {this is gray};
            \node at (0,-0.5) {{\color{blue}this is blue} but this is black!};
        \end{tikzpicture}

    \end{frame}

\end{document}

在此处输入图片描述

相关内容