3

I just upgraded from fedora version 32 to version 33. Tikz has therefore been updated (from the 3.1.4b to 3.1.5b). Since this change, this figure no longer compiles (I uses Lualatex) :

\documentclass{minimal}

\usepackage[french]{babel}

\usepackage{xcolor}
\definecolor{RdBu-9-1}{RGB}{178,24,43}
\definecolor{RdBu-9-2}{RGB}{214,96,77}
\definecolor{RdBu-9-8}{RGB}{67,147,195}
\definecolor{RdBu-9-9}{RGB}{33,102,172}

\usepackage{tikz}  
\usetikzlibrary{patterns}
\usetikzlibrary{fadings}
\usetikzlibrary{calc}
\usetikzlibrary{positioning}
\usetikzlibrary{arrows}
\usetikzlibrary{matrix}
\usetikzlibrary{decorations.pathreplacing}

\tikzset{%
  ffa/.style={%
    pattern=north west lines,
    pattern color=RdBu-9-2, 
    draw=none
  },
  ffc/.style={%
    draw=RdBu-9-1, 
    line width=1}
}

\usepackage[babel, autostyle]{csquotes}

\begin{document}

\begin{tikzpicture}
  \matrix [matrix of nodes,
  anchor=west,
  nodes={minimum size=.75cm}
  ] (zla0) at (0,0)
  {
    \draw[ffa,ffc] (0,0) circle (.3cm);&
    \draw[ffa,ffc] (0,0) circle (.3cm);\\
  };

  \matrix [matrix of nodes,
  anchor=north,
  nodes={minimum size=.75cm},
  below=2cm of zla0] (zlb0)
  {
    \draw[ffa,ffc] (0,0) circle (.3cm);\\
  };

  \foreach \m in {0} {
    \draw (zla\m.south west) |- ($(zla\m.south west)!0.5!(zla\m.south
    east) + (0,-.1)$) -| (zla\m.south east)  node[pos=0, yshift=.2]
    (zla\m-g) {};
    % 
    \draw (zlb\m.north west) |- ($(zlb\m.north west)!0.5!(zlb\m.north
    east) + (0,.1)$) -| (zlb\m.north east)  node[pos=0, yshift=.2]
    (zlb\m-g) {};
    % 
    \draw[->>, black,] ([yshift=-.2cm]zla\m.south) -- ([yshift=.2cm]zlb\m.north);
  }

  \draw[|-, black] ([yshift=1.25cm]zla0-1-2.north) -- (zla0-1-2.north)
  node[pos=.6,fill=white, minimum size=.75cm]{};

  \node[above=0cm of zla0-1-1.north, anchor=south, align=center,
  font=\tiny, text width=1.75cm]{\enquote{Je suis proche du \emph{Pic
        Jean Ray}}};

  \node[above=1.25cm of zla0-1-2.north, anchor=south, align=center,
  font=\tiny, text width=1.75cm]{\enquote{Je suis sous une \emph{crête}}};

  \node[below=0cm of zlb0.south, anchor=north, align=center,
  font=\tiny, text width=4cm]{\enquote{Je suis proche du \emph{Pic
        Jean Ray} et sous une crête}};

  \node[fill=white,align=center, font=\large\sffamily] at ($(zla0.south east)!0.5!(zlb0.north
  west)$){\emph{Fusion} des \emph{indices de localisation}};
\end{tikzpicture}

\end{document}

At compilation I get errors like :

ERROR: Package pgf Error: No shape named `zla0-1-2' is known.

By searching in the tikz repository I have identified the problem: the cells of a matrix of nodes that contain a \path derivative (like \draw) are directly treated and not added to a node (source). But I haven't found out why this code, which worked on ferora 32, doesn't work anymore (I couldn't find any information in the tikz changelog or anything else).

What is the best solution to make this figure work again? Knowing that I have several figures that are built on this scheme (this one is the simplest, for the example) and that I have few time to make these modifications.

The best would be if there was an option to switch to the old way of working, but I haven't found anything similar in the documentation.

Ps : I have ask the same question in french here, if I have an answer there I would post here and vice versa.

3
  • 1
    This different-from-document behavior was introduced by b9750809 and restored by 5e2f4a88, and the influenced tikz releases are 3.1.2 to 3.1.4b (inclusive). Nov 5, 2020 at 12:40
  • 1
    Though nesting tikzpicture is not officially supported, adding \tikz before every \draw used in matrix cells seems to work. BTW, to make \tiny defined, you need, for example, document class article. Nov 5, 2020 at 20:45
  • Indeed my minimal example is too minimal. In the whole document I uses the scrbook class with some customizations. I tried to add the tikz command before each draw and it works very well, thanks. The result is not exactly the same (the rows are a bit thicker), but this is not a problem.
    – Atm
    Nov 6, 2020 at 10:30

1 Answer 1

2

Cells in TikZ matrices that aren't just a node don't have name. (Even nodes that are put in cells of matrix of nodes with \node don't have a name unless you give them one.)

Besides using actual nodes like that

\matrix [
  matrix of nodes,
  anchor=west,
  nodes in empty cells,
  nodes={ffa, ffc, circle, minimum size=.6cm}
] (zla0) at (0,0) { & \\};

which would put the same circle into the cell as your \draw you can let TikZ install a tight rectangular node around each cell's bounding box. You still won't be able to reference the actual elements inside the cell, of course. (Unless they're nodes and you give them names.)

The install fitted node at end cell key will install the necessary \node at the end of every cell. The \path[every node/.code] part makes sure we don't inherit any styles from the every node key. These nodes are named <matrix name>-<row>-<column>' (note the ') so that there's no conflict with actual nodes in a matrix of node.

I've also tried giving the current bounding box an alias or install a local bounding box for every cell but these all need more work because actual nodes (that shall be used later) need to be installed in a special matrix hook so that their position is known after the matrix – and even then the line-width wasn't considered.

Code

\documentclass[tikz]{standalone}
\usepackage[french]{babel}
\definecolor{RdBu-9-1}{RGB}{178,24,43}
\definecolor{RdBu-9-2}{RGB}{214,96,77}
\definecolor{RdBu-9-8}{RGB}{67,147,195}
\definecolor{RdBu-9-9}{RGB}{33,102,172}
\usetikzlibrary{patterns, calc, positioning, arrows, matrix, fit}
\tikzset{% This is the new key.
  install fitted node at end cell/.style={
    execute at end cell={%
      \path[every node/.code=] node[shape=rectangle, fit=(current bounding box),
        inner sep=+0pt, minimum size=+0pt, outer sep=+0pt, name=\tikzmatrixname-%
          \the\pgfmatrixcurrentrow-\the\pgfmatrixcurrentcolumn']{};}}}
\tikzset{
  ffa/.style={pattern=north west lines, pattern color=RdBu-9-2,  draw=none},
  ffc/.style={draw=RdBu-9-1, line width=1}}
\usepackage[babel, autostyle]{csquotes}

\begin{document}
\begin{tikzpicture}[radius=.3cm]
\matrix [
  install fitted node at end cell, % ← Here's the new key used.
  anchor=west] (zla0) at (0,0) {
  \draw[ffa,ffc] (0,0) circle []; &
  \draw[ffa,ffc] (0,0) circle []; \\};
\matrix [below=2cm of zla0] (zlb0) {\draw[ffa,ffc] (0,0) circle [];\\};
\foreach \m in {0} {
  \draw (zla\m.south west)
    |- ($(zla\m.south west)!0.5!(zla\m.south east) + (0,-.1)$)
    -| (zla\m.south east) node[pos=0, yshift=.2] (zla\m-g) {};
  \draw (zlb\m.north west)
    |- ($(zlb\m.north west)!0.5!(zlb\m.north east) + (0,.1)$)
    -| (zlb\m.north east)  node[pos=0, yshift=.2] (zlb\m-g) {};
  \draw[->>, black,] ([yshift=-.2cm]zla\m.south) -- ([yshift=.2cm]zlb\m.north);
}
\draw[|-, black] ([yshift=1.25cm]zla0-1-2'.north) -- (zla0-1-2')
  node[pos=.6,fill=white, minimum size=.75cm]{};
\node[above=0cm of zla0-1-1'.north, anchor=south, align=center, font=\tiny,
  text width=1.75cm]{\enquote{Je suis proche du \emph{Pic Jean Ray}}};
\node[above=1.25cm of zla0-1-2'.north, anchor=south, align=center, font=\tiny,
  text width=1.75cm]{\enquote{Je suis sous une \emph{crête}}};
\node[below=0cm of zlb0.south, anchor=north, align=center, font=\tiny,
  text width=4cm]{
    \enquote{Je suis proche du \emph{Pic Jean Ray} et sous une crête}};
\node[fill=white, align=center, font=\large\sffamily]
  at ($(zla0.south east)!0.5!(zlb0.north west)$)
  {\emph{Fusion} des \emph{indices de localisation}};
\end{tikzpicture}
\end{document}

Output

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .