在 TikZ 上更改线条形状

在 TikZ 上更改线条形状

我想画一个长正合序列的图。这是我做的:

\documentclass{beamer}
\usecolortheme{wolverine}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,positioning}
\begin{document}
\begin{frame}{Conclusion}

\begin{center}
\begin{tikzpicture}
\matrix[matrix of nodes,ampersand replacement=\&, column sep=0.5cm, row sep=0.5cm](m)
{
 \& $\cdots$ \& $\pi_{n+1}(B)$ \\
$\pi_{n}(F)$ \& $\pi_{n}(E)$ \& $\pi_{n}(B)$ \\
$\pi_{n-1}(F)$ \& $\cdots$ \&  \\
};
\draw[->] (m-1-2) edge (m-1-3)
          (m-1-3) edge[out=0, in=180] (m-2-1)
          (m-2-1) edge (m-2-2)
          (m-2-2) edge (m-2-3)
          (m-2-3) edge[out=0, in=180] (m-3-1)
          (m-3-1) edge (m-3-2);
\end{tikzpicture}
\end{center}

i.e., the image of one homomorphism is equal to the kernel of the next one.
\end{frame}    
\end{document}

其结果是: 图01 http://www.ime.unicamp.br/~ra151530/TSE/frame.png

不过,我希望行之间的箭头像这样: 图02

我怎样才能做到这一点?

答案1

使用tikz-cd包,专为交换图设计,以及弯曲箭头的样式:

在此处输入图片描述

代码:

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

\tikzset{
curvarr/.style={
  to path={ -- ([xshift=2ex]\tikztostart.east)
    |- (#1) [near end]\tikztonodes
    -| ([xshift=-2ex]\tikztotarget.west)
    -- (\tikztotarget)}
  }
}

\begin{document}

\begin{tikzcd}
& \cdots \arrow[r]
\arrow[d, phantom, ""{coordinate, name=Z}]
& \pi_{n+1}(B) \arrow[dll,rounded corners=8pt,curvarr=Z] 
\\
\pi_{n-1}(F)\pi_{n}(F) \arrow[r]
& \pi_{n}(E)\arrow[r]\arrow[d, phantom, ""{coordinate, name=W}]
& \pi_{n}(B) 
\arrow[dll,rounded corners=8pt,curvarr=W] 
\\
\pi_{n-1}(F)\arrow[r] & \cdots & {}
\end{tikzcd}

\end{document}

答案2

这是通过calc库解决并使用to path操作来定义curvedlink边的样式:

在此处输入图片描述

\documentclass{beamer}
\usecolortheme{wolverine}
\beamertemplatenavigationsymbolsempty
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,positioning,calc}

\tikzset{
  curvedlink/.style={
    to path={
      let \p1=(\tikztostart.east), \p2=(\tikztotarget.west),
      \n1= {abs(\y2-\y1)/4} in
      (\p1) arc(90:-90:\n1) -- ([yshift=2*\n1]\p2) arc (90:270:\n1)
    },
  }
}

\begin{document}
\begin{frame}{Conclusion}

From a fibration we obtain a long exact sequence

\begin{center}
\begin{tikzpicture}
\matrix[matrix of nodes,ampersand replacement=\&, column sep=0.5cm, row sep=0.5cm](m)
{
 \& $\cdots$ \& $\pi_{n+1}(B)$ \\
$\pi_{n}(F)$ \& $\pi_{n}(E)$ \& $\pi_{n}(B)$ \\
$\pi_{n-1}(F)$ \& $\cdots$ \&  \\
};
\draw[->] (m-1-2) edge (m-1-3)
          (m-1-3) edge[curvedlink] (m-2-1)
          (m-2-1) edge (m-2-2)
          (m-2-2) edge (m-2-3)
          (m-2-3) edge[curvedlink] (m-3-1)
          (m-3-1) edge (m-3-2);

\end{tikzpicture}
\end{center}

i.e., the image of one homomorphism is equal to the kernel of the next one.
\end{frame}    
\end{document}

答案3

一种选择是使用控件,但这并不能得到您想要的完美方形线条:

在此处输入图片描述

\begin{tikzpicture}
\matrix[matrix of nodes,ampersand replacement=\&, column sep=0.5cm, row sep=0.5cm](m)
{
 \& $\cdots$ \& $\pi_{n+1}(B)$ \\
$\pi_{n}(F)$ \& $\pi_{n}(E)$ \& $\pi_{n}(B)$ \\
$\pi_{n-1}(F)$ \& $\cdots$ \&  \\
};
\draw[->] (m-1-2) edge (m-1-3)
          (m-1-3) edge[out=0, in=180,controls=+(-11:4) and +(-11:-3.5)] (m-2-1)
          (m-2-1) edge (m-2-2)
          (m-2-2) edge (m-2-3)
          (m-2-3) edge[out=0, in=180,controls=+(-11:4.5) and +(-11:-3)] (m-3-1)
          (m-3-1) edge (m-3-2);
\end{tikzpicture}

相关内容