答案1
你可以通过以下方式实现tikz 混合模式或者,如注释中所述,使用批处理模式下的 imagemagic 等工具(可能将白色背景变成透明背景,以便可以将其插入到任何位置):
\documentclass[]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[blend group=multiply]
\node{\includegraphics[width=8cm]{example-image-a}};
\node{\includegraphics[width=5cm]{example.png}};
\end{tikzpicture}
\end{document}
编辑
您还可以使用blend mode
Instead ofblend group
使其与文档的其余部分交互,但文档指出某些渲染器无法使其正常工作。至少在 Okular 中它似乎有效。如果您想要一个独立于后端的解决方案,您还可以使用path picture
order 将背景复制到新节点:
\documentclass[]{article}
\usepackage{eso-pic,graphicx}
\usepackage{tikz}
\AddToHook{shipout/background}{%
A
% \begin{tikzpicture}[remember picture, overlay]
% \node[anchor=center] at (current page.center) {
% \includegraphics[width=\paperwidth,height=\paperheight]{#1}
% };
% \end{tikzpicture}
}
\begin{document}
\begin{tikzpicture}[remember picture, overlay]
\node[anchor=center] at (current page.center) {
\includegraphics[width=\paperwidth,height=\paperheight]{example-image}
};
\end{tikzpicture}
Hey I am some text, see how the image blends? Note however that according to the Tikz documentation, some renderer might fail to render this properly:
\vspace{-2cm}
\begin{tikzpicture}[blend mode=multiply]
% \node{\includegraphics[width=8cm]{example-image-a}};
\node{\includegraphics[width=5cm]{example.png}};
\end{tikzpicture}
More safe (renderer independent), but will not work nicely with the background:
Hey I am some text, see how the image blends? Note however that according to the Tikz documentation, it
\vspace{-1cm}
\begin{tikzpicture}[blend group=multiply]
% \node{\includegraphics[width=8cm]{example-image-a}};
\node{\includegraphics[width=5cm]{example.png}};
\end{tikzpicture}
With a background picture:
\begin{tikzpicture}[blend group=multiply]
\node{\includegraphics[width=8cm]{example-image-a}};
\node{\includegraphics[width=5cm]{example.png}};
\end{tikzpicture}
With path picture (renderer independent, but a bit more annoying to use, possibly a bit less reliable (we are drawing the background twice in the internal node), and it would not overlay with text that is outside of the picture):
\tikzset{
%% WARNING: make sure to use "remember picture"
absolute fill with image/.style={
path picture={
\node[anchor=center] at (current page.center) {
\includegraphics[width=\paperwidth,height=\paperheight]{#1}};
}
},
}
\begin{tikzpicture}[remember picture]
\begin{scope}[transparency group]
\node[absolute fill with image=example-image]{\phantom{\includegraphics[width=5cm]{example.png}}};
\begin{scope}[blend mode=multiply]
\node{\includegraphics[width=5cm]{example.png}};
\end{scope}
\end{scope}
\end{tikzpicture}
\end{document}