我想将树定位在页面的北中心,但出于某种原因,前进的 x 坐标不会改变任何东西。使用相对定位在中node-0
绘制也无济于事。node-0
current page.north
有谁知道这里可能出了什么问题?
\begin{tikzpicture} [
array/.style = {
matrix of nodes,
nodes = { draw, minimum size = 7mm, anchor = center, fill = violet!30 },
nodes in empty cells
},
edge/.style = { -> }
]
\matrix[array] (node-0) at (14, 0) { 0 & 1 & 2 & 3 \\ };
\matrix[array] (node-1) [below left=0.4cm and 0.4cm of node-0] { 0 & 1 & 2 & 3 \\ };
\matrix[array] (node-2) [below right=0.4cm and 0.4cm of node-0] { 0 & 1 & & \\ };
\draw[edge] (node-0-1-1.south) to (node-1.north);
\draw[edge] (node-0-1-2.south) to (node-2.north);
\end{tikzpicture}
答案1
请尝试以下操作
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix, positioning}
\begin{document}
\begin{figure}
\centering
\begin{tikzpicture}[
array/.style = {
matrix of nodes,
nodes = { draw, minimum size = 7mm, anchor = center, fill = violet!30 },
nodes in empty cells
},
edge/.style = { -> }
]
\matrix[array] (node-0) at (14, 0) { 0 & 1 & 2 & 3 \\ };
\matrix[array] (node-1) [below left=0.4cm and 0.4cm of node-0] { 0 & 1 & 2 & 3 \\ };
\matrix[array] (node-2) [below right=0.4cm and 0.4cm of node-0] { 0 & 1 & & \\ };
\draw[edge] (node-0-1-1.south) to (node-1.north);
\draw[edge] (node-0-1-2.south) to (node-2.north);
\end{tikzpicture}
\end{figure}
\end{document}