我想在矩形旁边放置一个圆圈,使它们的顶线从相同的 y 轴开始。当我尝试时,node.170
如果矩形有多条线,它会发生变化。
○ |--------| ○ |--------|
| Node | |--------|
|--------|
基本代码如下:
\documentclass{article}
\usepackage{tikz} \usetikzlibrary{calc,positioning,shapes.geometric,shapes.symbols,shapes.misc}
\begin{document}
\begin{tikzpicture}[ block/.style={rectangle,draw,text centered,outer sep=0pt,semithick},
circ/.style = {circle,draw,blue,text centered,inner sep=1pt} ]
\node[block] (n1) {Node}; \node[circ,left=1.3mm of n1.170] {1};
\node[block,right =of n1,text width=8mm] (n2) {Node Node};
\node[circ,left=1.3mm of n2.170] {1}; \end{tikzpicture}
\end{document}
想要的输出:
答案1
尝试
编辑:
在图片元素样式的定义现在被认为是OP评论:
\documentclass{article}
\usepackage{tikz} \usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[
node distance = 4.5mm and 12mm, % <---
block/.style = {draw, semithick, align=center, inner sep=3pt},
circ/.style = {circle, draw, blue, inner sep=1pt,
node distance =2pt and 7pt} % 2pt = 3pt (of block) - 1pt (of circle)}
]
\node[block,below] (n1) {Node}; \node[circ,below left=of n1.north west] {1};
\node[block,below] (n2) at (3,0) {Node\\ text}; \node[circ,below left=of n2.north west] {2};
\node[block,below=of n2] (n3) {Node}; \node[circ,below left=of n3.north west] {3};
\end{tikzpicture}
\end{document}
它生产