5

Does someone know how to change this image in a simple way in Tikz?

enter image description here

Display Name
  • 46,933

6 Answers6

8

Well, it might be a duplicate, but here's a quick example anyway, using chains.

enter image description here

\documentclass[border=4mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{chains,arrows.meta}
\begin{document}
\begin{tikzpicture}
\begin{scope}[start chain,node distance=4mm,every node/.append style={on chain}]
\node (x1) {$x_1$};
\node (x2) {$x_2$};
\node (x3) {$x_3$};
\node (dots) {$\dots$};
\node (xk-1) {$x_{k-1}$};
\node (xk) {$x_k$};
\end{scope}
\foreach \n [remember=\n as \lastn (initially x1)] in {x2,x3,dots,xk-1,xk}
  \draw [{Bar[]}->] (\lastn) -- (\n);

\draw [->] (xk) -- ++(0,-0.7cm) -| (x1);
\end{tikzpicture}
\end{document}
Torbjørn T.
  • 206,688
6

Slightly simplified version of the Torbjørn T. answer:

\documentclass[border=4mm,
               tikz]{standalone}
\usetikzlibrary{chains,arrows.meta}

\begin{document}
    \begin{tikzpicture}[
        start chain,
        node distance = 4mm,
    every node/.style = {join=by {Bar[]}->,on chain}
                    ]
\node (first)   {$x_1$};
\node           {$x_2$};
\node           {$x_3$};
\node           {$\dots$};
\node           {$x_{k-1}$};
\node (last)    {$x_k$};
%
\draw [->] (last) -- +(0,-0.8) -| (first);
    \end{tikzpicture}
\end{document}

It gives the same result:

enter image description here

Zarko
  • 296,517
5

With tikz-cd:

\documentclass{article}
\usepackage{tikz-cd}

\begin{document}
\[
\begin{tikzcd}[column sep= small,arrows={mapsto},every matrix/.append style={name=m},
  execute at end picture={
        \draw [->] (m-1-6.south) -- ++(0,-0.7cm) -| (m-1-1.south);
  }]
   x_1 \arrow[r] & x_2 \arrow[r] & x_3 \arrow[r] & \cdots \arrow[r] & x_{k-1} \arrow[r] & x_k
\end{tikzcd}
\]
\end{document}

enter image description here

4

A psmatrix solution:

\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks-add}
\usepackage{auto-pst-pdf}

\begin{document}
\[
  \begin{psmatrix}%
    \rnode{B}{x_1}
    \mapsto x_2\mapsto x_3\mapsto \cdots\mapsto x_{k-1}\mapsto \rnode{E}{x_k }
    \ncbar[linewidth=0.4pt, nodesep=3pt, angle=-90, arrows=-v, arrowscale=0.5 0.3, linejoin=1]{E}{B}
  \end{psmatrix}
\]

\end{document} 

enter image description here

Bernard
  • 271,350
4

Without psmatrix but still using PSTricks.

\documentclass[preview,margin={3pt 12pt 3pt 5pt}]{standalone}
\usepackage{pstricks-add,amsmath}
\begin{document}
$
\displaystyle
    \rnode{B}{x_1}
    \mapsto x_2
    \mapsto x_3
    \mapsto \cdots
    \mapsto x_{k-1}
    \mapsto \rnode{E}{x_k }
    \ncbar[nodesep=3pt,angle=-90,arm=5pt,arrows=-v,arrowscale=.3,linewidth=.4pt]{E}{B}
$
\end{document} 

enter image description here

Display Name
  • 46,933
2

Since you are saying

a simple way in Tikz?

Create one node and draw an arrow from its south east to its south west with some slight shifting. Therefore, the code is

\documentclass[border={2}]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node (A) {$x_{1} \mapsto x_{2} \mapsto x_{3} \mapsto \cdots \mapsto x_{k-1}  \mapsto x_{k}$ };
\draw [->] ([xshift=-8pt] A.south east) -- ++(0,-.3) -|  ([xshift=8pt] A.south west);
%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{tikzpicture}
\end{document}

And the result is

enter image description here

CroCo
  • 5,902