How to draw an diagram with arrows?
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I want to draw the following diagram in LaTeX:
diagrams arrows draw
add a comment |Â
up vote
2
down vote
favorite
I want to draw the following diagram in LaTeX:
diagrams arrows draw
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I want to draw the following diagram in LaTeX:
diagrams arrows draw
I want to draw the following diagram in LaTeX:
diagrams arrows draw
diagrams arrows draw
edited Sep 26 at 17:25
asked Sep 25 at 11:01
Fatma Erol Kaynarca
394
394
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04
add a comment |Â
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04
add a comment |Â
4 Answers
4
active
oldest
votes
up vote
8
down vote
accepted
It's quite easy with tikz-cd
:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a"] ar[rr,bend right,"c"'] & 2 ar[r,"b"] & 3
endtikzcd
enddocument
But, in my humble opinion, I'd vote for picture-mode, for its far more user-friendly syntax:
documentclassarticle
usepackagepict2e
begindocument
setlengthunitlength1cm
beginpicture(2.1,0.75)(0,-0.45)
put(0,0)1
put(0.2,0.1)vector(1,0)0.75
put(0.5,0.15)footnotesize$a$
put(1,0)2
put(1.2,0.1)vector(1,0)0.75
put(1.5,0.15)footnotesize$b$
put(2,0)3
qbezier(0.2,-0.05)(1.05,-0.7)(1.9,-0.05)
put(1.9,-0.05)vector(4,3)0.0001
put(1.0,-0.55)footnotesize$c$
endpicture
enddocument
Update: tikz-cd
solution for the second diagram:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a_1"]
ar[rrrrr,bend right=50,looseness=0.3,"b"']
& 2 ar[r,"a_2"]
& 3 ar[r,"a_3"]
& cdots
ar[r,"a_n-2"] % This arrow isn't in the picture, but I chose to add it. Feel free to remove.
& n-1 ar[r,"a_n-1"]
& n
endtikzcd
enddocument
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician Thetikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;P
â Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
 |Â
show 3 more comments
up vote
8
down vote
For the sake of completeness, here it is a plain TikZ approach
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
draw[->] (1) -- node [midway,above] a (2);
draw[->] (1) to [bend right] node [midway,below]c (3);
draw[->] (2) -- node [midway,above] b (3);
endtikzpicture%
enddocument
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
node (dots) [right=of 3] $cdots$;
node (n1) [right=of dots] $n-1$;
node (n) [right=of n1] $n$;
%
draw[->] (1) -- node [midway,above] $a_1$ (2);
draw[->] (1) to [bend right=15cm] node [midway,below]b (n);
draw[->] (2) -- node [midway,above] $a_2$ (3);
draw[->] (3) -- node [midway,above] $a_3$ (dots);
draw[->] (dots) -- node [midway,above] $a_n-2$ (n1);
draw[->] (n1) -- node [midway,above] $a_n-1$ (n);
endtikzpicture%
enddocument
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
 |Â
show 2 more comments
up vote
4
down vote
A pstricks
solution: the three numbers are defined as nodes, and we link them by node connections.
documentclass[12pt]article
usepackagepst-node, auto-pst-pdf
begindocument
[
Rnode11 hspace3em Rnode22 hspace3em Rnode33
pssetlinewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab
everypsboxscriptstyle
ncline12^ancline23^b
ncarc[arcangle=-30]13_c
]
enddocument
add a comment |Â
up vote
0
down vote
With tikz, it is possible to use the chain
concept of the graphs
library.
chains
are a series of nodes
whose syntax is abbreviated compared to their normal syntax. A chain ends with a semicolon. The nodes and their text are identical by default as in the first figure. Nodes and text are the number 1
, 2
and 3
.
This first figure is composed of 2 chains: the first 1->2->3
and the second which goes directly from 1 to 3.
To add text to the arrow (that is called edge by tikz), simply place the option edge label
or edge label'
depending on whether the text is above or below the arrow. In reality, this places the text to the left or right when walking in the direction of the chain.
In the second example, to avoid having to draw an arrow, we write -!-
instead of ->
(see p 265 of the manual).
To make the node text
different from its name, simply separate the name from the text with a slash. For example : 5/$n-1$
means that node 5
displays the n-1
text.
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs
begindocument
tikz graph[grow right=30mm]
1 ->[edge label=a] 2 ->[edge label=b] 3;
1 -> [bend right,edge label'=c] 3;
;
tikz graph[grow right=20mm]
1 ->[edge label=$a_1$] 2 ->[edge label=$a_2$] 3->[edge label=$a_3$] 4/$cdots$ -!- 5/$n-1$->[edge label=$a_n-1$] n ;
1 -> [bend right,edge label'=b] n;
;
enddocument
Edit:
Using the quotes
library, the syntax for writing labels is even shorter:"a"
instead of edge label=a
"c"'
instead of edge label' =c
You can customize the colors as below:
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs,quotes
begindocument
tikz[thick,gray] graph[grow right=30mm]
1 ->["a"] 2 ->["b"] 3;
1 -> [bend right,"c"'] 3;
;
General case:
smallskip
tikz[thick,every edge/.style=red,draw,every node/.style=blue] graph[grow right=20mm,edge quotes=black,auto]
1 ->["$a_1$"] 2 ->["$a_2$"] 3->["$a_3$"] 4/$cdots$ -!- 5/$n-1$->["$a_n-1$"] n ;
1 -> [bend right,"b"'] n;
;
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
8
down vote
accepted
It's quite easy with tikz-cd
:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a"] ar[rr,bend right,"c"'] & 2 ar[r,"b"] & 3
endtikzcd
enddocument
But, in my humble opinion, I'd vote for picture-mode, for its far more user-friendly syntax:
documentclassarticle
usepackagepict2e
begindocument
setlengthunitlength1cm
beginpicture(2.1,0.75)(0,-0.45)
put(0,0)1
put(0.2,0.1)vector(1,0)0.75
put(0.5,0.15)footnotesize$a$
put(1,0)2
put(1.2,0.1)vector(1,0)0.75
put(1.5,0.15)footnotesize$b$
put(2,0)3
qbezier(0.2,-0.05)(1.05,-0.7)(1.9,-0.05)
put(1.9,-0.05)vector(4,3)0.0001
put(1.0,-0.55)footnotesize$c$
endpicture
enddocument
Update: tikz-cd
solution for the second diagram:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a_1"]
ar[rrrrr,bend right=50,looseness=0.3,"b"']
& 2 ar[r,"a_2"]
& 3 ar[r,"a_3"]
& cdots
ar[r,"a_n-2"] % This arrow isn't in the picture, but I chose to add it. Feel free to remove.
& n-1 ar[r,"a_n-1"]
& n
endtikzcd
enddocument
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician Thetikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;P
â Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
 |Â
show 3 more comments
up vote
8
down vote
accepted
It's quite easy with tikz-cd
:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a"] ar[rr,bend right,"c"'] & 2 ar[r,"b"] & 3
endtikzcd
enddocument
But, in my humble opinion, I'd vote for picture-mode, for its far more user-friendly syntax:
documentclassarticle
usepackagepict2e
begindocument
setlengthunitlength1cm
beginpicture(2.1,0.75)(0,-0.45)
put(0,0)1
put(0.2,0.1)vector(1,0)0.75
put(0.5,0.15)footnotesize$a$
put(1,0)2
put(1.2,0.1)vector(1,0)0.75
put(1.5,0.15)footnotesize$b$
put(2,0)3
qbezier(0.2,-0.05)(1.05,-0.7)(1.9,-0.05)
put(1.9,-0.05)vector(4,3)0.0001
put(1.0,-0.55)footnotesize$c$
endpicture
enddocument
Update: tikz-cd
solution for the second diagram:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a_1"]
ar[rrrrr,bend right=50,looseness=0.3,"b"']
& 2 ar[r,"a_2"]
& 3 ar[r,"a_3"]
& cdots
ar[r,"a_n-2"] % This arrow isn't in the picture, but I chose to add it. Feel free to remove.
& n-1 ar[r,"a_n-1"]
& n
endtikzcd
enddocument
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician Thetikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;P
â Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
 |Â
show 3 more comments
up vote
8
down vote
accepted
up vote
8
down vote
accepted
It's quite easy with tikz-cd
:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a"] ar[rr,bend right,"c"'] & 2 ar[r,"b"] & 3
endtikzcd
enddocument
But, in my humble opinion, I'd vote for picture-mode, for its far more user-friendly syntax:
documentclassarticle
usepackagepict2e
begindocument
setlengthunitlength1cm
beginpicture(2.1,0.75)(0,-0.45)
put(0,0)1
put(0.2,0.1)vector(1,0)0.75
put(0.5,0.15)footnotesize$a$
put(1,0)2
put(1.2,0.1)vector(1,0)0.75
put(1.5,0.15)footnotesize$b$
put(2,0)3
qbezier(0.2,-0.05)(1.05,-0.7)(1.9,-0.05)
put(1.9,-0.05)vector(4,3)0.0001
put(1.0,-0.55)footnotesize$c$
endpicture
enddocument
Update: tikz-cd
solution for the second diagram:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a_1"]
ar[rrrrr,bend right=50,looseness=0.3,"b"']
& 2 ar[r,"a_2"]
& 3 ar[r,"a_3"]
& cdots
ar[r,"a_n-2"] % This arrow isn't in the picture, but I chose to add it. Feel free to remove.
& n-1 ar[r,"a_n-1"]
& n
endtikzcd
enddocument
It's quite easy with tikz-cd
:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a"] ar[rr,bend right,"c"'] & 2 ar[r,"b"] & 3
endtikzcd
enddocument
But, in my humble opinion, I'd vote for picture-mode, for its far more user-friendly syntax:
documentclassarticle
usepackagepict2e
begindocument
setlengthunitlength1cm
beginpicture(2.1,0.75)(0,-0.45)
put(0,0)1
put(0.2,0.1)vector(1,0)0.75
put(0.5,0.15)footnotesize$a$
put(1,0)2
put(1.2,0.1)vector(1,0)0.75
put(1.5,0.15)footnotesize$b$
put(2,0)3
qbezier(0.2,-0.05)(1.05,-0.7)(1.9,-0.05)
put(1.9,-0.05)vector(4,3)0.0001
put(1.0,-0.55)footnotesize$c$
endpicture
enddocument
Update: tikz-cd
solution for the second diagram:
documentclassarticle
usepackagetikz-cd
begindocument
begintikzcd
1 ar[r,"a_1"]
ar[rrrrr,bend right=50,looseness=0.3,"b"']
& 2 ar[r,"a_2"]
& 3 ar[r,"a_3"]
& cdots
ar[r,"a_n-2"] % This arrow isn't in the picture, but I chose to add it. Feel free to remove.
& n-1 ar[r,"a_n-1"]
& n
endtikzcd
enddocument
edited Sep 26 at 18:58
answered Sep 25 at 11:23
Phelype Oleinik
17.5k43771
17.5k43771
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician Thetikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;P
â Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
 |Â
show 3 more comments
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician Thetikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;P
â Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
1
1
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
Actually, it's also very easy with plain TikZ (without tikz-cd), but +1 for picture mode ;)
â TeXnician
Sep 25 at 11:28
@TeXnician The
tikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;Pâ Phelype Oleinik
Sep 25 at 11:42
@TeXnician The
tikz-cd
answer is so that people can't say I posted a picture mode answer just to gain more rep. I honestly don't know why people think that ;Pâ Phelype Oleinik
Sep 25 at 11:42
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
Your first suggestion is very practical but when I get n points (1, 2, 3, ..., n-1, n) I could not print a_1, a_2,...a_n-1 on each arrow and I couldn't print b on below arrow from 1 to n. Can you help me?
â Fatma Erol Kaynarca
Sep 26 at 18:36
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
@FatmaErolKaynarca The first method can certainly be adapted to do what you want. Can you please upload a picture of what you want, I couldn't understand from your description.
â Phelype Oleinik
Sep 26 at 18:40
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
Okay, I am sorry:( I made correction in the first part I asked the question, can you see from there? If you don't see I upload a picture again, thank you:)
â Fatma Erol Kaynarca
Sep 26 at 18:48
 |Â
show 3 more comments
up vote
8
down vote
For the sake of completeness, here it is a plain TikZ approach
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
draw[->] (1) -- node [midway,above] a (2);
draw[->] (1) to [bend right] node [midway,below]c (3);
draw[->] (2) -- node [midway,above] b (3);
endtikzpicture%
enddocument
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
node (dots) [right=of 3] $cdots$;
node (n1) [right=of dots] $n-1$;
node (n) [right=of n1] $n$;
%
draw[->] (1) -- node [midway,above] $a_1$ (2);
draw[->] (1) to [bend right=15cm] node [midway,below]b (n);
draw[->] (2) -- node [midway,above] $a_2$ (3);
draw[->] (3) -- node [midway,above] $a_3$ (dots);
draw[->] (dots) -- node [midway,above] $a_n-2$ (n1);
draw[->] (n1) -- node [midway,above] $a_n-1$ (n);
endtikzpicture%
enddocument
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
 |Â
show 2 more comments
up vote
8
down vote
For the sake of completeness, here it is a plain TikZ approach
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
draw[->] (1) -- node [midway,above] a (2);
draw[->] (1) to [bend right] node [midway,below]c (3);
draw[->] (2) -- node [midway,above] b (3);
endtikzpicture%
enddocument
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
node (dots) [right=of 3] $cdots$;
node (n1) [right=of dots] $n-1$;
node (n) [right=of n1] $n$;
%
draw[->] (1) -- node [midway,above] $a_1$ (2);
draw[->] (1) to [bend right=15cm] node [midway,below]b (n);
draw[->] (2) -- node [midway,above] $a_2$ (3);
draw[->] (3) -- node [midway,above] $a_3$ (dots);
draw[->] (dots) -- node [midway,above] $a_n-2$ (n1);
draw[->] (n1) -- node [midway,above] $a_n-1$ (n);
endtikzpicture%
enddocument
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
 |Â
show 2 more comments
up vote
8
down vote
up vote
8
down vote
For the sake of completeness, here it is a plain TikZ approach
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
draw[->] (1) -- node [midway,above] a (2);
draw[->] (1) to [bend right] node [midway,below]c (3);
draw[->] (2) -- node [midway,above] b (3);
endtikzpicture%
enddocument
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
node (dots) [right=of 3] $cdots$;
node (n1) [right=of dots] $n-1$;
node (n) [right=of n1] $n$;
%
draw[->] (1) -- node [midway,above] $a_1$ (2);
draw[->] (1) to [bend right=15cm] node [midway,below]b (n);
draw[->] (2) -- node [midway,above] $a_2$ (3);
draw[->] (3) -- node [midway,above] $a_3$ (dots);
draw[->] (dots) -- node [midway,above] $a_n-2$ (n1);
draw[->] (n1) -- node [midway,above] $a_n-1$ (n);
endtikzpicture%
enddocument
For the sake of completeness, here it is a plain TikZ approach
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
draw[->] (1) -- node [midway,above] a (2);
draw[->] (1) to [bend right] node [midway,below]c (3);
draw[->] (2) -- node [midway,above] b (3);
endtikzpicture%
enddocument
documentclassarticle
usepackagetikz
usetikzlibrarypositioning
begindocument
begintikzpicture[node distance = 2cm, thick]%
node (1) 1;
node (2) [right=of 1] 2;
node (3) [right=of 2] 3;
node (dots) [right=of 3] $cdots$;
node (n1) [right=of dots] $n-1$;
node (n) [right=of n1] $n$;
%
draw[->] (1) -- node [midway,above] $a_1$ (2);
draw[->] (1) to [bend right=15cm] node [midway,below]b (n);
draw[->] (2) -- node [midway,above] $a_2$ (3);
draw[->] (3) -- node [midway,above] $a_3$ (dots);
draw[->] (dots) -- node [midway,above] $a_n-2$ (n1);
draw[->] (n1) -- node [midway,above] $a_n-1$ (n);
endtikzpicture%
enddocument
edited Sep 26 at 19:15
answered Sep 25 at 11:47
Diaa
2,34511643
2,34511643
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
 |Â
show 2 more comments
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
I can't print letters indexed on arrows ?
â Fatma Erol Kaynarca
Sep 26 at 17:24
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
@FatmaErolKaynarca could you explain more? Doesn't my code work with you?
â Diaa
Sep 26 at 18:58
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
Your typed code works very well, but I wanted to do something else, I couldn't fit what I wanted to do with your code.
â Fatma Erol Kaynarca
Sep 26 at 19:02
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
@FatmaErolKaynarca does my answer update get what you want?
â Diaa
Sep 26 at 19:16
1
1
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
Thank you very much
â Fatma Erol Kaynarca
Sep 26 at 19:29
 |Â
show 2 more comments
up vote
4
down vote
A pstricks
solution: the three numbers are defined as nodes, and we link them by node connections.
documentclass[12pt]article
usepackagepst-node, auto-pst-pdf
begindocument
[
Rnode11 hspace3em Rnode22 hspace3em Rnode33
pssetlinewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab
everypsboxscriptstyle
ncline12^ancline23^b
ncarc[arcangle=-30]13_c
]
enddocument
add a comment |Â
up vote
4
down vote
A pstricks
solution: the three numbers are defined as nodes, and we link them by node connections.
documentclass[12pt]article
usepackagepst-node, auto-pst-pdf
begindocument
[
Rnode11 hspace3em Rnode22 hspace3em Rnode33
pssetlinewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab
everypsboxscriptstyle
ncline12^ancline23^b
ncarc[arcangle=-30]13_c
]
enddocument
add a comment |Â
up vote
4
down vote
up vote
4
down vote
A pstricks
solution: the three numbers are defined as nodes, and we link them by node connections.
documentclass[12pt]article
usepackagepst-node, auto-pst-pdf
begindocument
[
Rnode11 hspace3em Rnode22 hspace3em Rnode33
pssetlinewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab
everypsboxscriptstyle
ncline12^ancline23^b
ncarc[arcangle=-30]13_c
]
enddocument
A pstricks
solution: the three numbers are defined as nodes, and we link them by node connections.
documentclass[12pt]article
usepackagepst-node, auto-pst-pdf
begindocument
[
Rnode11 hspace3em Rnode22 hspace3em Rnode33
pssetlinewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab
everypsboxscriptstyle
ncline12^ancline23^b
ncarc[arcangle=-30]13_c
]
enddocument
edited Sep 25 at 12:17
Phelype Oleinik
17.5k43771
17.5k43771
answered Sep 25 at 12:07
Bernard
157k764190
157k764190
add a comment |Â
add a comment |Â
up vote
0
down vote
With tikz, it is possible to use the chain
concept of the graphs
library.
chains
are a series of nodes
whose syntax is abbreviated compared to their normal syntax. A chain ends with a semicolon. The nodes and their text are identical by default as in the first figure. Nodes and text are the number 1
, 2
and 3
.
This first figure is composed of 2 chains: the first 1->2->3
and the second which goes directly from 1 to 3.
To add text to the arrow (that is called edge by tikz), simply place the option edge label
or edge label'
depending on whether the text is above or below the arrow. In reality, this places the text to the left or right when walking in the direction of the chain.
In the second example, to avoid having to draw an arrow, we write -!-
instead of ->
(see p 265 of the manual).
To make the node text
different from its name, simply separate the name from the text with a slash. For example : 5/$n-1$
means that node 5
displays the n-1
text.
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs
begindocument
tikz graph[grow right=30mm]
1 ->[edge label=a] 2 ->[edge label=b] 3;
1 -> [bend right,edge label'=c] 3;
;
tikz graph[grow right=20mm]
1 ->[edge label=$a_1$] 2 ->[edge label=$a_2$] 3->[edge label=$a_3$] 4/$cdots$ -!- 5/$n-1$->[edge label=$a_n-1$] n ;
1 -> [bend right,edge label'=b] n;
;
enddocument
Edit:
Using the quotes
library, the syntax for writing labels is even shorter:"a"
instead of edge label=a
"c"'
instead of edge label' =c
You can customize the colors as below:
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs,quotes
begindocument
tikz[thick,gray] graph[grow right=30mm]
1 ->["a"] 2 ->["b"] 3;
1 -> [bend right,"c"'] 3;
;
General case:
smallskip
tikz[thick,every edge/.style=red,draw,every node/.style=blue] graph[grow right=20mm,edge quotes=black,auto]
1 ->["$a_1$"] 2 ->["$a_2$"] 3->["$a_3$"] 4/$cdots$ -!- 5/$n-1$->["$a_n-1$"] n ;
1 -> [bend right,"b"'] n;
;
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
up vote
0
down vote
With tikz, it is possible to use the chain
concept of the graphs
library.
chains
are a series of nodes
whose syntax is abbreviated compared to their normal syntax. A chain ends with a semicolon. The nodes and their text are identical by default as in the first figure. Nodes and text are the number 1
, 2
and 3
.
This first figure is composed of 2 chains: the first 1->2->3
and the second which goes directly from 1 to 3.
To add text to the arrow (that is called edge by tikz), simply place the option edge label
or edge label'
depending on whether the text is above or below the arrow. In reality, this places the text to the left or right when walking in the direction of the chain.
In the second example, to avoid having to draw an arrow, we write -!-
instead of ->
(see p 265 of the manual).
To make the node text
different from its name, simply separate the name from the text with a slash. For example : 5/$n-1$
means that node 5
displays the n-1
text.
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs
begindocument
tikz graph[grow right=30mm]
1 ->[edge label=a] 2 ->[edge label=b] 3;
1 -> [bend right,edge label'=c] 3;
;
tikz graph[grow right=20mm]
1 ->[edge label=$a_1$] 2 ->[edge label=$a_2$] 3->[edge label=$a_3$] 4/$cdots$ -!- 5/$n-1$->[edge label=$a_n-1$] n ;
1 -> [bend right,edge label'=b] n;
;
enddocument
Edit:
Using the quotes
library, the syntax for writing labels is even shorter:"a"
instead of edge label=a
"c"'
instead of edge label' =c
You can customize the colors as below:
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs,quotes
begindocument
tikz[thick,gray] graph[grow right=30mm]
1 ->["a"] 2 ->["b"] 3;
1 -> [bend right,"c"'] 3;
;
General case:
smallskip
tikz[thick,every edge/.style=red,draw,every node/.style=blue] graph[grow right=20mm,edge quotes=black,auto]
1 ->["$a_1$"] 2 ->["$a_2$"] 3->["$a_3$"] 4/$cdots$ -!- 5/$n-1$->["$a_n-1$"] n ;
1 -> [bend right,"b"'] n;
;
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With tikz, it is possible to use the chain
concept of the graphs
library.
chains
are a series of nodes
whose syntax is abbreviated compared to their normal syntax. A chain ends with a semicolon. The nodes and their text are identical by default as in the first figure. Nodes and text are the number 1
, 2
and 3
.
This first figure is composed of 2 chains: the first 1->2->3
and the second which goes directly from 1 to 3.
To add text to the arrow (that is called edge by tikz), simply place the option edge label
or edge label'
depending on whether the text is above or below the arrow. In reality, this places the text to the left or right when walking in the direction of the chain.
In the second example, to avoid having to draw an arrow, we write -!-
instead of ->
(see p 265 of the manual).
To make the node text
different from its name, simply separate the name from the text with a slash. For example : 5/$n-1$
means that node 5
displays the n-1
text.
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs
begindocument
tikz graph[grow right=30mm]
1 ->[edge label=a] 2 ->[edge label=b] 3;
1 -> [bend right,edge label'=c] 3;
;
tikz graph[grow right=20mm]
1 ->[edge label=$a_1$] 2 ->[edge label=$a_2$] 3->[edge label=$a_3$] 4/$cdots$ -!- 5/$n-1$->[edge label=$a_n-1$] n ;
1 -> [bend right,edge label'=b] n;
;
enddocument
Edit:
Using the quotes
library, the syntax for writing labels is even shorter:"a"
instead of edge label=a
"c"'
instead of edge label' =c
You can customize the colors as below:
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs,quotes
begindocument
tikz[thick,gray] graph[grow right=30mm]
1 ->["a"] 2 ->["b"] 3;
1 -> [bend right,"c"'] 3;
;
General case:
smallskip
tikz[thick,every edge/.style=red,draw,every node/.style=blue] graph[grow right=20mm,edge quotes=black,auto]
1 ->["$a_1$"] 2 ->["$a_2$"] 3->["$a_3$"] 4/$cdots$ -!- 5/$n-1$->["$a_n-1$"] n ;
1 -> [bend right,"b"'] n;
;
enddocument
Translated with www.DeepL.com/Translator
With tikz, it is possible to use the chain
concept of the graphs
library.
chains
are a series of nodes
whose syntax is abbreviated compared to their normal syntax. A chain ends with a semicolon. The nodes and their text are identical by default as in the first figure. Nodes and text are the number 1
, 2
and 3
.
This first figure is composed of 2 chains: the first 1->2->3
and the second which goes directly from 1 to 3.
To add text to the arrow (that is called edge by tikz), simply place the option edge label
or edge label'
depending on whether the text is above or below the arrow. In reality, this places the text to the left or right when walking in the direction of the chain.
In the second example, to avoid having to draw an arrow, we write -!-
instead of ->
(see p 265 of the manual).
To make the node text
different from its name, simply separate the name from the text with a slash. For example : 5/$n-1$
means that node 5
displays the n-1
text.
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs
begindocument
tikz graph[grow right=30mm]
1 ->[edge label=a] 2 ->[edge label=b] 3;
1 -> [bend right,edge label'=c] 3;
;
tikz graph[grow right=20mm]
1 ->[edge label=$a_1$] 2 ->[edge label=$a_2$] 3->[edge label=$a_3$] 4/$cdots$ -!- 5/$n-1$->[edge label=$a_n-1$] n ;
1 -> [bend right,edge label'=b] n;
;
enddocument
Edit:
Using the quotes
library, the syntax for writing labels is even shorter:"a"
instead of edge label=a
"c"'
instead of edge label' =c
You can customize the colors as below:
documentclass[a4paper,12pt]article
usepackagetikz
usetikzlibrarygraphs,quotes
begindocument
tikz[thick,gray] graph[grow right=30mm]
1 ->["a"] 2 ->["b"] 3;
1 -> [bend right,"c"'] 3;
;
General case:
smallskip
tikz[thick,every edge/.style=red,draw,every node/.style=blue] graph[grow right=20mm,edge quotes=black,auto]
1 ->["$a_1$"] 2 ->["$a_2$"] 3->["$a_3$"] 4/$cdots$ -!- 5/$n-1$->["$a_n-1$"] n ;
1 -> [bend right,"b"'] n;
;
enddocument
Translated with www.DeepL.com/Translator
edited Sep 27 at 19:39
answered Sep 26 at 20:34
AndréC
3,376729
3,376729
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f452415%2fhow-to-draw-an-diagram-with-arrows%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
You could youre the TikZ package, you will find a short tutorial at the begin of the documentation.
â omisson
Sep 25 at 11:04