TikZ - 带箭头的弧

问题描述

我正在学习 Tikz,希望有人能帮助我实现以下目标,即我想在方程中的对象之间绘制一条有向弧。下面是我想要实现的目标的图片

Arrow in TikZ

我还附上了我目前使用的代码

\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,calc}

\begin{document}
\begin{tikzpicture}
    $(x+2)(x+3)$
\end{tikzpicture}
\end{document}

我还怀疑有一种方法可以在元素之间指定一条线或一条弧线,例如数字和字母,没有明确说明坐标。是这种情况吗?如果是这样,它将简化我想要实现的目标。

非常感谢任何帮助。

解决方法

以下解决方案使用arc在公式上方绘制弧线;可能需要调整实际角度和长度。为了获得相对于公式的坐标,公式被包装到节点 formula 中。

\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,calc}

\begin{document}
\begin{tikzpicture}
    \node (formula) [] {$(x+2)(x+3)$};
    \draw[-latex,red] ($(formula.north west)+(.4,0)$) arc
    [
        start angle=160,end angle=20,x radius=0.5cm,y radius =0.5cm
    ] ;

\end{tikzpicture}
\end{document}

输出:

enter image description here

,

tikzmark 库的另一种可能性:

\documentclass{article}
\usepackage{amsmath,calc}

\begin{document}
\begin{equation}
    (\tikzmarknode{a}{x}+2)(\tikzmarknode{b}{x}+3)
\end{equation}
\tikz[remember picture,overlay]{\draw[-latex,red] ([yshift=0.1em]a.north) to[bend left] ([yshift=0.1em]b.north);}
\end{document}

enter image description here