I want to draw labeled parallel arrow in commutative diagram with TikZ, I searched on google and Tex Stackexchange, however, I found only the method to draw parallel arrow by transform canvas
only, I tried to add the labeled but it failed.
Here is my picture:
I want to label a map from $\mathfrak{P}=\bigoplus_{i\inI}\mathfrak{P_{i}}$
to $\mathfrak{P_{i}}$ and from $\mathfrak{P_{i}}$
to $\mathfrak{P}=\bigoplus_{i\inI}\mathfrak{P_{i}}$
, i.e the arrows of the square.
Here is the code :
\begin{tikzpicture}[node distance=2.8cm, auto]
\node (P) {$\mathfrak{P}=\bigoplus_{i\in I}\mathfrak{P_{i}}$};
\node(Q)[right of=P] {$\mathfrak{P_{j}}$};
\node (B) [below of=P] {$\mathfrak{B}$};
\node (C) [right of=B] {$\mathfrak{C}$};
\draw[transform canvas={yshift=0.5ex},->] (P) - -(Q);
\draw[transform canvas={yshift=-0.5ex},->](Q) -- (P);
\draw[->](Q) to node {$a$}(B);
\draw[->](Q) to node {$a$}(C);
\draw[->] (P) to node {$\pi_{j}$} (B);
\draw[->] (B) to node {$\psi$} (C);
\draw[->, dashed] (Q) to node [swap] {$g$} (B);
\end{tikzpicture}
Best Answer
Here are your labeled lines.
There are other ways to shift nodes but IMO the
transform canvas
is the most direct, so you are doing fine for that aspect.To label a line, you can add a node command at the end of the line specification. The label may be placed
above
orbelow
and you can specify where along the line with keywords such asmidway
or the more generalpos=<fraction along line>
. I also shifted the diagonal lines so that they may both be seen (since one was dashed).I added a macro to simplify the shifting of the diagonal lines.