7

I am trying to type the following simple commutative diagram in LaTeX. I have the basics, but I need for the V to be centered, and for the arrow under the g to be in the opposite direction.

\begin{tikzpicture}[every node/.style={midway}]
\matrix[column sep={4em,between origins},
    row sep={2em}] at (0,0)
{ \node(X)   {$X$}  ; & \node(Y) {$Y$}; \\
\node(V) {$V$};                   \\};
\draw[<-] (V) -- (X) node[anchor=east]  {$h$};
\draw[->] (V) -- (Y) node[anchor=north]  {$g$};
\draw[->] (X)   -- (Y) node[anchor=south] {$f$};
\end{tikzpicture}
David Carlisle
  • 757,742

1 Answers1

5

Does this solution with tikz-cd help?

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

\begin{document}

\begin{tikzcd}[column sep=small]
X \arrow{rr}{f} \arrow[swap]{dr}{h}& &Y \arrow{dl}{g}\\
& V & 
\end{tikzcd}    

\end{document}  

enter image description here

David Carlisle
  • 757,742
c.p.
  • 4,636
  • Actually, it does as this is exactly what I was looking for. In general, what are the differences between tikz and tikz-cd? I mean when is it better to use the latter rather than the former? Thanks again. – Michael Dykes Jan 01 '13 at 20:18
  • I am unexpert, but as I see it, tikz-cd is a tikz-based package to easily type commutative diagrams. As you can see, the syntaxis is as easy as xymatrix. – c.p. Jan 01 '13 at 20:24
  • You're welcome. Here is the manual for more information: http://ctan.unixbrain.com/graphics/pgf/contrib/tikz-cd/tikz-cd-doc.pdf – c.p. Jan 01 '13 at 20:33