Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
share|improve this question
    
To switch the direction of the arrow, just reverse the order: \draw[->] (Y) -- (V) instead of \draw[->] (V) -- (Y). Also, the V node is centered, so perhaps just increasing the length of the line a bit by adding shorten option as in \draw[->, shorten >=-0.5ex] (Y) -- (V) makes it look more centered. –  Peter Grill Jan 1 '13 at 19:56
    
have you seen Commutative Diagrams and TikZ and a search for commutative diagrams –  cmhughes Jan 1 '13 at 20:00
    
@PeterGrill When I compile, I still see the V directly beneath the X,rather than centered and diagonally beneath and to the right of the X, as I would like for it to be. Thanks again. –  Michael Dykes Jan 1 '13 at 20:05
    
@MichaelDykes: Duhh!!! Sorry about that. Not sure what part of "center" was confusing to me. :-) –  Peter Grill Jan 1 '13 at 20:49
add comment

1 Answer 1

up vote 4 down vote accepted

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

share|improve this answer
    
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 1 '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 1 '13 at 20:24
    
Ok,thank you very much! –  Michael Dykes Jan 1 '13 at 20:28
    
You're welcome. Here is the manual for more information: ctan.unixbrain.com/graphics/pgf/contrib/tikz-cd/tikz-cd-doc.pdf –  c.p. Jan 1 '13 at 20:33
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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