Answer

问题及解答

[PGF]直线(线段)的画法

Posted by haifeng on 2012-04-12 12:44:44 last update 2012-04-12 14:12:27 | Edit | Answers (0)

1. 直接指定坐标, 然后使用\draw命令将它们连接起来.

\begin{tikzpicture}
\draw (0,0) -- (2,1);
\end{tikzpicture}

2. 但有时, 对于端点若给定名称, 如线段 $AB$, 则更容易理解, 并且有利于进一步使用它们.

\begin{tikzpicture}
\coordinate (A) at (0,0);% 定义 A 点的坐标是 (0,0)
\coordinate (B) at (2,1);
\draw[blue] (A) -- (B);
\end{tikzpicture}

3. 如果需要在端点旁标记 $A$, $B$, 并使用某种颜色, 则可以对\coordinate命令添加如下选项.

\begin{tikzpicture}
\coordinate [label=left:\textcolor{blue}{$A$}] (A) at (0,0);
\coordinate [label=right:\textcolor{blue}{$B$}] (B) at (1.25,0.25);
\draw[blue] (A) -- (B);
\end{tikzpicture}

A B