答案1
这很容易tikz-cd
:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
1 \ar[r,"a"] \ar[rr,bend right,"c"'] & 2 \ar[r,"b"] & 3
\end{tikzcd}
\end{document}
但以我的拙见,我会投票支持图像模式,因为它的远的更加用户友好的语法:
\documentclass{article}
\usepackage{pict2e}
\begin{document}
\setlength{\unitlength}{1cm}
\begin{picture}(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$}
\end{picture}
\end{document}
更新:tikz-cd
第二张图的解决方案:
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
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
\end{tikzcd}
\end{document}
答案2
为了完整起见,这里是一个简单的 TikZ 方法
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[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);
\end{tikzpicture}%
\end{document}
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}[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);
\end{tikzpicture}%
\end{document}
答案3
解决方案pstricks
:将三个数字定义为节点,我们通过节点连接将它们链接起来。
\documentclass[12pt]{article}
\usepackage{pst-node, auto-pst-pdf}
\begin{document}
\[
\Rnode{1}{1} \hspace{3em} \Rnode{2}{2} \hspace{3em} \Rnode{3}{3}
\psset{linewidth=0.6pt, arrows=->, arrowinset=0.12, nodesep=0.6ex, labelsep=2pt, shortput=nab}
\everypsbox{\scriptstyle}
\ncline{1}{2}^{a}\ncline{2}{3}^{b}
\ncarc[arcangle=-30]{1}{3}_{c}
\]
\end{document}
答案4
含钛钾Z,可以使用库chain
的概念graphs
。
chains
是一系列的nodes
,其语法与正常语法相比有所缩写。链以分号结尾。节点及其文本默认与第一张图相同。节点和文本分别是数字1
、2
和3
。
第一个图形由两条链组成:第一条链1->2->3
和第二条链,直接从 1 到 3。
要将文本添加到箭头(tikz 称之为边缘),只需放置选项edge label
或,edge label'
具体取决于文本是在箭头上方还是下方。实际上,这会将文本放置在左边或者正确的沿链条方向行走时。
在第二个例子中,为了避免画箭头,我们-!-
这样写->
(参见19.3.3 Syntax of Chain Specifications
TikZ 手册第 272 页 3.1.1 节)。要使其node text
与名称不同,只需用斜线将名称与文本分开。例如:5/{$n-1$}
表示节点5
显示n-1
文本。
使用quotes
库:
使用该quotes
库,编写标签的语法甚至更短:
"a"
而不是edge label={a}
"c"'
您edge label' ={c}
可以自定义颜色,如下所示:
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs,quotes}
\begin{document}
\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;
};
\end{document}
没有quotes
图书馆
\documentclass[a4paper,12pt]{article}
\usepackage{tikz}
\usetikzlibrary{graphs}
\begin{document}
\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;
};
\end{document}
使用 www.DeepL.com/Translator 翻译