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 want to draw a commutative diagram with TikZ as follows:

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{tikzpicture}[auto]
\node (S1) {$\sigmaSet \cap X_N$};
\node (S2) [below= 2cm and 4cm of S1] {$\sigmaSet \cap X_N$};
\node (S3) [below= 2cm and 4cm of S2] {$\discreteSigmaSet$};
\node (U1) [right= 2cm and 4cm of S1] {$\potentialSpace$};
\node (U2) [below= 2cm and 4cm of U1] {$Y_M$};
\node (U3) [below= 2cm and 4cm of U2] {$\R^M$};
\draw[->] (S1) to node {$F_f$} (U1);
\draw[->] (S2) to node {$\widetilde{F}_f$} (U2);
\draw[->] (S3) to node {$\widehat{F}_f$} (U3);
\draw[->] (S1) to node [swap] {$I$} (S2);
\draw[->] (S2) to node [swap] {$\theta_{B_N}$} (S3);
\draw[->] (U1) to node {$P^{\psprod{E}{\cdot}{\cdot}}_{Y_M}$} (U2);
\draw[->] (U2) to node {$\theta_{C_M}$} (U3);
\end{tikzpicture}

which looks like this:

enter image description here

Note how the horizontal arrows are not straight, but end too high on the right side.

Now my question is how I can make TikZ draw the horizontal arrows as straight lines. Is there a way to accomplish this without having to use the matrix library? I want to keep the code above as simple as possible.

share|improve this question
    
Welcome to TeX.SX! –  Papiro Jun 19 '13 at 11:03
    
The arrows are straight (they’re just not horizontal). The problem is the placement of the nodes which is not consistent in the way you use it. Why don’t you simply use a matrix (which is used for tikz-cd too)? The on grid option does help here too (as it uses the center anchor for both nodes: the one that is referenced and the one that is placed)) but has other disadvantages (overlapping nodes). –  Qrrbrbirlbel Jun 19 '13 at 13:06
    
Adding the on grid option looks pretty good to me. –  Loop Space Jun 19 '13 at 14:56

2 Answers 2

up vote 3 down vote accepted

You can use the (p |- q) notation, meaning the intersection of a vertical line through p and a horizontal line through q.

Code

\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{positioning}

\begin{document}

\begin{tikzpicture}[auto]
\node (S1) {$\sigma \cap X_N$};
\node (S2) [below= 2cm and 4cm of S1] {$\sigma \cap X_N$};
\node (S3) [below= 2cm and 4cm of S2] {$\sigma$};
\node (U1) [right= 2cm and 4cm of S1] {$\gamma$};
\node (U2) at (U1 |- S2) {$Y_M$};
\node (U3) at (U2 |- S3) {$R^M$};
\draw[->] (S1) to node {$F_f$} (U1);
\draw[->] (S2) to node {$\widetilde{F}_f$} (U2);
\draw[->] (S3) to node {$\widehat{F}_f$} (U3);
\draw[->] (S1) to node [swap] {$I$} (S2);
\draw[->] (S2) to node [swap] {$\theta_{B_N}$} (S3);
\draw[->] (U1) to node {$P^{\hat{E}{\cdot}{\cdot}}_{Y_M}$} (U2);
\draw[->] (U2) to node {$\theta_{C_M}$} (U3);
\end{tikzpicture}

\end{document}

Output

enter image description here

share|improve this answer
    
Thanks a lot. :) –  Joerg Jul 11 '13 at 7:12
    
@Joerg: You're very welcome. –  Tom Bombadil Jul 11 '13 at 9:58

Would tikz-cd help?

I've mocked up the symbols you didn't define.

\documentclass{article}
\usepackage{tikz-cd}
\begin{document}

\begin{tikzcd}[column sep=large,row sep=large]
\Sigma \cap X_N
 \arrow{r}{F_f}
 \arrow[swap]{d}{I}
&
\mathcal{P}
 \arrow{d}{P^{\Pi(E){\cdot}{\cdot}}}
\\
\Sigma \cap X_N
 \arrow{r}{\tilde{F}_f}
 \arrow[swap]{d}{\theta_{B_N}}
&
Y_M
 \arrow{d}{\theta_{C_M}}
\\
\Sigma
 \arrow{r}{\hat{F}_f}
&
R^M
\end{tikzcd}
\end{document}

enter image description here

share|improve this answer
    
Oh, I didn't realize there was a package for commutative diagrams. All examples I found online were using Tikz's matrix library. Thanks a lot for the hint, I will vertainly give it a try. But coming back to my original question: is there a simple Tikz option to accomplish the same with my existing code above? P.S.: Sorry for not providing all symbol definitions. –  Joerg Jun 19 '13 at 11:53
    
@Joerg You can still edit your question to include a minimal working example (MWE). –  Qrrbrbirlbel Jun 19 '13 at 12:58

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.