
我剛從 Fedora 版本 32 升級到版本 33。由於此更改,該圖不再編譯(我使用 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}
在編譯時我收到以下錯誤:
ERROR: Package pgf Error: No shape named `zla0-1-2' is known.
透過在 tikz 儲存庫中搜索,我發現了問題:matrix of nodes
包含\path
導數(如\draw
)的 a 的單元格被直接處理,而不是添加到node
(來源)。但我還沒有找到為什麼這個在 ferora 32 上有效的程式碼不再運作了(我在 tikz 中找不到任何資訊)變更日誌或其他任何東西)。
讓這個數字再次發揮作用的最佳解決方案是什麼?知道我有幾個基於此方案構建的圖形(例如,這是最簡單的)並且我幾乎沒有時間進行這些修改。
最好的是如果有一個選項可以切換到舊的工作方式,但我在文件中沒有找到類似的內容。
PS:我用法語問過同樣的問題這裡,如果我在那裡有答案,我會在這裡發布,反之亦然。
答案1
TikZ 矩陣中的單元格不僅僅是節點,沒有名稱。 (即使是放在matrix of nodes
with單元格中的節點也\node
沒有名稱,除非您給它們一個名稱。)
除了使用這樣的實際節點之外
\matrix [
matrix of nodes,
anchor=west,
nodes in empty cells,
nodes={ffa, ffc, circle, minimum size=.6cm}
] (zla0) at (0,0) { & \\};
這會將與您相同的圓放入單元格中,\draw
您可以讓 TikZ 在每個單元格的邊界框周圍安裝一個緊密的矩形節點。當然,您仍然無法引用儲存格內的實際元素。 (除非它們是節點並且您為它們命名。)
鑰匙將在每個單元的末端install fitted node at end cell
安裝必要的部件。\node
該\path[every node/.code]
部分確保我們不會從every node
鍵繼承任何樣式。這些節點被命名<matrix name>-<row>-<column>'
(注意'
),以便與 中的實際節點不發生衝突matrix of node
。
我還嘗試為每個單元提供current bounding box
別名或安裝別名local bounding box
,但這些都需要更多工作,因為實際節點(稍後將使用)需要安裝在特殊的矩陣掛鉤中,以便在矩陣之後知道它們的位置 -即使如此,也沒有考慮線寬。
程式碼
\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}