使用圆角选项将路径连接到节点的角

使用圆角选项将路径连接到节点的角
\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}

相关内容