我是 tikz 的新用户,在做我真正想做的事情时遇到了很多问题...我必须绘制一个由值参数化的图形。例如,这意味着第二个节点级别的节点数介于 0 和某个值之间。X
因此,我无法绘制完整的图形,但我必须使用\ldots
例如省略某些部分。
为此,我正在使用arrows
tikzautomata
库,但是在第二个节点级别遇到一个问题:我想要绘制的 4 个节点被覆盖了......这里是源代码:
\documentclass{standalone}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,shapes}
\usepackage[latin1]{inputenc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=5cm,sibling distance=50cm,
semithick]
\tikzstyle{every state}=[
rounded rectangle,
fill=red,
draw=none,
text=white,
align=center,
inner sep=1pt,
text width=9.5em,
]
\tikzstyle{kernel} = [
inner sep=1pt,
node font=\itshape \small,
]
\node[state] (A) {$A(0:DIM\_X, 0)$};
\node[state] (B) [below left of=A] {$A(1, 1)$};
\node[state] (C) [below right of= A] {$A(DIM\_X-2, 1)$};
\node[state] (D) [below of=B] {$A(1, 2)$};
\node[state] (E) [right of=D] {$A(2, 2)$};
\node[state] (F) [below of=C] {$A(DIM\_X-2, 2)$};
\node[state] (G) [left of=F] {$A(DIM\_X-3, 2)$};
\path (A) edge node[kernel,swap] {S(1, 1)} (B)
edge node[kernel] {S(DIM\_X-2, 1)} (C)
;
\path (B) edge[-,dotted] (C);
\end{tikzpicture}
\end{document}
谢谢你的帮助:)
答案1
使用positioning
图书馆。
\documentclass{standalone}
\usepackage{pgf}
\usepackage{tikz}
\usetikzlibrary{arrows,automata,shapes,positioning}
\usepackage[latin1]{inputenc}
\begin{document}
\begin{tikzpicture}[->,>=stealth',shorten >=1pt,auto,node distance=5cm,sibling distance=50cm,
semithick]
\tikzstyle{every state}=[
rounded rectangle,
fill=red,
draw=none,
text=white,
align=center,
inner sep=1pt,
text width=9.5em,
]
\tikzstyle{kernel} = [
inner sep=1pt,
node font=\itshape \small,
]
\node[state] (A) {$A(0:DIM\_X, 0)$};
\node[state] (B) [below left=of A] {$A(1, 1)$};
\node[state] (C) [below right=of A] {$A(DIM\_X-2, 1)$};
\node[state] (D) [below=of B] {$A(1, 2)$};
\node[state] (E) [right=of D] {$A(2, 2)$};
\node[state] (F) [below=of C] {$A(DIM\_X-2, 2)$};
\node[state] (G) [left=of F] {$A(DIM\_X-3, 2)$};
\path (A) edge node[kernel,swap] {S(1, 1)} (B)
edge node[kernel] {S(DIM\_X-2, 1)} (C)
;
\path (B) edge[-,dotted] (C);
\end{tikzpicture}
\end{document}