4

I have quite a simple question. I was wondering if it was possible to do something like this in LaTeX:

enter image description here

But formatted a little more nicely.

It doesn't need to be arrows necessarily. Just some form of annotation marker.

Sebastiano
  • 54,118

1 Answers1

5
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark}

\begin{document}
\[
\tikzmarknode{A}{f}(\tikzmarknode{B}{5}) = \tikzmarknode{C}{25}
\begin{tikzpicture}[overlay, remember picture,shorten <=1mm,
                    nodes={inner sep=1pt, align=center, font=\footnotesize}]
\draw (A.south) -- ++ (-1,-1) node[below] {The\\ machine};
\draw (B.south) -- ++ (.2,-1) node[below] {When\\ given 5};
\draw (C.south) -- ++ (.8,-1) node[below] {Gives\\ us 25};
\end{tikzpicture}
\vspace{3ex}
\]
\end{document}

For the following result you need to compile above MWE (Minimal Working Example) at least twice!

enter image description here

Addendum: With red arrows:

enter image description here

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, tikzmark}

\begin{document}
\[
\tikzmarknode{A}{f}(\tikzmarknode{B}{5}) = \tikzmarknode{C}{25}
\begin{tikzpicture}[overlay, remember picture,shorten <=1mm,
                    nodes={inner sep=1pt, align=center, font=\footnotesize},
                    every path/.style = {draw=red, Stealth-}] % <---
\draw (A.south) -- ++ (-1,-1) node[below] {The\\ machine};
\draw (B.south) -- ++ (.2,-1) node[below] {When\\ given 5};
\draw (C.south) -- ++ (.8,-1) node[below] {Gives\\ us 25};
\end{tikzpicture}
\vspace{3ex}
\]
\end{document}
Zarko
  • 296,517