2

How may we replace the right arrow with inclusion arrow while keeping the bottom arrow straight?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}

 \begin{document}

  \begin{tikzpicture}
   \matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
    {
     M,\phi,\xi,\eta,g &  C(M),\omega,\bar{g},\bar{\phi}\\
     Z,\Omega,h,J \\};
   \path[-stealth]
    (m-1-1) [right hook->] edge node[anchor=east] {}
     node [right] {}  (m-1-2)
     edge node [left] {} (m-2-1);
  \end{tikzpicture}

\end{document}

2 Answers 2

2

I suggest using tikz-cd which has a much simpler syntax:

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

\begin{document}

\begin{tikzcd}
M,\phi,\xi,\eta,g \arrow[r,hook] \arrow[d] &  C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J
\end{tikzcd}

\end{document}

enter image description here

If you want stealth arrows, you can set them globally:

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

\tikzcdset{
  arrow style=tikz,
  diagrams={>=stealth},
}

\begin{document}

\begin{tikzcd}
M,\phi,\xi,\eta,g \arrow[r,hook] \arrow[d] &  C(M),\omega,\bar{g},\bar{\phi}\\
Z,\Omega,h,J
\end{tikzcd}

\end{document}

enter image description here

4
  • I'm sorry but I'm getting an error on line two: File tikz-cd.sty not found. Commented Aug 27, 2015 at 8:38
  • @Student Upgrade your TeX distribution.
    – egreg
    Commented Aug 27, 2015 at 9:01
  • I upgraded MikTex after you commented but I get the same problem. I'm sorry. I don't know what is wrong. Commented Aug 27, 2015 at 14:30
  • @Student Open MiKTeX's package manager and install what's needed.
    – egreg
    Commented Aug 27, 2015 at 16:23
1

Although I second egreg's suggestion about using tikz-cd, here's how to do it with your current settings. You have two options:

  1. Enclose in braces changes in arrow specification to keep them local.
  2. Add [-stealth] before the edge to restore the arrow type.

I illustrate both options below.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows,decorations.pathmorphing}

 \begin{document}

\begin{tikzpicture}[>=stealth]
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
  M,\phi,\xi,\eta,g &  C(M),\omega,\bar{g},\bar{\phi}\\
  Z,\Omega,h,J \\
};
\path[->]
    (m-1-1) [right hook-stealth] edge node[anchor=east] {}
     node [right] {}  (m-1-2)
    [->] edge node [left] {} (m-2-1);
\end{tikzpicture}\par\bigskip

\begin{tikzpicture}[>=stealth]
\matrix (m) [matrix of math nodes,row sep=3em,column sep=4em,minimum width=2em]
{
  M,\phi,\xi,\eta,g &  C(M),\omega,\bar{g},\bar{\phi}\\
  Z,\Omega,h,J \\
};
\path[->]
    (m-1-1) {[right hook->] edge node[anchor=east] {}
     node [right] {}  (m-1-2)}
     edge node [left] {} (m-2-1);
\end{tikzpicture}

\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .