배경 이미지(eso-pic) 및 tikz 외부화

배경 이미지(eso-pic) 및 tikz 외부화

다음을 포함하는 문서를 만들려고 합니다.

  • 표지 이미지(참조1이 게시물 아래) package 를 사용하여 배경으로 설정합니다 eso-pic.
  • .\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=\AddToShipoutPictureBG활성화할 때 옵션을 사용할 수 있습니다 \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}

여기에 이미지 설명을 입력하세요

관련 정보