如何取得一個節點到另一個節點的相對節點距離?

如何取得一個節點到另一個節點的相對節點距離?

我想畫一個大塊和幾個小塊,它在外面但堅持大塊,如下圖所示。我不知道如何根據大塊的寬度和高度相對設定“節點距離”。請幫忙。

我的輸出:

在此輸入影像描述

我的期望:我希望這兩個塊處於同一地平線,並且小塊將粘附在大塊上。

在此輸入影像描述

\documentclass{article}
\usepackage[a4paper,landscape]{geometry}
\usepackage{fontspec}
\setmainfont[Scale=0.9]{Verdana}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows}
\begin{document}
\pagestyle{empty}

\tikzstyle{big} = [rectangle,draw,fill=blue!20,text width = 5em,text centered,minimum width=6em,minimum height=8em]
\tikzstyle{small} = [rectangle,draw,fill=green!40,text width=0.8em, text centered,minimum height = 1em]

\begin{tikzpicture}
  \node [big] (in1) {1st instance};
  \node [small, above right of=in1] (port1) {1};
\end{tikzpicture}

\end{document}

答案1

你可以使用\node [small, anchor=north west, at=(in1.north east)] (port1) {1};

相關內容