如何使用 Tikz 包制作适当的六边形交换图?

如何使用 Tikz 包制作适当的六边形交换图?

如果你运行以下代码

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

\begin{document}
    \begin{tikzcd}
     & A \arrow[r, "a"] \arrow[ld, "a'"'] & B \arrow[rd, "b"] &  \\
    C \arrow[rd, "c"']&  &  & F \\
     & D \arrow[r, "d"'] & E \arrow[ru, "e"'] & 
    \end{tikzcd}

\end{document}

您会发现我得到的六边形不太“对称”,看起来也不太美观。有办法解决这个问题吗?

答案1

给你:

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

\begin{document}
\begin{tikzcd}[column sep={1cm,between origins}, row sep={1.732050808cm,between origins}]
    & A \arrow[rr, "a"] \arrow[ld, "a'"'] && B \arrow[rd, "b"] &  \\
    C \arrow[rd, "c"']&  &&  & F \\
    & D \arrow[rr, "d"'] && E \arrow[ru, "e"'] & 
\end{tikzcd}
\end{document}

这个奇怪的数字是 3 的平方根。

在此处输入图片描述

答案2

使用 MetaPost 实现此操作的一种(可能比较笨拙)方法,可能会引起一些人的兴趣。它利用了包boxes和 Metafun 格式的一些宏(shortened, freelabel)。我将代码包含在 LuaLaTeX 程序中,因为这样排版更容易。

\documentclass[border=5mm]{standalone}
\usepackage{luatex85,luamplib}
    \mplibtextextlabel{enable}
    \mplibsetformat{metafun}
\begin{document}
\begin{mplibcode}
input boxes;
u := 2.5cm;
beginfig(1);
    boxit.a("$A$"); boxit.b("$B$"); boxit.c("$C$");
    boxit.d("$D$"); boxit.e("$E$"); boxit.f("$F$");
    i := 0;
    forsuffixes z = f, b, a, c, d, e:
        z.c = u*dir(60i); drawunboxed(z); i := i+1;
    endfor;
    for p = a.c -- b.c, b.c -- f.c, c.c -- d.c, d.c -- e.c, e.c -- f.c, a.c -- c.c:
        drawarrow p shortened 3mm;
    endfor; 
    freelabel("$a$", .5[a.c, b.c], origin);
    freelabel("$b$", .5[b.c, f.c], origin);
    freelabel("$c$", .5[c.c, d.c], origin);
    freelabel("$d$", .5[d.c, e.c], origin);
    freelabel("$e$", .5[e.c, f.c], origin);
    freelabel("$a'$", .5[a.c, c.c], origin);
endfig;
\end{mplibcode}
\end{document}

在此处输入图片描述

答案3

这里有两种方法可以使用 来获得这样的图表pstricks:要么psmatrix使用 来调整 rowsep 和 colsep 以得到大致正六边形,要么使用\pstHexagon中的命令pst-poly,这样可以避免任何计算:

\documentclass{article}
\usepackage{tikz-cd, amsmath}
\usepackage{pst-node, pst-arrow, pst-poly}
\usepackage{auto-pst-pdf} %% to compile with pdflatex --enable-write18 (MiKTeX) or pdflatex --shell-escape (TeX Live, MacTeX))

\begin{document}

\[
\def\pscolhookii{\hskip -0.75cm}
\def\pscolhookiv{\hskip -0.75cm}
\psset{nodesep = 3pt, rowsep = 1.2cm, arrowinset = 0.15,arrows = ->, linewidth = 0.5pt, shortput = nab}%
\begin{psmatrix}
 &[name = A] A & [name = B] B \\
[name = C] C & & & [name = F] F \\
  & [name = D] D & [name = E] E
\psset{labelsep = 2pt}
\ncline{A}{B}^{a}\ncline{D}{E}_{d}
\ncline{B}{F}\naput{b}
\ncline{A}{C}\nbput[npos = 0.45]{a'}\ncline{C}{D}\nbput{c}
\ncline{E}{F}\nbput{e}
\end{psmatrix} \]
\bigskip

\[ 
\begin{pspicture}
\psset{linewidth = 0.5pt, unit = 1.8}
\PstHexagon[PolyName = H, linestyle = none]
\foreach \label[count = \i] in {F, B, A, C, D, E}{\rput(H\i){\label}}
\psset{labelsep = 2pt, nodesep = 8pt, arrows = ->, arrowinset = 0.15}
\ncline{H3}{H2}\naput{$ a $}\ncline{H2}{H1}\naput{$ b $}
\foreach \i/\j/\arlabel in{3/2/a, 2/1/b} {\ncline{H\i}{H\j}\naput{$ \arlabel $}}
\foreach \i/\j/\arlabel in{3/4/a', 4/5/c, 5/6/d,6/1/e} {\ncline{H\i}{H\j}\nbput{$ \arlabel $}}
\end{pspicture}
 \]%

\end{document} 

在此处输入图片描述

相关内容