2

Im new to the tikz package how can I have the arrow closer to the equal sign and can I have it align automatically?

output

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

This can be done using \tikzmarknode from the tikzmark TikZ library. This command creates a TikZ node around basically whatever you want. Here, the equal sign is a good candidate given what you wish to do. The node can be accessed from a tikzpicture that uses the remember picture and overlay options. You need to compile twice because this technique relies on the .aux file.

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

enter image description here

2

For an explanation of the \tikznode command see my answer to "How to add arrow in equations and matrix?".

enter image description here

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

As mentioned in frougon's answer, tikzmark can be used here. However, I think one should also make sure that the annotation does not overlap with the text. So one may want to put the tikzpicture inside the equation, measure the relevant distance and add it.

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.