path picture
我正在尝试使用推荐的背景图像填充一些图片这里或者这里。如果我将样式直接放入单元格中,效果很好|[path card]| my content
,但如果我将它放在里面,则无法编译cells={nodes={path card}}
。知道哪里出了问题吗?
梅威瑟:
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{tikz}
\usetikzlibrary{cd,calc,positioning,shadows}
\begin{document}
\tikzset{
path card/.style={
path picture={
\node[] at (path picture bounding box.center) {
\includegraphics[height=3cm]{example-image}};}},
}
{
\begin{tikzcd}[
nodes in empty cells,
column sep=1mm,
row sep=1mm,
cells={
nodes={
inner sep=0pt,
minimum width=3.9mm,
minimum height=6mm,
drop shadow,
draw,
fill=white,
rounded corners=2pt,
anchor=center,
shape=rectangle,
font={\fontsize{4}{12}\selectfont},
%path card, %% <- uncomment this line, everything breaks.
}
},
]
|[path card]| & & [1mm] & \\
& & & \\[1mm]
& & & \\
& & &
\end{tikzcd}
}%
\end{document}
答案1
path picture
您为所有包含包含包含包含...的节点定义样式(选项) - 问题。使用(或单独使用以避免警告)node
中断无限递归。path picture=none
path picture
\documentclass[tikz]{standalone}
\usepackage{graphicx}
\usetikzlibrary{matrix,shadows}
\tikzset{
path card/.style={
path picture={
\node[path picture] at (path picture bounding box.center) {
\includegraphics[height=3cm]{example-image}};}},
}
\begin{document}
\begin{tikzpicture}
\matrix [
matrix of nodes,
nodes in empty cells,
column sep=1mm,
row sep=1mm,
nodes={
inner sep=0pt,
minimum width=3.9mm,
minimum height=6mm,
drop shadow,
draw,
fill=white,
rounded corners=2pt,
anchor=center,
shape=rectangle,
font={\fontsize{4}{12}\selectfont},
path card,
},
]{
& &[1mm] &\\
& & &\\[1mm]
& & &\\
& & &\\
};
\end{tikzpicture}
\end{document}