有什么方法可以修改此示例,以便“嘿!”行在其节点边界的边缘停止?(或者至少停止绘制距其最终位置一段距离的距离)我知道我可以使用,fill
但在这种情况下我不想使用。
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning}
\begin{document}
\begin{tikzpicture}[node distance=2cm,>=latex, every node/.style={
font=\sffamily\scriptsize
},
circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt}
]
{
\node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5](C){}(B);
\draw[-] (C) --++(1,1) node[draw, inner sep=1pt]{Hey!};
}
\end{tikzpicture}
\end{document}
答案1
参考:
代码
\documentclass[tikz]{standalone}
\usetikzlibrary{positioning,backgrounds,calc}
\newcommand*\mydrawing{%
% \node[rectangle, fill=green!10!white!90!black, minimum width=6cm, minimum height=3cm] at (2,0){};
\node[circtext, left, fill=yellow](A) at (0,0) {A};
\node[circtext, fill=yellow, right=of A](B){B};
\draw[->] (A) -- node[dot, pos=0.5](C){}(B);}
\tikzset{every picture/.append style={execute at begin picture=\mydrawing, node distance=2cm, >=latex,
every node/.style={font=\sffamily\scriptsize},
circtext/.style={draw,circle,minimum size=8pt,inner sep=2pt},
dot/.style={draw,circle,fill=black,minimum size=0.6mm,inner sep=0pt},
gridded}}
\begin{document}
\tikz\draw (C) --++(1,1) node[draw, inner sep=1pt]{Hey!};
\tikz\node[inner sep=1pt, draw] at ([shift={(1,1)}]C) {Hey!} edge (C);
\tikz\node[inner sep=1pt, draw] at ($(C)+(1,1)$) {Hey!} edge (C);
\tikz\node[inner sep=1pt, draw, above right=1 and 1 of C] {Hey!} edge (C);
\tikz[on grid]\node[inner sep=1pt, draw, above right=1 and 1 of C] {Hey!} edge (C);
\tikz\path (C) ++(1,1) node[draw, inner sep=1pt] {Hey!} edge (C);
\tikz\path[pin distance=1cm] (C)
[late options={pin={[draw, inner sep=1pt, pin edge={thin,black}]above right:Hey!}}];
\tikz\path[every pin edge/.style={thin,black}, pin distance=1cm] (C)
[late options={pin={[draw, inner sep=1pt]above right:Hey!}}];
% This is the same as saying \node[pin=…] (C) {};
\end{document}