I have drawn the above diagram with diagonal arrows in TikZ, but the labels look like they have been placed on a curve instead of next to each other. I think I understand why they are placed like that: TikZ puts the labels in the middle of the arrows and the diagonal arrows end slightly lower. But I'm unable to fix this.
The code I have written for this diagram is:
\documentclass[border=1]{standalone}
\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
\begin{document}
\begin{tikzpicture}
[
arr/.style={->,font=\scriptsize},
description/.style={fill=white,inner sep=2pt}
]
\matrix (m) [
matrix of math nodes, row sep=3em, column sep=4em, text height=1.5ex, text depth=0.25ex
]
{A[f]_0:=A & A[f]_1 & A[f]_2 & \cdots \\
& & B \\};
\draw[arr] (m-1-1) -- node[above] {$\pi_0$} (m-1-2);
\draw[arr] (m-1-1) -- node[description] {$f_0:=f$} (m-2-3);
\draw[arr] (m-1-2) -- node[above] {$\pi_1$} (m-1-3);
\draw[arr] (m-1-2) -- node[description] {$f_1$} (m-2-3);
\draw[arr] (m-1-3) -- node[above] {$\pi_2$} (m-1-4);
\draw[arr] (m-1-3) -- node[description] {$f_2$} (m-2-3);
\draw[arr] (m-1-4) -- node[description] {$f_3$} (m-2-3);
\end{tikzpicture}
\end{document}
So the question is: how can I put the labels $f_0:=f$
, $f_1$
, $f_2$
and $f_3$
at the same height, preferably the height of $f_2$
?
Best Answer
As I told you in my comment you need to set an horizontal line. I selected
f_2
as a reference point and named it while placing on the paththe horizontal line crossing
f2
is declared withThen you need to
name
all other paths likeand place labels over intersections
My complete code is
and the result