2

I'm trying to fill some pictures with a background image using path picture as recomended here or here. It works great if I put the style in the cell directly like |[path card]| my content, but it does not compile if I put it inside cells={nodes={path card}}. Any idea what's wrong?

enter image description here

MWE:

\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}

tobiasBora
  • 8,684

1 Answers1

1

You define a style(options) for all nodes, that contain a path picture that contain a node that contain... - problems. Break the infinite recursion with path picture=none (or rather path picture alone to avoid a warning).

\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}

16 rectangles with example image

tobiasBora
  • 8,684
  • path picture=none is not correct after all, as it creates warnings. Just path picture seems to work. – hpekristiansen Dec 07 '21 at 12:52
  • 1
    oh, good point, thanks! I did not realized that the every node would also apply to this node ^^ Thanks! (also, I applied your comment as an edit since it seems to work) – tobiasBora Dec 07 '21 at 13:48