TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to draw a commutative diagram having drawings as objects, like in this link which is also shown below.

enter image description here

I have some problems:

  1. xy-pic "slants" the objects;
  2. "matrix" library in TiKZ is not happy to have other TiKZ commands in the matrices I wnat to draw.

What can I do? This is a tentative answer to my problem:

\filldraw[lightgray] (0,0) -- (2,0) -- (2,1) -- (0,1) -- cycle;
\draw (0,0) -- (2,0);
\draw (0,1) -- (2,1);
\end{tikzpicture} \ar@{->>}[r]
\draw[fill=lightgray] (0,0) ellipse (.5cm and .25cm);
\filldraw[lightgray] (-.5,0) -- (.5,0) -- (.5, .6) -- (-.5, .6) -- cycle;
\draw (-.5,0) -- (-.5, .6);
\draw (.5,0) -- (.5, .6);
\draw[fill=lightgray,yshift=.6cm] (0,0) ellipse (.5cm and .25cm);

as you can see the arrow is "too low".

share|improve this question
Sorry, I thought I linked it at the right page (27)... maybe the "#page=35" part can't be read by browser different from Chrome? – Fosco Loregian May 27 '12 at 18:23
you can place nodes without matrix library. – Ignasi May 27 '12 at 18:25
I know, but I was wondering if there are some well-written solutions to this (quite natural if you handle geometric topology ;) ) problem... – Fosco Loregian May 27 '12 at 18:27
You should be able to draw inside a TikZ matrix. See page 202 (introduction to matrices) in the manual. – Caramdir May 27 '12 at 19:05
Did I include the right image? Also matrix library is quite cooperative, what kind of difficulty did you have before? – percusse May 27 '12 at 20:05

You can use tikz-cd. It is the tikz analog to xy-matrix, it easy to use, and it is reasonably flexible. Here is an example:





    \pgfuseimage{image-name} \rar[start anchor=real east] & \node[draw,circle]{A};


Note that you need to modify the anchors of the arrows (where the arrows begin and end) since the anchors of the nodes in tikz-cd are shifted for technical reasons (cf. Sec. 3.3 in the package's manual). The circle on the left is a node as defined by tikz-cd, hence adjustment is necessary. The other is a normal node, so no adjustment is necessary.

Also, note that you can use pgf to include your drawings from separate files (since it seems you use several). This has the advantage that each image is included just once in the PDF file and it can be used many times without increasing the size of the file a lot.

Edit: Example


Replace the polygons with fancier graphics, and you can get very nice diagrams with very simple code:


\usetikzlibrary{shapes} % to draw polygons


  \node[draw,regular polygon, regular polygon sides=5]{}; \rar{\varphi}
  \drar \arrow[bend right=50]{d} &
  \node[draw,circle]{}; \dlar[crossing over] \\
  \node[draw,regular polygon, regular polygon sides=6]{}; \arrow{r}[description]{\psi} &


Also, I want to stress what I wrote in one comment, tikz-cd changes the arrows parameters (only in diagrams of course) for the arrows to look exactly as the arrows from the amsmath package. Very important...

share|improve this answer
If you have the inner pictures, you don't need tikz-cd anyway. You can just use path-picture option on a node. Also tikz-cd loads TikZ so there is no need to load pgf. – percusse Aug 3 '12 at 18:37
It seems that if you don't load pgf explicitely you cannot use the command \pgfuseimage, at least in my installation. – Gustavo Aug 3 '12 at 19:04
Also, for the case-use of the OP, tikz-cd seems as a good choice since it provides an easy-to-use front-end to pgf/tikz for example to add labels and descriptions to arrows, cross-overs, control the curvature of the arrows and so on... But perhaps one of the nicests things it is that it modifies the parameters of the default arrows to make them exactly like the arrows from the amsmath package. I will add a more complicated example to show what I mean. – Gustavo Aug 3 '12 at 19:08
@percusse Actually, I was mistaken. Apparently my problem with the undefined command appeared because of loading pgf... Thanks, I have corrected my answer. – Gustavo Aug 3 '12 at 20:16
No problem, wha I meant in my slightly cocky comment is that the real challenge is to make readily made nodes that have those curves inside them for frequent use (at least that's how I read the question) otherwise you can't change the line width, color etc. (if you ever want that). Otherwise you solution is the practical way to go. – percusse Aug 3 '12 at 20:32

Your Answer


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.