如何將點保存為 tkz-euclide 中的變量

如何將點保存為 tkz-euclide 中的變量

如何在 tkz-euclide 中定義一個點以供以後使用?顯然下面的程式碼不起作用。我知道我可以使用類似\def\x1{1} \def\y1{1} \def\x2{2} \def\y2{0}在每個 tikzpicture 中定義點的方法來保存 xy 座標,但我更喜歡定義整個點並在所有 tikzpictues 中使用它。是否可以?

\documentclass{article}
\usepackage{tkz-euclide}
\tkzDefPoint(1,1){A}
\tkzDefPoint(2,0){B}

\begin{document}

\begin{tikzpicture}
\tkzDrawSegment(A,B)
\end{tikzpicture}

\end{document}

答案1

您可以用來coordinate保存積分。以後可以在全域使用該座標。

\documentclass{article}
\usepackage{tkz-euclide}

\begin{document}

\begin{tikzpicture}
    \coordinate (A) at (1,1);
    \coordinate (B) at (2,0);
    \tkzDrawSegment(A,B)
\end{tikzpicture}

\begin{tikzpicture}
    \tkzDrawSegment(A,B)
\end{tikzpicture}

\end{document}

相關內容