Example: Chains with labeled edges

Published 2011-12-31 | Author: Stefan Kottwitz

TikZ chains with labeled edges

The chains library is very useful for writing exact sequences. Yet there’s no feature for labeling the edges of a chain. Besides arrows, we might need to write symbols for maps over, under, or just next to it.

This example shows a way by modifying the join method of the chains library. Its original syntax is join=with<node> by <options>, here the syntax is changed to join={node[options] {label}}.

Furthermore, we define a style for the labels, so that all are in math mode and typeset in scriptstyle.

Download as: [PDF] [TEX]

Chains with labeled edges

Do you have a question regarding this example, TikZ or LaTeX in general? Just ask in the LaTeX Forum.
Oder frag auf Deutsch auf TeXwelt.de. En français: TeXnique.fr.

% TikZ chains with labeled edges
% Author: Stefan Kottwitz , http://texblog.net
\documentclass[a4paper,10pt]{article}
\usepackage{tikz}
\usetikzlibrary{arrows,chains,matrix,positioning,scopes}
%
\makeatletter
\tikzset{join/.code=\tikzset{after node path={%
\ifx\tikzchainprevious\pgfutil@empty\else(\tikzchainprevious)%
edge[every join]#1(\tikzchaincurrent)\fi}}}
\makeatother
%
\tikzset{>=stealth',every on chain/.append style={join},
         every join/.style={->}}
\tikzstyle{labeled}=[execute at begin node=$\scriptstyle,
   execute at end node=$]
%
\begin{document}
\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,labeled] {\eta_1}}];}
    \chainin (m-1-3) [join={node[above,labeled] {\varphi}}];
    { [start branch=B] \chainin (m-2-3)
        [join={node[right,labeled] {\eta_2}}];}
    \chainin (m-1-4) [join={node[above,labeled] {\psi}}];
    { [start branch=C] \chainin (m-2-4)
        [join={node[right,labeled] {\eta_3}}];}
    \chainin (m-1-5); }
  { [start chain] \chainin (m-2-1);
    \chainin (m-2-2);
    \chainin (m-2-3) [join={node[above,labeled] {\varphi'}}];
    \chainin (m-2-4) [join={node[above,labeled] {\psi'}}];
    \chainin (m-2-5); }
\end{tikzpicture}
\end{document}

Comments

  • #1 Eunate, September 24, 2012 at 7:47 p.m.

    how could I get this type of schema but vertical instead of horizontal? thank you!!! Eunate

Adding comments is currently not enabled.