设置路径连接到 TikZ 中的节点的确切位置

设置路径连接到 TikZ 中的节点的确切位置

我已经用一条路径连接了两个节点:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\tikzmarknode[inner sep=2pt,draw]{surname}{\mbox{Kennedy}} was killed in an assasin.

\vspace{5pt}

\begin{tikzpicture}[remember picture, overlay]
\draw[blue,thick,->](surname.south west) --++ (0,-1)  node [below, draw]{\footnotesize b. May 29, 1917, d. November 22, 1963, often referred to by his initials JFK, 35th president of the USA from 1961 to 1963};
\end{tikzpicture}

\end{document}

在此处输入图片描述

由于路径默认连接到中心节点的上边缘,因此节点的左侧部分超出了页面。为了解决这个问题,我修改了node以下选项:

node [below right=-10pt, draw]
node [below, right=-10pt, draw]
node [below, center=-10pt, draw]

它们都没有帮助(我尝试了不同的选项大约一个小时)我在 TikZ 文档中搜索了该特定信息,但也没有任何帮助。

如何设置路径连接到节点的精确位置,以便节点位于屏幕截图中给出的所需位置?

答案1

您可以使用xshift来移动节点:

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}

\tikzmarknode[inner sep=2pt,draw]{surname}{\mbox{Kennedy}} was killed in an assasin.

\vspace{5pt}

\begin{tikzpicture}[remember picture, overlay]
\draw[blue,thick,->](surname.south west) --++ (0,-1)  node [below, draw,anchor=north west,xshift=-3cm]{\footnotesize b. May 29, 1917, d. November 22, 1963, often referred to by his initials JFK, 35th president of the USA from 1961 to 1963};
\end{tikzpicture}

\end{document}

在此处输入图片描述

相关内容