3

I have a problem with the placement of labels on "rectangle shaped" arrows. I would like to place the labels middle and most right or left on the most right and left arrows respectively. Does anyone know how to do this? Thanks!!

My code

\begin{center} 
\begin{tikzpicture} 
\matrix(cd)[matrix of math nodes,
  row sep=2.6em, column sep=2cm, 
  text height=1.5ex, text depth=0.25ex]{
  F_0a & F_0b \\ 
  F_1a & F_1b \\ 
  F_2a & F_2b \\
}; 
\draw[->] (cd-1-1) edge node[label=above:$F_0f$] (U) {} (cd-1-2); 
\draw[->] (cd-2-1) edge node[label=above:$F_1f$] (V) {} (cd-2-2); 
\draw[->] (cd-3-1) edge node[label=below:$F_2f$] (W) {} (cd-3-2); 
\draw[->] (cd-1-1) edge node[label=left:$t_a$ ] (U) {} (cd-2-1); 
\draw[->] (cd-2-1) edge node[label=left:$t'_a$] (V) {} (cd-3-1); 
\draw[->] (cd-1-2) edge node[label=right:$t_b$ ] (W) {} (cd-2-2); 
\draw[->] (cd-2-2) edge node[label=right:$t'_b$] (U) {} (cd-3-2); 
\draw[->] (cd-1-1.west) -| ++(-.5,0) node[label=left :$(t'\circ t)_a$] {} |- (cd-3-1.west); 
\draw[->] (cd-1-2.east) -| ++(.5,0)  node[label=right:$(t'\circ t)_b$] {} |- (cd-3-2.east); 
\end{tikzpicture} 
\end{center} 
  • 1
    Are you using the position library of TikZ in the preamble? – Dox Jul 12 '13 at 14:27
  • It seems I am not, how should the preamble looks like in your opinion? – nunatak Jul 12 '13 at 14:40
  • Thaks!! That worked perfect!! Nice – nunatak Jul 12 '13 at 14:47
3

A quick solution is to place the nodes using the matrix entries as reference points instead of placing them along the paths:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{center} 
\begin{tikzpicture} 
\matrix(cd)[matrix of math nodes,
  row sep=2.6em, column sep=2cm, 
  text height=1.5ex, text depth=0.25ex]{
  F_0a & F_0b \\ 
  F_1a & F_1b \\ 
  F_2a & F_2b \\
}; 
\draw[->] (cd-1-1) edge node[label=above:$F_0f$] (U) {} (cd-1-2); 
\draw[->] (cd-2-1) edge node[label=above:$F_1f$] (V) {} (cd-2-2); 
\draw[->] (cd-3-1) edge node[label=below:$F_2f$] (W) {} (cd-3-2); 
\draw[->] (cd-1-1) edge node[label=left:$t_a$ ] (U) {} (cd-2-1); 
\draw[->] (cd-2-1) edge node[label=left:$t'_a$] (V) {} (cd-3-1); 
\draw[->] (cd-1-2) edge node[label=right:$t_b$ ] (W) {} (cd-2-2); 
\draw[->] (cd-2-2) edge node[label=right:$t'_b$] (U) {} (cd-3-2); 
\draw[->] (cd-1-1.west) -| ++(-.5,0) |- (cd-3-1.west); 
\draw[->] (cd-1-2.east) -| ++(.5,0) |- (cd-3-2.east);
\node[anchor=east,xshift=-16pt] at (cd-2-1.west) {$(t'\circ t)_a$}; \node[anchor=west,xshift=16pt] at (cd-2-2.east) {$(t'\circ t)_b$}; 
\end{tikzpicture} 
\end{center} 

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.