TikZ 矩形分割和边缘

TikZ 矩形分割和边缘

这是我第一次在这个网站上发帖

所以我有以下代码:

 \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
  \begin{centering}
    \begin{tikzpicture}[->, >=stealth',shorten >=1pt,auto, main node/.style={rectangle,fill=lightgray!10,draw, minimum size=1cm, minimum width=2.875cm, minimum height=1cm, node distance=5cm}, t_object node/.style={circle,fill=lightgray!10, draw, node distance=2cm}]

      \node[main node, rectangle split, rectangle split parts=4] (t_object)
      at (0,0) {\quad \ Object $o_{1}$ \nodepart{second}\quad Old Versions$_{}$
        \nodepart{third} \quad Latest Version$_{}$
      \nodepart{fourth}\quad Lock};

           % object O1
      \node[t_object node] (O1_0) [right of=t_object, above of=t_object, node distance=4cm] {$v: 5$};
      \node[t_object node] (O1_1) [below of=O1_0] {$v: 11$};
      \node[t_object node] (O1_2) [below of=O1_1] {$v: 13$};
      \node[t_object node] (O1_3) [below of=O1_2] {$v: 29$};

      \path (t_object.second) edge [dashed] node [above, sloped, ->] {} (O1_0);
      \path (t_object.second) edge [dashed] node [above, sloped, ->] {} (O1_1);
      \path (t_object.second) edge [dashed] node [above, sloped, ->] {} (O1_2);
      \path (t_object.third) edge node [above, sloped, ->] {} (O1_3);


      %\path (C) edge node[below, sloped, ->] {} (O1_1);
      %\path (B) edge node[below, sloped, ->] {} (O1_0);

    \end{tikzpicture}
  \end{centering}
\end{figure}




\end{document}

这将创建:

在此处输入图片描述

当然,这不是我想要做的,我希望箭头从矩形的右侧开始,而不是左侧。

有什么想法可以做到吗?

答案1

你可以使用

\path (t_object.second east) edge [d...

这使

在此处输入图片描述

 \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}

\begin{document}

\begin{figure}
  \begin{centering}
    \begin{tikzpicture}[->, >=stealth',shorten >=1pt,auto, main node/.style={rectangle,fill=lightgray!10,draw, minimum size=1cm, minimum width=2.875cm, minimum height=1cm, node distance=5cm}, t_object node/.style={circle,fill=lightgray!10, draw, node distance=2cm}]

      \node[main node, rectangle split, rectangle split parts=4] (t_object)
      at (0,0) {\quad \ Object $o_{1}$ \nodepart{second}\quad Old Versions$_{}$
        \nodepart{third} \quad Latest Version$_{}$
      \nodepart{fourth}\quad Lock};

           % object O1
      \node[t_object node] (O1_0) [right of=t_object, above of=t_object, node distance=4cm] {$v: 5$};
      \node[t_object node] (O1_1) [below of=O1_0] {$v: 11$};
      \node[t_object node] (O1_2) [below of=O1_1] {$v: 13$};
      \node[t_object node] (O1_3) [below of=O1_2] {$v: 29$};

      \path (t_object.second east) edge [dashed] node [above, sloped, ->] {} (O1_0);
      \path (t_object.second east) edge [dashed] node [above, sloped, ->] {} (O1_1);
      \path (t_object.second east) edge [dashed] node [above, sloped, ->] {} (O1_2);
      \path (t_object.third east) edge node [above, sloped, ->] {} (O1_3);


      %\path (C) edge node[below, sloped, ->] {} (O1_1);
      %\path (B) edge node[below, sloped, ->] {} (O1_0);

    \end{tikzpicture}
  \end{centering}
\end{figure}




\end{document}

相关内容