1

There are many examples of the coproduct in tikz with straight edges, however I can not find any (that work) or without a special package (other than tikz) for the product. I would just like to be able to be able to reproduce this picture of a product in tikz, or possibly another method that is easy to understand so as to update and add arrows if need be.

I have tried to turn the following in to the diagram that I would like, however all the arrows and everything get pushed together (the arrows are extremely small). My thought was to extend $\prod_{i \in I} A_i$ to the left, then of course change the symbols. Note that I got the following from here:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
  \node (C) {$C$};
  \node (P) [below of=C] {$\prod_{i \in I} A_i$};
  \node (Ai) [right of=P] {$A_i$};
  \draw[->] (C) to node {$f_i$} (Ai);
  \draw[->, dashed] (C) to node [swap] {$\langle f_i \rangle_{i \in I}$} (P);
  \draw[->] (P) to node [swap] {$\pi_i$} (Ai);
\end{tikzpicture}
\end{document}
  • 1
    You mention code you can't get working. Could we please see it? It might make a useful starting point. Also, do you want to do this in tikz-cd? You've tagged it that way? What problem are you having exactly? It is generally simpler to draw a non-bent arrow than a bent one, so I'm a bit confused. – cfr Jul 31 '15 at 23:40
  • Thanks cfr, I had curved arrows that I was trying to get rid of as I has been trying to modify (without success) tikz code for the fibered product and there were curved arrows in that. It does seem easier to what I would like with straight arrows though. I added the code for the closest possible solution that I could find - the diagram was imploded on itself though.. – Relative0 Aug 1 '15 at 0:11
2

Something like this?

Note that the use of the positioning library and the updated syntax <direction>=of <place> helps immediately with the spacing. Only one further adjustment really was needed here to increase the height a bit. The rest is just a question of tweaking the position of the labels e.g. below or above and using sloped for the 2 requiring that option.

\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{positioning}
\begin{document}
\begin{tikzpicture}
  \node (s) {$S$};
  \node (xy) [below=2 of s] {$X \times Y$};
  \node (x) [left=of xy] {$X$};
  \node (y) [right=of xy] {$Y$};
  \draw[->] (s) to node [sloped, above] {$f_y$} (y);
  \draw[<-] (x) to node [sloped, above] {$f_x$} (s);
  \draw[->, dashed] (s) to node {$(f_x,f_y)$} (xy);
  \draw[->] (xy) to node [below] {$\pi_X$} (x);
  \draw[->] (xy) to node [below] {$\pi_Y$} (y);
\end{tikzpicture}
\end{document}

product

  • It works! Very very nice and helpful. Thanks for the help and the explanation of what the problem had been with the previous code. – Relative0 Aug 1 '15 at 7:31
3

Since you are doing commutative diagrams, I'd suggest you to use a dedicated package such as the powerfult tikz-cd (built upon TikZ) which offer you a more convenient, cleaner and shorter syntax as well as ready to use features for your diagrams. A little example with your product:

\documentclass[border=5pt]{standalone}
\usepackage{tikz-cd}

\begin{document}
\begin{tikzcd}[row sep=huge]
  & S\ar[dl,"f_{x}",swap,sloped] \ar[dr,"f_{y}",sloped] \ar[d,dashed,"{(f_{x},f_{y})}" description] & \\
X & X\times Y\ar[l,"\pi_{X}"] \ar[r,"\pi_{Y}",swap] & Y
\end{tikzcd}
\end{document}

The result:

enter image description here

  • The question was originally tagged tikz-cd. I removed it because the question didn't mention it and the code didn't use it. (It was not originally tagged tikz-pgf even though the code used just that.) Should the other tag be restored? Maybe both tags? I kind of think it should have the more generic tag in addition, since the question didn't mention tikz-cd at all...? – cfr Aug 1 '15 at 23:18

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.