使用 TikZ 绘制更高类别的图表

使用 TikZ 绘制更高类别的图表

我计划就严格 n 类别进行一次介绍性演讲,并且我想使用 TikZ 通过一些细胞图来展示 k-morphim 之间的关系。

确切地说,我想画出像 Tom Leinster 的书《高等歌剧,高等范畴》前言第六页顶部的四张图一样的图表。 http://arxiv.org/abs/math.CT/0305049

在此处输入图片描述

前两个当然很容易。对于第三个,我找到了这个

\begin{tikzcd}
A \arrow[bend left=50]{r}[name=U,below]{} \arrow[bend right=50]{r}[name=D]{} & B \arrow[Rightarrow,to path={(U) -- (D)}]{}
\end{tikzcd}

不幸的是我不知道如何修改代码来绘制最后一个。有什么想法吗?

答案1

像这样吗?

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


\begin{document}

\begin{tikzcd}[column sep=3cm]
a 
  \arrow[bend left=50]{r}[name=U,below]{}{f} 
  \arrow[bend right=50]{r}[name=D]{}[swap]{g}
& 
b 
  \arrow[Rightarrow,to path={(U) to[out=-150,in=150] node[auto,swap] {$\scriptstyle\alpha$} coordinate (M) (D)}]{}
  \arrow[Rightarrow,to path={(U) to[out=-30,in=30] node[auto] {$\scriptstyle\beta$} coordinate (N)  (D)}]{}
  \arrow[Rightarrow,to path={([xshift=4pt]M) -- node[auto] {$\scriptstyle\Gamma$} ([xshift=-4pt]N)}]{}
\end{tikzcd}

\end{document}

在此处输入图片描述

只需稍微努力一下就可以模仿原始风格:

\documentclass{article}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usetikzlibrary{calc,arrows}

\tikzset{
mydot/.style={circle,fill,inner sep=1.5pt},
commutative diagrams/.cd,
  arrow style=tikz,
  diagrams={>=latex},
}

\begin{document}

\begin{tikzcd}[column sep=3cm]
  \arrow[to path={node[mydot,label={left:$a$}] {}}]{} 
  \arrow[bend left=50]{r}[name=U,below]{}{f} 
  \arrow[bend right=50,shorten >= -3.5pt,shorten <= -3.5pt]{r}[name=D]{}{}
  \arrow[to path={node[below,yshift=-2pt] at (D) {$\scriptstyle g$} {}}]{}
& 
  \arrow[to path={node[mydot,label={right:$b$}] {}}]{} 
  \arrow[Rightarrow,to path={(U) to[out=-160,in=160] node[auto,swap] {$\scriptstyle\alpha$} coordinate (M) (D)}]{}
  \arrow[Rightarrow,to path={(U) to[out=-20,in=20] node[auto] {$\scriptstyle\beta$} coordinate (N)  (D)}]{}
  \arrow[to path={node[label={center:\scalebox{1.9}[0.75]{$\Rrightarrow$}},label={[yshift=-2pt]above:$\scriptstyle\Gamma$}] at ( $ (M)!0.5!(N) $ ) {}}]{}
\end{tikzcd}

\end{document}

在此处输入图片描述

答案2

这里有一个仅使用 tikz 的解决方案:

\documentclass[11pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{tikz}
\usetikzlibrary{arrows,calc}

\begin{document}

\begin{tikzpicture}[>=latex,
    every node/.style={auto},
    arrowstyle/.style={double,->,shorten <=3pt,shorten >=3pt},
    mydot/.style={circle,fill}]

    \coordinate[mydot,label=left:$a$](a)  at (0,0);
    \coordinate[mydot,label=right:$b$](b) at (3,0);

    \draw[->]   (a) to[bend left=50]  coordinate (f) node[]{$f$}          (b);
    \draw[->]   (a) to[bend right=50] coordinate (g) node[,swap] {$g$}    (b);

    \draw[arrowstyle] (f) to node[right]{$\alpha$} (g);


    \coordinate[mydot,label=left:$a$](a)  at (6,0);
    \coordinate[mydot,label=right:$b$](b) at (11,0);

    \draw[->]         (a) to[bend left=50]  coordinate (f) node[]{$f$}          (b);
    \draw[->]         (a) to[bend right=50] coordinate (g) node[,swap] {$g$}    (b);

    \draw[arrowstyle] (f) to[bend left=50]       node (p){$\beta$}  (g);
    \draw[arrowstyle] (f) to[bend right=50,swap] node (q){$\alpha$} (g);

    \draw[arrowstyle] (q.east) to node[above]{$\Gamma$} (p.west);
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案3

这是使用 Metapost 的解决方案。我在网上找不到任何绘制双线和三线的示例,所以我想出了一个使用不同笔宽和的方法undraw。我坚持使用标准 MP 箭头,但只要稍微多做一点工作,我们就可以根据需要将其更改为开放的卷曲箭头。

prologues := 3;
outputtemplate := "%j%c.eps";

vardef double_line_arrow(expr p) = 
    interim linecap:=butt; 
    draw p cutafter fullcircle scaled ahlength 
                               shifted point length(p) of p withpen currentpen scaled 3;
    undraw p;
    filldraw arrowhead p;
    enddef;

vardef triple_line_arrow(expr p) = 
    interim linecap := butt;
    draw   p cutafter fullcircle scaled (1.5*ahlength) 
                                 shifted point length(p) of p withpen currentpen scaled 5;
    undraw p withpen currentpen scaled 3;
    drawarrow p;
    enddef;

beginfig(1);
dotlabel.bot(btex $a$ etex,origin);
endfig;

beginfig(2);
z1 = origin; z2 = right scaled 2cm;
path ab; ab = z1--z2;
drawarrow ab cutafter fullcircle scaled 3 shifted z2; 
             % stop arrow slightly short of the dotlabel
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);
label.top(btex $f$ etex, point .5 of ab);
endfig;

beginfig(3);
z1 = origin;
z2 = right scaled 2cm;

path ab[]; 
ab1 = z1{dir 60} .. {dir -60}z2; ab2 = ab1 reflectedabout(origin,right);
drawarrow ab1 cutafter fullcircle scaled 3 shifted z2;
drawarrow ab2 cutafter fullcircle scaled 3 shifted z2;
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);

z3 = point .5 of ab1; 
z4 = point .5 of ab2; 
label.top(btex $f$ etex,z3);
label.bot(btex $g$ etex,z4);

path fg; 
fg =  z3 -- z4 cutbefore fullcircle scaled 8pt shifted z3 
               cutafter  fullcircle scaled 8pt shifted z4;
double_line_arrow(fg);
label.rt(btex $\alpha$ etex, point .5 of fg);
endfig;

beginfig(4);
z1 = origin;
z2 = right scaled 2.2cm;

path ab[]; ab1 = z1{dir 60} .. {dir -60}z2; ab2 = ab1 reflectedabout(origin,right);
drawarrow ab1 cutafter fullcircle scaled 3 shifted z2;;
drawarrow ab2 cutafter fullcircle scaled 3 shifted z2;;
dotlabel.llft(btex $a$ etex,z1);
dotlabel.lrt (btex $b$ etex,z2);

z3 = point .5 of ab1; 
z4 = point .5 of ab2; 
label.top(btex $f$ etex,z3);
label.bot(btex $g$ etex,z4);

path fg[]; 
fg1 =  z3{dir -150} .. {dir -30} z4 
          cutbefore fullcircle scaled 8pt shifted z3 
          cutafter  fullcircle scaled 8pt shifted z4;
fg2 =  fg1 reflectedabout(z3,z4);

z5 = point .5 of fg1;
z6 = point .5 of fg2;

double_line_arrow(fg1); label.lft(btex $\alpha$ etex, z5);
double_line_arrow(fg2); label.rt (btex $\beta$  etex, z6);

ab3 = z5 -- z6
      cutbefore fullcircle scaled 4pt shifted z5
      cutafter  fullcircle scaled 4pt shifted z6;
triple_line_arrow(ab3);
label.top(btex $\Gamma$ etex, point .5 of ab3);
endfig;
end.

该图中从左到右依次为图 1..4。

在此处输入图片描述

答案4

自 2020 年起,我们颤动,一个图形化的 tikz-cd 编写器。它特别适合在箭头之间绘制箭头。

相关内容