添加间距以避免箭头超出标签

添加间距以避免箭头超出标签

我有以下 MWE

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,calc}

\tikzset{%
    block/.style    = {draw, thick, rectangle, node distance=3em, minimum height = 3em,
        minimum width = 3em, align=center}
}

\begin{document}
\begin{tikzpicture}[auto, thick, >=triangle 45]

\draw node [block] (b) {B};
\draw node [block, above left=of b, label=below:Label] (a) {A};
\draw[->](a) |- (b);

\end{tikzpicture}
\end{document}

以及相应的图像:

在此处输入图片描述

如何减少长度/移动箭头的起点以使其不绘制在标签上方?

答案1

欢迎!您可以给标签命名并连接标签而不是节点。

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,calc}

\tikzset{%
    block/.style    = {draw, thick, rectangle, node distance=3em, minimum height = 3em,
        minimum width = 3em, align=center}
}

\begin{document}
\begin{tikzpicture}[auto, thick, >=triangle 45]

\draw node [block] (b) {B};
\draw node [block, above left=of b, label={[name=aLabel]below:Label}] (a) {A};
\draw[->](aLabel) |- (b);

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

像这样?

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,arrows,positioning,calc}

\tikzset{%
    block/.style    = {draw, thick, rectangle, node distance=3em, minimum height = 3em,
        minimum width = 3em, align=center}
}

\begin{document}
\begin{tikzpicture}[auto, thick, >=triangle 45]

\draw node [block] (b) {B};
\draw node [block, above left=of b] (a) {A};
\draw (a.south) node [below] (a2) {Label};
\draw[->](a2.south) |- (b);

\end{tikzpicture}
\end{document}

相关内容