tikz:锚定到矩形分割吗?

tikz:锚定到矩形分割吗?

有没有一种简单的方法可以锚定到矩形分割节点的第二部分的中心?这是我目前正在做的事情:

\documentclass[letterpaper,oneside]{report}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.multipart}
\begin{document}
\begin{tikzpicture}[node distance=5mm,>=stealth',auto]
    \tikzstyle{bucket}=      [rectangle,draw=black!50,fill=black!20,
                              minimum size=5mm,inner sep=0mm]
    \tikzstyle{listitem}=    [rectangle split,rectangle split horizontal,
                              rectangle split parts=2,
                              draw=black!50,fill=black!20,
                              inner sep=0mm,text width=5mm,
                              minimum height=4mm,rectangle split part align=center,
                              rectangle split empty part width=2mm]
    \tikzstyle{every label}= [font=\footnotesize]  

    \node[bucket] (B0) [label=above:$B$,label=left:0] {};
        \draw (B0.south west) -- (B0.north east);
    \node[bucket] (B1) [below of=B0,label=left:1] {};
    \node[listitem] (B1') [right of=B1,node distance=1.5cm] {.13 \nodepart{two}}
        edge [<-] (B1.center);
    \node[listitem](B1'') [right of=B1',node distance=1.5cm] {.16 \nodepart{two}}
        edge [<-] (B1'.two);
        \draw (B1''.two split south) -- (B1''.north east);
\end{tikzpicture}
\end{document} 

这是我最终得到的结果:(好吧,我有一张图片,但不能在这里发布......)

我希望从 B1' 到 B1'' 的箭头从“B1'.two center”开始,但该锚点不存在?我该如何定义它,或者至少如何使用它作为箭头的起点?(查看从 B1 到 B1' 的箭头,了解我希望它看起来的样子)。

感谢大家的帮助!

答案1

那个锚点确实不存在,然而你可以通过取东边和南边的交点来稍微作弊一下,但如果你的线宽不可忽略,那么就需要使用 进行更多的推动[xshift=-\pgflinewidth]

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart,arrows}
\begin{document}
\begin{tikzpicture}[node distance=5mm,>=stealth',auto]
    \tikzstyle{bucket}=      [rectangle,draw=black!50,fill=black!20,
                              minimum size=5mm,inner sep=0mm]
    \tikzstyle{listitem}=    [rectangle split,rectangle split horizontal,
                              rectangle split parts=2,
                              draw=black!50,fill=black!20,
                              inner sep=0mm,text width=5mm,
                              minimum height=4mm,rectangle split part align=center,
                              rectangle split empty part width=2mm]
    \tikzstyle{every label}= [font=\footnotesize]  

    \node[bucket] (B0) [label=above:$B$,label=left:0] {};
        \draw (B0.south west) -- (B0.north east);
    \node[bucket] (B1) [below of=B0,label=left:1] {};
    \node[listitem] (B1') [right of=B1,node distance=1.5cm] {.13 \nodepart{two}} 
        edge [<-] (B1.center);
    \node[listitem](B1'') [right of=B1',node distance=1.5cm] {.16 \nodepart{two}}
        edge [<-] (B1'.two south |- B1'.two east);
        \draw (B1''.two split south) -- (B1''.north east);
\end{tikzpicture}
\end{document} 

在此处输入图片描述

相关内容