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} 

在此輸入影像描述

相關內容