
我想畫一幅畫並在下面寫一些方程式,這些方程式將與某個符號(在本例中為等號)對齊。
\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
提供的代碼存在幾個問題。
- 文法
below=of ...
需要positioning
tikz lib - 包含數學的節點
;
後面缺少一個 - 數學節點的內容使用
&=
但沒有對齊環境,這會導致錯誤。
這編譯
\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}