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 make a lot of commutative diagrams and am trying to switch to Tikz from amcd,diagrams, etc. I often have to refer to these diagrams in the text and would rather have them as equations (i.e. with and equation number) rather than a figure. I have tried just putting it in an equation environment but it neither centers the diagram (as ma)

share|improve this question
Please explain more why putting them as figures is no good. Presumably because you want to refer to commutative diagrams as if they were equations? Buy why can't you just refer to figures instead? – Seamus Oct 20 '10 at 12:21
@Seamus: In a math paper, commutative diagrams are functionally like equations, so the coherent thing is to label both in the same way. In a math paper, in which one customarily refers to dozens, if not hundreds, of equations, writing "Figure 32" instead of (32) is cumbersome. Also the label "Figure 32" takes up more (vertical) space than does a margin equation number. Surely there are still other reasons, but those are what occur to me. – Dan Fox Sep 10 '13 at 16:32
up vote 33 down vote accepted
\begin{tikzpicture}[baseline=(current  bounding  box.center)]

Copied from Mtikz.pdf.

share|improve this answer
That's really slick---the [baseline=(current bounding box.center)] centers the equation reference number, rather than having it at the bottom of the picture. – Leah Wrenn Berman Oct 20 '10 at 18:02
Exactly. "equation" puts the reference number on the baseline of the picture, so the solution is to move the baseline. – Mephisto Oct 20 '10 at 18:55
And it works for all sorts of other things, too, like labelling for lists! that's great---thanks! – Leah Wrenn Berman Oct 20 '10 at 19:59
Could the example about be edited to include \hbox, then the answer would be complete? – user1536 Oct 21 '10 at 8:53
I don't understand your comment --- there is no need for \hbox. Did you even try it? – Mephisto Oct 21 '10 at 13:39

just place the TikZ picture into a box, for example using \text{} (which is an AMS command).

In case you do not use AMS, you can also use \hbox (which is a plain TeX command) instead.

Example which compiles without extra packages:

\hbox{\tikz\draw[draw=black,fill=red] (0,0) circle (5pt);}

In (\ref{eq:test}), we see a TikZ picture.\dotfill


share|improve this answer
This is still using a distinct counter from the one used in the equation environment, so this might not work how the OP wanted it to... – Seamus Oct 20 '10 at 13:16
@Seamus: How is the counter distinct? @user1537: \eqref handles the parentheses. – TH. Oct 20 '10 at 13:51
Thanks , hbox works for generating an appropriate equation number, but I am using the tikzpicture environment, which seems to conflict with \text{} which for some reason it doesnt like and the equation number is not placed correctly (at the bottom of the diagram rather than the middle). – user1536 Oct 20 '10 at 14:17
@user1536: Use \vcenter instead of \hbox. – TH. Oct 20 '10 at 15:21
@TH Sorry, I didn't notice that you'd wrapped the hbox in an equation environment, I thought hbox had its own counter, that was distinct. I see now what you mean... – Seamus Oct 20 '10 at 16:26

To put the equation number on top or bottom (which is the default) just use the following commands:

\begin{tikzpicture}[baseline=(current  bounding  box.north)]


\begin{tikzpicture}[baseline=(current  bounding  box.south)]

which is the default.

share|improve this answer

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.