如何在图表中画箭头?

如何在图表中画箭头?

我找到了代码

在此处输入图片描述

我尝试在端点处放置一个箭头以将 0 连接到 0,但是做不到。有什么帮助吗?

编辑:这是我找到的代码

\begin{tikzpicture}
  \matrix (m) [matrix of math nodes, row sep=3em,
    column sep=3em]
    { 0 & A  & B  & C  & 0 \\
      0 & A' & B' & C' & 0 \\ };
  { [start chain] \chainin (m-1-1);
    \chainin (m-1-2);
    { [start branch=A] \chainin (m-2-2)
        [join={node[right] {$\scriptstyle\eta_1$}}];}
    \chainin (m-1-3) [join={node[above]
                      {$\scriptstyle\varphi$}}];
    { [start branch=B] \chainin (m-2-3)
        [join={node[right] {$\scriptstyle\eta_2$}}];}
    \chainin (m-1-4) [join={node[above]
                      {$\scriptstyle\psi$}}];
    { [start branch=C] \chainin (m-2-4)
        [join={node[right] {$\scriptstyle\eta_3$}}];}
    \chainin (m-1-5); }
  { [start chain] \chainin (m-2-1);
    \chainin (m-2-2);
    \chainin (m-2-3) [join={node[above]
                      {$\scriptstyle\varphi'$}}];
    \chainin (m-2-4) [join={node[above]
                      {$\scriptstyle\psi'$}}];
    \chainin (m-2-5); }
\end{tikzpicture}

答案1

我根本不会使用,\chainin而是使用\draw

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
\begin{document}

\begin{center}
  \begin{tikzpicture}[>=stealth,->,shorten >=2pt,looseness=.5,auto]
    \matrix (M)[matrix of math nodes,row sep=10mm,column sep=16mm]{
        0 & A  & B  & C  & 0 \\
        0 & A' & B' & C' & 0 \\
     };
     \foreach \a [evaluate={\b=int(\a+1)}] in {1,4} {
       \draw[->](M-1-\a)--(M-1-\b);
       \draw[->](M-2-\a)--(M-2-\b);
     }
     \foreach \a [count=\b] in {2,3,4} {\draw[->](M-1-\a)--node[right]{$\eta_\b$}(M-2-\a);}
     \draw[->](M-1-2)--node[above]{$\varphi$}(M-1-3);
     \draw[->](M-2-2)--node[above]{$\varphi'$}(M-2-3);
     \draw[->](M-1-3)--node[above]{$\psi$}(M-1-4);
     \draw[->](M-2-3)--node[above]{$\psi'$}(M-2-4);
     \draw[->](M-1-1)--(M-2-1);
     \draw[->](M-1-5)--(M-2-5);
  \end{tikzpicture}
\end{center}

\end{document}

这要简单得多,并产生:

在此处输入图片描述

答案2

为了完整性(在我看来,因为代码更简单),这里是在 tikz 中执行此操作的另一种方法(我没有改变 phi)

\documentclass[a4paper]{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
  0 \arrow{r} \arrow{d} &  A \arrow{r}{\phi} \arrow{d}{\eta_1}
  & B \arrow{r}{\psi} \arrow{d}{\eta_2}
  & C \arrow{r} \arrow{d}{\eta_3} 
  & 0 \arrow{d}
  \\
  0 \arrow{r} & A' \arrow{r}{\phi'} & B' \arrow{r}{\psi'} 
  & C' \arrow{r} & 0
\end{tikzcd}
\end{document}

在此处输入图片描述

相关内容