\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
\Large
\tikzmarknode[inner sep=2pt,draw,rounded corners]{surname}{Kennedy} was killed by Lee Harvey Oswald
the sniper.
\vspace{5pt}
\begin{tikzpicture}[remember picture, overlay]
\draw[blue,thick,->](surname.south west) --++ (-1,-0) --++(0,-1) node [below, draw, anchor=north west, xshift=-2cm]{\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}
在此代码中,路径连接到节点的西南角。但是当我创建节点时rounded corners
,路径没有连接到角落:
这个问题最接近的解决方案是如何将 tikz 节点放在圆角上?但它没有回答将路径连接到圆角的问题。
如何将路径连接到这个圆角节点的角落?
答案1
默认rounded corner
值为4pt
,因此只需沿对角线一半即可连接到边框。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\begin{document}
\Large
\tikzmarknode[inner sep=2pt, draw, rounded corners]{surname}{Kennedy} was killed by Lee Harvey Oswald
the sniper.
\vspace{5pt}
\begin{tikzpicture}[remember picture, overlay]
\draw[blue, thick, ->] ([shift={(45:2pt)}]surname.south west) -- (surname.south west) --++ (-1,-0) --++(0,-1) node [below, draw, anchor=north west, xshift=-2cm]{\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}
答案2
改编
- 我用了这个答案您的链接问题:
([xshift=0.293*\rndc, yshift=0.293*\rndc] surname.south west)
- 利用
-|
连接
结果
代码
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\def\rndc{4pt}
\begin{document}
\Large
\tikzmarknode[inner sep=2pt,draw,rounded corners=\rndc]{surname}{Kennedy} was killed by Lee Harvey Oswald the sniper.
\vspace{5pt}
\begin{tikzpicture}[remember picture, overlay]
\draw[blue,thick,->]
([xshift=0.293*\rndc, yshift=0.293*\rndc] surname.south west)
-- (surname.south west)
-|++(-1,-1) node [below, draw, anchor=north west, xshift=-2cm]{%
\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}