TikZ - 带箭头的弧线

Dan*_*317 5 latex tikz

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

我还附上了迄今为止我使用过的代码:

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

\begin{document}
\begin{tikzpicture}
    $(x+2)(x+3)$
\end{tikzpicture}
\end{document}
Run Code Online (Sandbox Code Playgroud)

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

任何帮助将非常感激。

jf_*_*jf_ 7

以下解决方案使用以下公式在公式上方绘制圆弧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}
Run Code Online (Sandbox Code Playgroud)

输出:

在此输入图像描述


sam*_*ter 7

图书馆的另一种可能性tikzmark

\documentclass{article}
\usepackage{amsmath,amssymb,braket,tikz}
\usetikzlibrary{tikzmark,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}
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

  • 您可以使用 out/in 选项来更好地控制,而不是使用“to[bend left]”,例如,“to[out=60,in=120]”对我来说看起来不错。 (2认同)