ノード内の複数行数式モードがまったく機能しない

ノード内の複数行数式モードがまったく機能しない

絵を描いて、その下に特定の記号 (この場合は等号) に合わせていくつかの方程式を書きたいと思います。

\documentclass{report}
\usepackage{amsmath,tikz,mathtools}
\usetikzlibrary{shapes}
\begin{document}
    \begin{tikzpicture}
        \node[draw,regular polygon,regular polygon sides=4] (square) {};
        \node[below=of square] () {$
        Area &= side \times side \\
        Perimeter &= 4 \times side
        $}
    \end{tikzpicture}
\end{document}

残念ながらこれは機能しません。その理由はわかりません。

答え1

  • インライン数式は複数の行に分割されていませんでした。あなたの場合、数式は、およびmultlinedで定義された環境内にある必要がありました。amsmathmathtools
  • 位置決めにはpositioningライブラリを使用しますが、ロードはしません
\documentclass{report}
\usepackage{mathtools}
\usepackage{tikz}
\usetikzlibrary{positioning,
                shapes}

\begin{document}
    \begin{tikzpicture}
\node[draw,regular polygon,regular polygon sides=4] (square) {};
\node[below=of square]  
    {$\begin{aligned}
        Area        & = side \times side \\
        Perimeter   & = 4 \times side
      \end{aligned}$};
    \end{tikzpicture}
\end{document}

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

答え2

提供されたコードにはいくつかの問題があります。

  • 構文にはtikzライブラリがbelow=of ...必要でしたpositioning
  • 数式のあるノード;の後に​​ が抜けている
  • 数学ノードの内容は&=アライメント env を使用しますが、エラーが発生することはありません。

これをコンパイルすると

\documentclass{report}
\usepackage{amsmath,tikz,mathtools}
\usetikzlibrary{shapes}
\usetikzlibrary{positioning}
\begin{document}
    \begin{tikzpicture}
        \node[draw,regular polygon,regular polygon sides=4] (square) {};
        \node[below=of square] {$
          \begin{aligned}
        Area &= side \times side \\
        Perimeter &= 4 \times side
        \end{aligned}$};
    \end{tikzpicture}
\end{document}

関連情報