Does someone know how to change this image in a simple way in Tikz?
Asked
Active
Viewed 1,093 times
5
Display Name
- 46,933
6 Answers
8
Well, it might be a duplicate, but here's a quick example anyway, using chains.
\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:
Zarko
- 296,517
-
1Nice! 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 04 '15 at 14:05
-
Thanks a lot all! I accepted your answer, because I think I better understand your code :) – Heinz Doofenschmirtz Nov 04 '15 at 19:46
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}
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}
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}
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
CroCo
- 5,902







\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 04 '15 at 11:58procrastination_team.add("TorbjørnT")– Tom Bombadil Nov 04 '15 at 12:00