
絵を描いて、その下に特定の記号 (この場合は等号) に合わせていくつかの方程式を書きたいと思います。
\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
で定義された環境内にある必要がありました。amsmath
mathtools
- 位置決めには
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}