2

I want to write the following diagram. enter image description here

I wrote following code, but I cannot out put the injective map from $A$ to $B$. How can I do that and I can write beautiful diagram ?

\documentclass[tikz,border=10pt]{standalone}

\usepackage{tikz}
\usetikzlibrary{positioning,arrows}
\usepackage{amsmath}

\begin{document}
\begin{tikzpicture}[node distance=1.5cm and 3cm, auto]
  \node (A) {A};
  \node (B) [right=of A] {B};
  \node (C) [below=of A] {C};
  \node (D) [below=of B] {D};
  \node (E) [right=of D] {E};
  \node (F) [right=of E] {F};

  \draw[->] (A) -- (B) node[midway,above] {$\hookrightarrow$};
  \draw[->] (A) -- (C);
  \draw[->] (B) -- (D);
  \draw[->] (C) -- (D);
  \draw[->] (D) -- (E) node[midway,above] {$f_1$};
  \draw[->] (E) -- (F) node[midway,above] {$f_2$};
  \draw[->] (B) -- (E) node[midway,sloped,above] {$f$};
\end{tikzpicture}
\end{document}

Output:

output

1
  • Ok, don't get what you are missing. Can you please EDIT your question and explain a little more? Thank you
    – MS-SPO
    Dec 8, 2023 at 15:54

2 Answers 2

4

Instead of manually creating your diagram in tikz, have instead a look at the tikz-cd package:

\documentclass[border=10pt]{standalone}

\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}
  A \arrow[r, hook] \arrow[d] & B\arrow[d]\arrow[dr,"f"]\\
  C \arrow[r] & D \arrow[r,"f_1"] & E \arrow[r,"f_2"] & F
\end{tikzcd}
\end{document}

enter image description here

1

Use tikz-cd instead:

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

\begin{document}

\begin{tikzcd}[row sep=large]
  A \arrow[r, hook] \arrow[d] &
  B \arrow[d] \arrow[dr,"f"]
\\
  C \arrow[r] & D \arrow[r,"f_2"'] & E \arrow[r] & F
\end{tikzcd}

\end{document}

enter image description here

I feel somewhat unsatisfied by the diagonal arrow; changing the anchor point does a batter job. You can first draft your diagrams in an easy way and reserve some time at the end for fine tuning.

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

\begin{document}

\begin{tikzcd}[row sep=large]
  A \arrow[r, hook] \arrow[d] &
  B \arrow[d] \arrow[dr,start anchor=base east,"f"]
\\
  C \arrow[r] & D \arrow[r,"f_2"'] & E \arrow[r] & F
\end{tikzcd}

\end{document}

enter image description here

Note how the hook arrow and the labels are specified; a single quote after the closing " for the label means that the label should go on the right side of the arrow (default is the left side, determined in the same way as for rivers, that is, facing the end).

You must log in to answer this question.

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