13

Here's what I have, and I've hand drawn what I seeking:

enter image description here

I'm after (a) a double-ended arrow with the two ends pointing to the numerator and denominator of a fraction under a square root, and (b) an arrow pointing to the double-ended arrow labeled by an \otimes.

I'm typesetting old lecture notes in LaTeX and need to be as accurate as possible, so this is what I need to do. But it doesn't strike as straightforward.

I tried using baseline in tikz, but it didn't come out symmetric, and I wouldn't even know where to begin with the arrow pointing to the double-ended arrow.

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}

\begin{document}

\begin{equation*}
 \sqrt{\frac{N}{p(1-p)}}
\end{equation*}

\end{document}
1
  • 1
    Have a look for tikzmark
    – cmhughes
    Commented Jun 11, 2015 at 7:14

2 Answers 2

15

A solution that uses calc to determine the position of the double arrow:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}[execute at begin node = $\displaystyle, execute at end node   = $]
        \node (eq) {\sqrt{\frac{N}{p(1-p)}}};
        \draw[<->] ($(eq.north east)!.3!(eq.south east)$) to[in=0, out=0,distance=10] node[right] {\leftarrow\otimes} ($(eq.north east)!.7!(eq.south east)$);
    \end{tikzpicture}
\end{document}

enter image description here

Some adjustments to tailor it to your liking:

  • For a longer arrow, change \leftarrow to \longleftarrow
  • You can use colours by adding \color{}
  • The size of the bend of the double arrow is in distance=...
  • The vertical position of the arrowheads of the double arrow are the !.3! and !.7!
  • The horizontal position of the arrowheads of the double arrow can be adjusted by adding -(.4,0).

Example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}

\begin{document}
    \begin{tikzpicture}[execute at begin node = $\displaystyle, execute at end node   = $]
        \node (eq) {\sqrt{\frac{N}{p(1-p)}}};
        \draw[<->,red] ($(eq.north east)!.3!(eq.south east)-(.4,0)$) to[in=0, out=0,distance=20] node[right] {\color{blue}\longleftarrow \color{green}\otimes} ($(eq.north east)!.7!(eq.south east)$);
    \end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    Remarkable! Thanks for this (and thanks to the other answerer). Commented Jun 11, 2015 at 8:10
16

Here is something that should get you started on using tikzmark:

enter image description here

Notes:

  • This does require two runs. First one to determine the locations, and the second to do the drawing.

  • There probably are easier ways to determine the locations.

Code:

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{calc}

\newcommand{\mytikzmark}[1]{\tikz[remember picture] \node[baseline, inner sep=0pt] (#1) {};}

\begin{document}

\begin{equation*}
 \sqrt{\frac{N\mytikzmark{top}}{p(1-p)\mytikzmark{bottom}}}
\end{equation*}
\begin{tikzpicture}[remember picture, overlay]
    \coordinate (Top Start)  at ([yshift=0.25\baselineskip]top -| bottom);
    \coordinate (Bottom End) at ([yshift=0.2\baselineskip]bottom);
    \draw [latex-latex, red, thick] 
            (Top Start) to[out=-5, in=5, distance=0.75cm] 
            (Bottom End);
    \node (MidHeight) at (Top Start |- Bottom End) {};
    \node  at ([shift={(1.5cm,0.5\baselineskip)}]Bottom End) (OTIMES) {$\otimes$};
    \draw [blue, -stealth, thick] (OTIMES) -- ++(-0.8cm,0);
\end{tikzpicture}%
\end{document}
1
  • What a beautiful image!
    – Sigur
    Commented Jun 11, 2015 at 7:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .