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'm new at using the TikZ package to make commutative diagrams. I'm trying to draw a triangle with an arrow between each pair of objects. Here's the code I'm using now:

\documentclass{article}
\usepackage{amsmath,amssymb,tikz}
\newcommand{\QQ}{\mathbb{Q}}
\begin{document}
\begin{tikzpicture}
  \node (Q) {$\QQ$};
  \node (tQ) [below of=Q] {$\QQ\otimes\QQ$};
  \node (cQ) [right of=tQ] {$\QQ\times\QQ$};
  \draw[->] (Q) to node {$i$} (cQ);
  \draw[->] (tQ) to node [swap] {$m$} (Q);
  \draw[<-] (cQ) to node [swap] {$\iota$} (tQ);
\end{tikzpicture}
\end{document}

(\QQ is a command I've defined to produce \mathbb{Q}, since it saves me typing.) The diagram compiles fine, but the objects and arrows overlap quite badly on the bottom line: the right- and left-most \mathbb{Q} in the nodes on the bottom line touch, and the arrow is superimposed over them. How can I fix this so that the diagram can be more readable?

share|improve this question
    
The easiest way out is to add \begin{tikzpicture}[node distance=2cm]. But this would affect all nodes in that particular TikZ picture placed by to command. See the positioning library in the manual. –  percusse Feb 19 '12 at 20:22
    
Thanks, that helps a lot- the nodes are now readable. If you make that an answer, I will accept it. –  KReiser Feb 19 '12 at 20:28
add comment

2 Answers

up vote 2 down vote accepted

The easiest way out is to add \begin{tikzpicture}[node distance=2cm]. But this would affect all nodes in that particular TikZ picture placed by to command.

For more specific solutions, the positioning library is a very powerful tool. (see page 185 in the manual v2.10)

share|improve this answer
add comment

you can use the positioning tikzlibrary and the above or right

\documentclass{article}
\usepackage{amsmath,amssymb,tikz}
\usetikzlibrary{positioning}
\newcommand{\QQ}{\mathbb{Q}}
\begin{document}
\begin{tikzpicture}
  \node (Q) {$\QQ$};
  \node (tQ) [below =5em of Q] {$\QQ\otimes\QQ$};
  \node (cQ) [right =5em of tQ] {$\QQ\times\QQ$};
  \draw[->] (Q) to node[ above] {$i$} (cQ);
  \draw[->] (tQ) to node [right] {$m$} (Q);
  \draw[<-] (cQ) to node [above] {$\iota$} (tQ);
\end{tikzpicture}
\end{document}
share|improve this answer
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.