8

I'm new to TikZ, and I'm trying to use the align enviroment to align some text then draw something on it using some TikZ lines.

But the problem that pdfLaTeX is generating an error whenever I try to put the alignment enviroment inside a TikZ picture.

Here's my code:

\begin{figure}
\centering
\begin{tikzpicture}

\begin{align}
    \notag &a_1,\ &b_1,\ &c_1,\ &d_1,\ &e_1\ \mbox{etc.}\\
    \notag &a_2,\ &b_2,\ &c_2,\ &d_2,\ &e_2\ \mbox{etc.}
\end{align} 

%% draw some stuff using tikz on the the aligned text.
\end{tikzpicture}
\end{figure}

but I'm always getting this error:

! Missing \endgroup inserted.
<inserted text> 
                \endgroup 
l.358 \end{align}

P.S. If I put the align outside the TikZ enviroment, everything works normally.

1
  • Perhaps your example is too minimal. Do you want to annotate the aligned elements? Because that can be done totally inside a tikzpicture with a matrix of nodes. Feel free to expand on what you intend with "draw some stuff using tikz on the aligned text". Apr 4 '13 at 12:46
8

This is not just a problem with align but with almost any other non-tikz construction. You need to put tikz in to a situation where it will be expecting ordinary LaTeX commands. One of these is the label for a node. Now to protect things further from tikz's parsing, you can include the material in a minipage as below. Similar issues would be seen with e.g. the non-AMS displaymath.

Sample output

\documentclass{article}

\usepackage{amsmath}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\node at (0,0) {
\begin{minipage}{0.9\linewidth}
  \begin{align}
    \notag &a_1,\ &b_1,\ &c_1,\ &d_1,\ &e_1\ \mbox{etc.}\\
    \notag &a_2,\ &b_2,\ &c_2,\ &d_2,\ &e_2\ \mbox{etc.}
  \end{align}
\end{minipage}
};
%% draw some stuff using tikz on the the aligned text.
\end{tikzpicture}

\end{document}
0
4

Inside tikzpicture you should speak tikz language. This can be put indise a node and a minipage.

\documentclass{article}
\usepackage{amsmath,tikz}
\begin{document}
  \begin{figure}
\centering
\begin{tikzpicture}
\node at (0,0) {%
\begin{minipage}{5cm}%adjust width here
\begin{align}
    \notag &a_1,\ &b_1,\ &c_1,\ &d_1,\ &e_1\ \mbox{etc.}\\
    \notag &a_2,\ &b_2,\ &c_2,\ &d_2,\ &e_2\ \mbox{etc.}
\end{align}
\end{minipage}
};
%% draw some stuff using tikz on the the aligned text.
\end{tikzpicture}
\end{figure}
\end{document}

enter image description here

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.