-1

How would you write the code for this expression?:

enter image description here

4

I have added some examples - they are not perfect but a start.

% Based on https://tex.stackexchange.com/questions/34452 and https://tex.stackexchange.com/questions/35717
% Remark: Please compile at least 2 times (otherwise the arrow position may be wrong).

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

\newcommand{\tikzmark}[1]{\tikz[overlay,remember picture] \node (#1) {};}

\begin{document}

\begin{equation}
  a\tikzmark{a_mark}x^2 + bx + c = 5\tikzmark{b_mark}x^2 + bx + c.
  \begin{tikzpicture}[
    overlay,
    remember picture,
    out = 315, % degree
    in = 225, % degree
    distance = 5mm,
    ]
    \draw[
        ->,
        red,
        ] (a_mark.center) to (b_mark.center);
  \end{tikzpicture}
\end{equation}

\begin{equation}
  a\tikzmark{a_mark}x^2 + bx + c = 5\tikzmark{b_mark}x^2 + bx + c.
  \begin{tikzpicture}[
    overlay,
    remember picture,
    out = 45, % degree
    in = 135, % degree
    distance = 10mm,
    ]
    \draw[
        ->,
        blue,
        ] (a_mark.center) to (b_mark.center);
  \end{tikzpicture}
\end{equation}

\begin{equation}
  a\tikzmark{a_mark}x^2 + bx + c = 5\tikzmark{b_mark}x^2 + bx + c.
  \begin{tikzpicture}[
    overlay,
    remember picture,
    out = 45, % degree
    in = 135, % degree
    distance = 10mm,
    ]
    \draw[
        ->,
        green,
        shorten > = 15pt,
        shorten < = 15pt,
        ] (a_mark.center) to (b_mark.center);
  \end{tikzpicture}
\end{equation}

\end{document}

enter image description here

Or using tikzmark.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{tikzmark,arrows.meta,bending}
\begin{document}
\[ f(0) = \tikzmarknode{1}{1}
\foreach \X in {2,3,4}
{\;,\quad f(\the\numexpr\X-1)= \tikzmarknode{\X}{\the\numexpr2*\X-1}}
\begin{tikzpicture}[overlay,remember picture]
 \foreach \X [count=\Y] in {2,3,4}
  {\draw[-{Stealth[bend]},red!80!black] (\Y.north east) 
  to[bend left] node[above]{$+2$}
  (\X.north west);}
\end{tikzpicture}\]
\end{document}

enter image description here

| improve this answer | |
  • Thanks, but is different. – Arnold Fernández May 18 at 20:15
  • 2
    @ArnoldFernández As you can see from your negative vote (it wasn't me), your question is maybe not ideal. I strongly suggest, that you read the following link carefully and try to follow the recommendations: tex.meta.stackexchange.com/questions/228. Asking a "good question" is hard work and takes time! – Dr. Manuel Kuehner May 18 at 20:34
  • 2
    I hope you do not mind the edit but my really think one should not define \tikzmark, which is a command of the tikzmark library. Rather, please use the tikzmark library and, in particular, \tikzmarknode. – user194703 May 18 at 21:56
  • 1
    @Schrödinger's cat Thanks! I apparently used a very old question as a template before the library was available. – Dr. Manuel Kuehner May 18 at 22:29
3

A short code with pstricks: each value is made an \rnode, and these nodes are linked by a node connection with the relevant shape (\ncarc) with a label above:

\documentclass[svgnames]{article}
\usepackage{nccmath}

\usepackage{pst-node}

\begin{document}

    \[ f(0) = \rnode{1}{1},\; f(1)= \rnode{2}{3},\; f(2)= \rnode{3}{5},\; f(3)= \rnode{4}{7}
    \psset{linewidth = 0.5pt, arrows=->, arrowinset=0.15, arcangle=45, labelsep=1pt, nodesep=1pt, linecolor=IndianRed}
    \foreach \s/\t in{1/2,2/3,3/4}{\ncarc[offset=2pt]{\s}{\t}\naput{\color{IndianRed}\medmath{+2}}}\]%

\end{document} 

enter image description here

| improve this answer | |
  • Thanks. How would it be with Tikz? – Arnold Fernández May 18 at 21:00
  • I'm sorry, I'm no expert in TiKZ. It certainly is also possible, but probably with a bit longer code. Certainly some of the Tikz specialists will propose a code. – Bernard May 18 at 21:12
  • 2
    @ArnoldFernández No, the code is not longer with TikZ. The converse is true. (I have been using PSTricks for more over a decade and find it not appropriate to claim that the code with TikZ is longer than with PSTricks. In 90% of the cases it is precisely the opposite.) – user194703 May 18 at 21:43
  • 1
    Bernard, how is it possible that, on the one hand, by your own admission you are "no expert on TikZ", but on the other hand you think that the code will be longer? As someone who has used PSTricks over a long time I can tell you that there is absolutely no basis for such claims, and this very example is substantiating the empirical fact that PSTricks is usually longer and, to me more importantly, far less flexible, even if one ignores the fact that you are very restricted in the choice of compilers. The only reason why your code is not excessively long is that you load pgffor. – user194703 May 19 at 1:24
  • Don't fight :). You're both great :). – Dr. Manuel Kuehner May 19 at 9:57

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