# Placing a tikzpicture next to an align and add an equation number

I want to place a tikzpicture next to an equation and equip both of them together with an equation number. The reason is that the tikzpicture is a kind of explanation (visualization) for the equation. Therefore I prefer that both appear together as one "equation".

In Placing a tikzpicture next to an align it is explained how to place a tikzpicture next to an align environment using minipages. This works for me, but I have problems equipping the result with an equation number. I tried to enclose both minipages in an equation environment, but this does not really work.

• If I use align inside one of the minipages, I get two equation numbers (one for align, the other one for equation, but both actually being the name number). I would expect this, expect from both equation numbers being the same, but this is probably related to the fact that I place align inside equation. I guess one is not supposed to do this.

• If I use align* inside one of the minipages, I get no equation number at all, also the equation environment does not carry an equation number. I would expect an equation number for the equation environment.

The result of the following example looks as follows:

\documentclass[10pt]{article}

\usepackage{tikz}
\usetikzlibrary{matrix,arrows}
\usepackage{mathtools}

\usepackage[english]{babel}
\begin{document}

\begin{minipage}{0.40\linewidth} \begin{align*} A=B \end{align*} \end{minipage} \begin{minipage}{0.40\linewidth} \begin{center} \begin{tikzpicture} \matrix (m) [matrix of math nodes, column sep=20pt] { A & B \\ }; \path[->,font=\scriptsize,>=angle 90] (m-1-1) edge (m-1-2); \end{tikzpicture} \end{center} \end{minipage}

\begin{minipage}{0.40\linewidth} \begin{align} A=B \end{align} \end{minipage} \begin{minipage}{0.40\linewidth} \begin{center} \begin{tikzpicture} \matrix (m) [matrix of math nodes, column sep=20pt] { A & B \\ }; \path[->,font=\scriptsize,>=angle 90] (m-1-1) edge (m-1-2); \end{tikzpicture} \end{center} \end{minipage}
\end{document}


I don't quite understand the question but here are two options;

\documentclass[10pt]{article}
\usepackage{tikz,mathtools}
\usetikzlibrary{matrix,arrows}

\begin{document}
\begin{align}
A&=B & \begin{tikzpicture}[baseline]
\matrix (m) [circle,fill=yellow,matrix of math nodes, column sep=20pt,
ampersand replacement=\&]
{
A \& B \\
C \& D \\
};
\draw[-angle 90,font=\scriptsize]  (m-1-1) -- (m-1-2);
\end{tikzpicture} \\
C&=D &
\end{align}

\begin{minipage}{0.4\textwidth}
\begin{align}
A&=B \\
C&=D
\end{align}
\end{minipage}\hspace{2cm}
\begin{tikzpicture}[baseline]
\matrix (m) [circle,fill=yellow,matrix of math nodes, column sep=20pt,
ampersand replacement=\&]
{
A \& B \\
C \& D \\
};
\draw[-angle 90,font=\scriptsize]  (m-1-1) -- (m-1-2);
\end{tikzpicture}
\end{document}


• Probably I simplified my question too much. In my case the align() environment at the left actually contains an xymatrix that showing a commutative diagram containing several lines. This xymatrix, together with the tikzpicture at the right should should get a single equation number. I guess the use of align at the left hand side is not essential here (I just use it to enclose xymatrix). Maybe I can just use an equation environment containing xymatrix plus some horizontal space plus the tikzpicture. I tried this and only a problem with vertical alignment remains, but this is another issue. – user44400 May 17 '14 at 12:56