TikZ 基本命令集

TikZ 基本命令汇集, 以及编译结果.

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
%\tikzstyle{every node}=[draw,shape=circle];  %set the form of every node
\path (0,0) node[draw,shape=circle] (v0) {$v_0$};  %不建议,有点麻烦

\node[draw,shape=circle] (v5) at (4,0) {$v_5$};

\node[below] (v1) at (1,0) {$v_1$}; %(v1) 和 $v_1$ 均可省略,但一般省略一个

\node[above right] (v3) at (2,-1) { };

\node[below] at (2,-2) {b}; %% 这几个位置还可以加距离, 如 below=0.2 之类 (默认单位是 cm)

\node (c) at (2,-2) {c}; %center

\node[above] at (2,-2) {a};

\node[left] at (2,-2) {l};

\node[right] at (2,-2) {r};

\coordinate[label=above:$v_2$] (v2) at (2,0);

\coordinate (v4) at (3,0);

%  \coordinate[label=above:$v_6$] (v6) at (v4)++(1,2);

\path (v4)++(1,2) coordinate[label=above:$v_6$] (v6);  %%这个没找到用 coordinate 替换的方法

\filldraw[fill=gray] (-2,-1) rectangle (-1,0); %%同时更新当前点的位置为(-1,0)

\filldraw[fill=red] (6,1) ellipse (2 and 1); %(6,1) center

\filldraw[fill=white] (1,2) arc (30:90:2);  %%前面的坐标是 圆弧的 起点

\draw (0,0) arc (90:270:2);  %% (0,0) 不是中心, 而是起点
\draw (0,0) arc (-45:90:2 and 1);  %% (0,0) 不是中心, 而是起点

\draw (v2) circle (1.5pt);

\draw[->] (c) -- (c |- 0,0);  %% 画 c 到 x~轴的垂线, 手册上是 xline, 但是报错说找不到,改称改成原点坐标就可以
\draw[->] (c) -- (c -| 0,0);  %% 画 c 到 y~轴的垂线, 

\filldraw (6,-2) arc (-45:90:2 and 1); %%[fill=white]  %% (6,-2) 不是中心, 而是起点
%%	\filldraw[fill=white] (6,-2) arc (-45:90:2 and 1); == \draw (6,-2) arc (-45:90:2 and 1);

\draw[color=red] (v1) -- (v3) -- (v2);
\draw (v3) -- (v6) -- (v4) -- (v1) -- (v2)
(v0) .. controls (-1,4) and (3,1) .. (v6);
\draw[thick] (v3) -- (v4)  %dashed, thick, very thick
(v0) .. controls (1,-2) and (2,-2) .. (v5)
(v0) .. controls (2,-3) .. (v5);

\filldraw[fill=white] (v4) circle (1.5pt); %%fill=white or color=white

\end{tikzpicture}

\end{document}

当然, 可以通过注释详细研究每句的意思.