答案1
这几乎是从 pgf 手册的第 50.6.1 节逐一复制而来。
\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,% switch on markings
mark=between positions 0.1 and 0.9 step 12mm with {\arrow{stealth}}},
dot/.style={circle,inner sep=1pt,fill}]
\draw[postaction={decorate},red] (0,0) node[dot,label=right:{$P_2(2,2)$}]{}
arc[start angle=45,end angle=-135,radius=2]
node[dot,label=left:{$P_2(-2,-2)$}]{}
-- cycle;
\end{tikzpicture}
\end{document}
答案2
\tikzset
对于您将多次使用的样式,使用这种方法通常很有用。在下面的代码中,添加multarrow
到\draw
选项将为路径添加五个箭头。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\tikzset{multarrow/.style={decoration={markings,mark=between positions 0.1 and 1 step 0.2 with {\arrow{>}}},postaction={decorate}}}
\begin{document}
\begin{tikzpicture}
\draw[multarrow, red, thick] (-2,-2)node[fill, circle, inner sep=1pt, label={[below left] $P_1(-2,-2)$}]{}
-- (2,2)node[fill, circle, inner sep=1pt, label={[right] $P_2(2,2)$}]{}
arc(45:-135:{2*sqrt(2)})node[below right, pos=.3]{$\gamma$};
\end{tikzpicture}
\end{document}