背景画像(eso-pic)とtikz外部化

背景画像(eso-pic)とtikz外部化

以下の内容を含むドキュメントを作成しようとしています:

  • 表紙画像(1パッケージを使用して背景として設定しますeso-pic
  • を使用して外部化したいくつかの tikz 画像\tikzexternalize[up to date check={md5}]

問題:表紙画像の一部が tikz 画像の背景に含まれています。

外部化を維持しながらこの問題を解決するにはどうすればよいでしょうか?

続くトムの答え:完成したドキュメントでは、\AddToShipoutPictureBGマクロ内を使用しているため、コマンド\tikzset{external/optimize command away=\mymacro}内ではなく、マクロ定義の後に設定する必要がありました\tikzexternalize

% !TeX TXS-program:compile = txs:///lualatex/[--shell-escape]

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{external}
\tikzexternalize[up to date check={md5}]
\usepackage{eso-pic}
\usepackage{graphicx}

\begin{document}
    
    % Add title image across the complete page
    \AddToShipoutPictureBG*{\AtPageLowerLeft{%
            \includegraphics[width=\paperwidth,height=\paperheight]{my_picture.jpg}}}
    \newpage\null\newpage
        
    \tikzsetnextfilename{tikz_picture}
    \begin{tikzpicture}
        \draw[red, thick] (-1,2) -- (2,-4);
        \draw[red, thick] (-1,-1) -- (2,2);
        \filldraw[red] (0,0) circle (2pt) node[anchor=west]{A tikz picture};
    \end{tikzpicture}
        
\end{document}

答え1

optimize command away=\AddToShipoutPictureBGenable の場合、オプションを使用できます\tikzexternalize。コマンドの前にパッケージeso-picをロードする必要があることに注意してください\tikzexternalize

% !TeX TXS-program:compile = txs:///lualatex/[--shell-escape]

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{external}
\usepackage{eso-pic} %%load the 'eso-pic' package before '\tikzexternalize', otherwise the command '\AddToShipoutPictureBG' will not be defined.
\tikzexternalize[
up to date check={md5},
optimize command away=\AddToShipoutPictureBG
]
\usepackage{graphicx}

\begin{document}

    % Add title image across the complete page
    \AddToShipoutPictureBG*{\AtPageLowerLeft{%
            \includegraphics[width=\paperwidth,height=\paperheight]{example-image-a}}}
    \newpage\null\newpage
      
 \tikzsetnextfilename{tikz_picture}

    \begin{tikzpicture}
        \draw[red, thick] (-1,2) -- (2,-4);
        \draw[red, thick] (-1,-1) -- (2,2);
        \filldraw[red] (0,0) circle (2pt) node[anchor=west]{A tikz picture};
    \end{tikzpicture}
        
\end{document}

ここに画像の説明を入力してください

関連情報