Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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". –  Matthew Leingang Apr 4 '13 at 12:46
add comment

2 Answers

up vote 6 down vote accepted

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}
share|improve this answer
    
thanks, that's exactly what i was looking for –  ifreak Apr 4 '13 at 8:45
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

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.