
私は TikZ を初めて使用しており、align
環境を使用してテキストを整列させ、TikZ の線を使用してその上に何かを描画しようとしています。
alignment
しかし、TikZ 画像内に環境を配置しようとすると、pdfLaTeX がエラーを生成するという問題があります。
これが私のコードです:
\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}
しかし、常にこのエラーが発生します:
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.358 \end{align}
align
PS TikZ 環境の外側に置くと、すべて正常に動作します。
答え1
これは の問題だけではalign
なく、他のほとんどすべての 非tikz
構文でも発生します。 を、通常の LaTeX コマンドが想定される状況にする必要がありますtikz
。 これらの 1 つは、ノードのラベルです。 の解析からさらに保護するためにtikz
、以下のように にマテリアルを含めることができますminipage
。 同様の問題は、たとえば AMS 以外の にも見られますdisplaymath
。
\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}
答え2
内部では言語tikzpicture
を話す必要があります。これは、インデックス aと atikz
で表すことができます。node
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}