如何将 tikzpicture 中的箭头指向 LaTex 中的方程式?

如何将 tikzpicture 中的箭头指向 LaTex 中的方程式?

我可以创建这样的页面: 截屏
使用以下代码:

\documentclass{article}


\usepackage{tikz}
\usetikzlibrary{fit, calc} 
\usepackage{fontspec}
\newfontfamily{\myfont}{Arial}
\usepackage{marginnote}
\newcommand\commentary[2]{%
\tikz[remember picture, baseline={(here.base)}] \node (here) {#1};%
\marginpar{
\begin{tikzpicture}[remember picture, overlay]
 \begin{scope}[rotate=(rand*10),shift={(1.8,0)}]
    \node [text width=3cm, align=center, transform shape] (text) at (0, 0)   {\footnotesize \myfont #2};
    \draw [transform shape, thick] plot [smooth, tension=0.8] coordinates {
      ($(text.south) + (-10pt, -5pt) + (rand * 2pt, rand * 2pt)$) 
      ($(text.south east) + (-5pt, 5pt)$)
      ($(text.north east) + (rand * 2pt - 5pt, rand * 2pt)$)
      ($(text.north west) + (rand * 2pt + 5pt, rand * 2pt)$)
      ($(text.south west) + (rand * 2pt + 5pt, rand * 2pt)$)
      ($(text.south) + (10pt, -3pt) + (rand * 2pt, rand * 2pt)$)
    };
\end{scope}
\draw[->, thick] ($(text.south west) - (-10pt, 5pt)$)  to [bend left=20] ($(here.south east) - (3pt, 2pt)$);
\end{tikzpicture}
 }
 }

\begin{document}
 The equation of a plane through $(x_0,y_0,z_0)$ \commentary{is:}{The tangent   plane: $\nabla f(\mathbf{x})\cdot (\mathbf{x}-\mathbf{x}_0)=0$.}
$$a(x-x_0)+b(y-y_0)+c(z-z_0)=0$$
 The vector $(a,b,c)$ is normal to the plane. 


 \end{document}

1)如何将箭头的头部放到等式中(例如,在显示问题中放到 + 号),而不是文本中的单词(而不是此例中的“is :”)?

(2)如何将文本气泡向上或向下移动 1 厘米?

答案1

使用命令

\tikznode[..options..]{..label..}{..contents..}

标记箭头应指向的内容;在你的情况下,等式:

\tikznode{equation}{$a(x-x_0)+b(y-y_0)+c(z-z_0)=0$}

要添加箭头和文本,使用

\begin{tikzpicture}[remember picture,overlay]
  ... tikz code using the label defined by \tikznode ...
\end{tikzpicture}

\tikznode在序言中将命令定义为

\usepackage{tikz}
\newcommand\tikznode[3][]%
   {\tikz[remember picture,baseline=(#2.base)]
      \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
   }

您必须至少运行两次 LaTeX,直到有关位置的信息传播到各处。

为了将椭圆定位在右边框,我们首先计算当前页面上位于右边框左侧 3 厘米处的点

\path let \p1=($(current page.east)-(3,0)$) in

并用它来定义椭圆中心的位置,水平方向与节点位于同一水平equation,且位于下方/上方\p1

(equation-|\p1) node [ellipse,...] (remark) {...};

现在,您可以使用选项将节点向上移动 1 厘米yshift

(equation-|\p1) node [ellipse,yshift=1cm,...] (remark) {...};

在此处输入图片描述

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{shapes,calc}

\newcommand\tikznode[3][]%
   {\tikz[remember picture,baseline=(#2.base)]
      \node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
   }

\begin{document}
The equation of a plane through $(x_0,y_0,z_0)$ is:
\[ \tikznode{equation}{$a(x-x_0)+b(y-y_0)+c(z-z_0)=0$} \]
 The vector $(a,b,c)$ is normal to the plane.

\begin{tikzpicture}[remember picture,overlay]
  \path let \p1=($(current page.east)-(3,0)$) in (equation-|\p1)
    node [ellipse,draw,align=center,rotate=30,yshift=1cm] (remark)
     {The tangent plane:\\
      $\nabla f(\mathbf{x})\cdot (\mathbf{x}-\mathbf{x}_0)=0$.%
     };
  \draw[<-,shorten <=2pt] (equation) to[bend left=10] (remark);
\end{tikzpicture}
\end{document}

相关内容