TikZ – How to Create an Inclusion Arrow in TikZ

arrowsdiagramstikz-pgf

How can I give shape to some arrow in tikz, to draw the inclusion arrow?

I read a similar question How to typeset inclusion arrow? with given answer, but the answer didn't really used TikZ, which I really need in order to produce nice large diagrams.

For instance, in this diagram (taken from here ), I want, say, A to be included in A' :

\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); }

Best Answer

For commutative diagrams I suggest using the tikz-cd package; it uses TikZ to facilitate the drawing of commutative diagrams (it has its own arrows library designed for diagrams and the arrow you are looking for is already buil-in); a little example with the requested inclusion (and some others just for illustration):

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

\begin{document}

\begin{tikzcd}
0 \arrow[hookrightarrow]{r} 
  & A\arrow[hookrightarrow]{r}{\varphi}\arrow[hookrightarrow]{d}{\eta_1} 
  & B\arrow{r}{\psi}\arrow{d}{\eta_2} 
  & C\arrow{r}\arrow{d}{\eta_3} 
  & 0 \\
0 \arrow[hookrightarrow]{r} 
  & A'\arrow[hookrightarrow]{r}[swap]{\varphi'} 
  & B'\arrow{r}[swap]{\psi'} 
  & C'\arrow{r}
  & 0 
\end{tikzcd}
\end{document}

enter image description here

You can use the arrows library from TikZ, so for example, to use the -latex style from TikZ, you can say

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

\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>=latex}}

\begin{document}


\begin{tikzcd}
0 \arrow[hookrightarrow]{r} 
  & A\arrow[hookrightarrow]{r}{\varphi}\arrow[hookrightarrow]{d}{\eta_1} 
  & B\arrow{r}{\psi}\arrow{d}{\eta_2} 
  & C\arrow{r}\arrow{d}{\eta_3} 
  & 0 \\
0 \arrow[hookrightarrow]{r} 
  & A'\arrow[hookrightarrow]{r}[swap]{\varphi'} 
  & B'\arrow{r}[swap]{\psi'} 
  & C'\arrow{r}
  & 0 
\end{tikzcd}
\end{document}

enter image description here

The above code changes the tip arrow style for all the diagrams, but you can select the -latex arrow tip just for some arrows (perhaps not really desirable to have two different arrow tips on the same diagram):

\arrow[hookrightarrow,-latex]{d}{\eta_1}