TikZ 内の環境を整列する

TikZ 内の環境を整列する

私は 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}

alignPS 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で表すことができます。nodeminipage

\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}

ここに画像の説明を入力してください

関連情報