我正在尝试绘制以下内容:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,
mark=at position 0.5cm with {\arrow[line width=1pt]{>}},
mark=at position 2cm with {\arrow[line width=1pt]{>}},
mark=at position 7.85cm with {\arrow[line width=1pt]{>}},
mark=at position 9cm with {\arrow[line width=1pt]{>}}
}
]
% The axes
\draw[help lines,->] (-3,0) -- (3,0) coordinate (xaxis);
\draw[help lines,->] (0,-1) -- (0,3) coordinate (yaxis);
% The path
\path[draw,line width=0.8pt,postaction=decorate] (1,0) node[below] {$\varepsilon$} -- (2,0) node[below] {$r$} arc (0:180:2) -- (-1,0) arc (180:0:1);
% The labels
\node[below] at (xaxis) {$x$};
\node[left] at (yaxis) {$y$};
\node[below left] {$O$};
\node at (0.5,1.2) {$C_{\varepsilon}$};
\node at (1.5,1.8) {$C_{r}$};
\end{tikzpicture}
\end{document}
除了只有半个圆盘的一半,换句话说,就是这条路径,但面积只有一半,沿着虚轴切开一半。我似乎无法在\path
不破坏形状的情况下改变的参数。如果这是非常基础的,我很抱歉,我是 TiKz 的新手。
答案1
由于您绘制的范围是从 0 度到 180 度(即,半径为 2,范围从 0 度到 180 度),因此该圆弧是一个完整的半圆0:180:2
。要使其成为四分之一圆,请将其绘制的范围从 0 度到 90 度(0:90:2
即,半径为 2,范围从 0 度到 90 度)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,
mark=at position 0.5cm with {\arrow[line width=1pt]{>}},
mark=at position 2cm with {\arrow[line width=1pt]{>}},
mark=at position 7.85cm with {\arrow[line width=1pt]{>}},
mark=at position 9cm with {\arrow[line width=1pt]{>}}
}
]
% The axes
\draw[help lines,->] (-3,0) -- (3,0) coordinate (xaxis);
\draw[help lines,->] (0,-1) -- (0,3) coordinate (yaxis);
更改了行
% The path
\path[draw,line width=0.8pt,postaction=decorate]
(1,0) node[below] {$\varepsilon$} --
(2,0) node[below] {$r$}
arc (0:90:2) --
(0,1) arc (90:0:1);
其余不变
% The labels
\node[below] at (xaxis) {$x$};
\node[left] at (yaxis) {$y$};
\node[below left] {$O$};
\node at (0.5,1.2) {$C_{\varepsilon}$};
\node at (1.5,1.8) {$C_{r}$};
\end{tikzpicture}
\end{document}
或者
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,
mark=at position 0.5cm with {\arrow[line width=1pt]{>}},
mark=at position 2.8cm with {\arrow[line width=1pt]{>}},
mark=at position 4.75cm with {\arrow[line width=1pt]{>}},
mark=at position 5.8cm with {\arrow[line width=1pt]{>}}
}
]
% The axes
\draw[help lines,->] (-3,0) -- (1,0) coordinate (xaxis);
\draw[help lines,->] (0,-1) -- (0,3) coordinate (yaxis);
% The path
\path[draw,line width=0.8pt,postaction=decorate]
(0,1) node[right] {$\varepsilon$} --
(0,2) node[right] {$r$}
arc (90:180:2) --
(-1,0)
arc (180:90:1);
\end{tikzpicture}
\end{document}
答案2
或者你想得到
代码:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\begin{tikzpicture}[decoration={markings,
mark=at position 0.5cm with {\arrow[line width=1pt]{>}},
mark=at position 2cm with {\arrow[line width=1pt]{>}},
mark=at position 4.75cm with {\arrow[line width=1pt]{>}},% <- changed
mark=at position 6cm with {\arrow[line width=1pt]{>}}% <-changed
}
]
% The axes
\draw[help lines,->] (-3,0) -- (3,0) coordinate (xaxis);
\draw[help lines,->] (0,-1) -- (0,3) coordinate (yaxis);
% The path
\newcommand\qangle{45}
\path[draw,line width=0.8pt,postaction=decorate]
(\qangle:1)coordinate(e)
-- ([turn]0:1)coordinate(r)
arc (\qangle:{\qangle+90}:2)coordinate[midway](Cr)
-- ([turn]90:1)
arc ({\qangle+90}:\qangle:1)coordinate[midway](Ce)
;
% The labels
\node[below] at (xaxis) {$x$};
\node[left] at (yaxis) {$y$};
\node[below left] {$O$};
\node[below right]at(e){$\varepsilon$};
\node[below right]at(r) {$r$};
\node[above right]at(Cr){$C_{r}$};
\node[above right]at(Ce){$C_{\varepsilon}$};
\end{tikzpicture}
\end{document}
也可以使用其他值来表示\qangle
like0
或90
。
有了\newcommand\qangle{0}
它,\node[below]at(e){$\varepsilon$};\node[below]at(r) {$r$};
你就会得到