[Tex/LaTex] Diagonal arrow using Tikz

tikz-arrows

enter image description here

I intend to generate this sketch using tikz, but was unable to do so. I was trying to fiddle with the following code:

 \documentclass{article}
   \usepackage{amsmath,mathtools}
   \usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
 A \arrow[rd] \arrow[r, "\phi"] & B \\
& C
\end{tikzcd}
\end{document}

I need some help here. Also a good reference for tikz would be appreciated, specifically, I am not able to understand the function of "&" in tikz environment.

Best Answer

tikz-cd documentation

You have to think on your diagram as an array, with rows and columns. In your case, 2 rows and 4 columns.

So, at position (i,j) you can start an arrow pointing to another position (k,l), where you specify if the ending position is left, right, up or down, or even combinations of those.

In your example, and arrow from B to E should be rd (right and down).

Observe that to create cells in the array you change columns with & and change rows with \\.

As usual, it is easy to change colours also, for example, \arrow[rd, red].

enter image description here

\documentclass{article}
%\usepackage{amsmath,mathtools}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
 A  \arrow[r, "\phi"] & B \arrow[rd] \arrow[r] & C \arrow[r] & D \\
 & & E
\end{tikzcd}
\end{document}
Related Question