\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}