5

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

enter image description here

  • 2
    Change? Do you have the code for it and want to change it somehow, or do you want to draw it from scratch? If the latter, can you do any part of it yourself? – Torbjørn T. Nov 4 '15 at 11:34
  • It's an image I found, but I don't have the tex-file. I have no idea about how to do it, as for the big arrow, the small arrows can be done with \mapsto. – Heinz Doofenschmirtz Nov 4 '15 at 11:38
  • There have been a lot of questions about that type of arrows, e.g. Is there a TikZ equivalent to the PSTricks \ncbar command? and How to draw a return arrow from node-3 to node-1 – Torbjørn T. Nov 4 '15 at 11:41
  • 1
    Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. As it is, most of our users will be very reluctant to touch your question, and you are left to the mercy of our procrastination team who are very few in number and very picky about selecting questions. You can improve your question by adding a minimal working example (MWE) that more users can copy/paste onto their systems to work on. If no hero takes the challenge we might have to close your question. – Tom Bombadil Nov 4 '15 at 11:58
  • 3
    @TorbjørnT.: to use Python syntax: procrastination_team.add("TorbjørnT") – Tom Bombadil Nov 4 '15 at 12:00
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

  • 1
    Nice! I thought there might be a way of adding the connections automatically in the chain, but I didn't bother reading the manual ... – Torbjørn T. Nov 4 '15 at 14:05
  • Thanks a lot all! I accepted your answer, because I think I better understand your code :) – Heinz Doofenschmirtz Nov 4 '15 at 19:46
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}
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

  • is it a commutative diagram? :) +1 anyway :) – cmhughes Nov 4 '15 at 16:02
  • 1
    @cmhughes I don't know. But it does the job :) – user11232 Nov 5 '15 at 0:49
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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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