2

I am planning to draw an arrow over the digits like in the figures:

enter image description here enter image description here

So far I tried $\overset{\curvearrowleft}{5}$, but It didn't produce arrows as the figures. I also tried this:

\usepackage{tikz}
\usetikzlibrary{arrows.meta, matrix}
\begin{tikzpicture}
    \matrix[
    matrix of math nodes,
    nodes in empty cells,
    row sep=4pt,
    column sep=4pt,
    ] (mymatr) {
    1& 0 &1 &0 &1 &0 &1& 0& 1\\
    &+&1& 0& 1&0& 1& 0& 1\\
    1& 0 &1 &0& 1& 0& 1& 0& 1\\
    };
    \draw ([yshift=-2pt]mymatr-2-1.south west) -- ([yshift=-2pt]mymatr-2-9.south east);
    \draw[-Latex] (mymatr-1-4.north)  to[in=90, out=90, looseness=2]  node[midway, above, font=\footnotesize]{$1$} (mymatr-1-3.north);
\end{tikzpicture}

This code is burden for whole document. It should be independent of any other nodes/elements of tikz (without mymatr-1-4.north etc.).

I need a single line and short solution to draw the arrow as I have lots of places where the arrows will be drawn in the whole document. That's why I want make it simple, easy to use, inline and also parametric (as you see in the second figure, the number may contain multiple digits).

mmr
  • 2,249
  • 5
  • 22
  • Related: https://tex.stackexchange.com/questions/439929/how-to-get-a-digit-over-curved-arrow-pointing-left-and-right/440088#440088 – mmr Nov 21 '21 at 14:39

1 Answers1

2

Update

screenshoot

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,matrix,arrows.meta,bending}
\begin{document}

%definition of arrow (fleche in fernch) \newcommand{\fleche}[3]{ \draw[-{Latex[flex]}] (#1.north) .. controls ++(0,.25) and ++(0,.25) .. node[midway, above, font=\footnotesize]{$#3$} (#2.north); }

\begin{tikzpicture} \matrix[ matrix of math nodes, nodes in empty cells, row sep=4pt, column sep=4pt, ] (mymatr) { 1& 0 &1 &0 &1 &0 &1& 0& 1\ &+&1& 0& 1&0& 1& 0& 1\ 1& 0 &1 &0& 1& 0& 1& 0& 1\ }; \draw ([yshift=-2pt]mymatr-2-1.south west) -- ([yshift=-2pt]mymatr-2-9.south east); %------ % arrows \fleche{mymatr-1-4}{mymatr-1-3}{$1$} \fleche{mymatr-1-5}{mymatr-1-6}{$2$} \end{tikzpicture} \end{document}

Old answer

Like this? the code is commented

screenshoot

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows.meta,bending}%<- add bending library
\begin{document}

\begin{tikzpicture} \matrix[ matrix of math nodes, nodes in empty cells, row sep=4pt, column sep=4pt, ] (mymatr) { 1& 0 &1 &0 &1 &0 &1& 0& 1\ &+&1& 0& 1&0& 1& 0& 1\ 1& 0 &1 &0& 1& 0& 1& 0& 1\ }; \draw ([yshift=-2pt]mymatr-2-1.south west) -- ([yshift=-2pt]mymatr-2-9.south east); %------------- % add flex option, in= 60, out=120, looseness=1 \draw[-{Latex[flex]}] (mymatr-1-4.north) to[in=60, out=120, looseness=1,] node[midway, above, font=\footnotesize]{$1$} (mymatr-1-3.north); \end{tikzpicture} \end{document}

AndréC
  • 24,137