我是 tikz 包的新手,我怎样才能让箭头更靠近等号,并能让它自动对齐?
\documentclass{article}
\usepackage{tikz}
\usepackage{amsmath}
\begin{document}
$$\left(\int_{-\infty}^\infty e^{-x^2}\text{d}x\right)^2=\int_{-\infty}^\infty\int_{-\infty}^\infty e^{-x^2-y^2}\text{d}x\text{d}y$$
\hspace{3cm}
\begin{tikzpicture}
\draw[<-](0.9,0.5) -- (0.9,0) -- (0,0) -- (0,-.5) node[anchor=north] {explanation};
\end{tikzpicture}
\end{document}
答案1
这可以\tikzmarknode
通过tikzmark
Ti钾Z 库。此命令创建 Ti钾Z 节点基本上可以随意放置。在这里,等号是一个很好的选择,因为它能满足您的需要。可以tikzpicture
使用remember picture
和overlay
选项从访问节点。您需要编译两次,因为此技术依赖于文件.aux
。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{tikzmark}
% From egreg: https://tex.stackexchange.com/a/84308/73317
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
\[ \left( \int_{-\infty}^{+\infty} e^{-x^2} \diff x \right)^{\!2}
\tikzmarknode{eqsign}{=}
\int_{-\infty}^{+\infty} \!\!\!
\int_{-\infty}^{+\infty} \! e^{-x^2-y^2} \diff x \diff y \]
\begin{tikzpicture}[remember picture, overlay]
\draw[<-] (eqsign) ++ (0,-1ex) -- ++(0,-0.5) -- ++(-0.9,0) -- ++(0,-.5)
node[anchor=north] {explanation};
\end{tikzpicture}
\end{document}
答案2
有关命令的解释,\tikznode
请参阅
我对“如何在方程和矩阵中添加箭头?”的回答。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows} % for arrow tip stealth'xpdf
\newcommand\tikznode[3][]{%
\tikz[remember picture,baseline=(#2.base)]
\node[minimum size=0pt,inner sep=0pt,#1](#2){#3};%
}
\usepackage{amsmath}
\begin{document}
\[\left(\int_{-\infty}^\infty e^{-x^2}\text{d}x\right)^2\mathrel{\tikznode{eq}{$=$}}\int_{-\infty}^\infty\int_{-\infty}^\infty e^{-x^2-y^2}\text{d}x\text{d}y
\]
\begin{tikzpicture}[remember picture,overlay]
\draw[stealth'-,shorten <=2pt,rounded corners]
(eq) |- ++(-0.9,-0.5) -- ++(0,-.5) node[below] {explanation};
\end{tikzpicture}
\end{document}
答案3
正如所提到的frougon 的回答,tikzmark
可以在这里使用。但是,我认为还应确保注释不与文本重叠。因此,可能需要将 放入tikzpicture
方程式中,测量相关距离并将其添加。
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc,tikzmark}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\begin{document}
Some text before the equation.
\[ \left( \,\int\limits_{-\infty}^\infty \mathrm{e}^{-x^2} \diff x \right)^{2}
\tikzmarknode{eqsign}{=}
\int\limits_{-\infty}^\infty \int\limits_{-\infty}^\infty
\mathrm{e}^{-x^2-y^2} \diff x \diff y
\begin{tikzpicture}[remember picture,baseline={(tmp.base)}]
\node(tmp){\vphantom{1}};
\draw[latex-, overlay] (eqsign.south) |- ++(-1,-0.7) -- ++ (0,-0.5)
node[below] (expl) {explanation};
% add point to tikzpicture to make it take the right size, subtract inner sep
\path ([yshift=2pt]expl.south-|tmp);
\end{tikzpicture}
\]
Some more text after the equation.
\end{document}