我需要使用 TikZ 在我的 latex 中绘制下图。我做了以下操作:
\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\draw (0,0) circle (1cm);
\draw (1,-.3) node[right] {(2,0)};
\draw (-1,-.3) node[left] {(-2,0)};
\end{tikzpicture}
但是我怎样才能为上方的半圆添加阴影以及如何在中间绘制箭头?
附加问题 非常感谢您的回答。但我还有一个疑问:如果我在问题中使用这些命令,我会让图表右对齐并位于问题上方。但我需要它位于问题旁边。有时我需要准确定义我想要它的位置。我该怎么办?
\question Evaluate $\displaystyle\iint_R dxdy,$ where $R$ is the shaded region in the figure.
\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\draw (0,0) circle (1cm);
\draw (1,-.3) node[right] {(2,0)};
\draw (-1,-.3) node[left] {(-2,0)};
\draw[pattern=north west lines] (-1,0) --(1,0) arc[start angle=0, end angle=180, radius=1cm];
\end{tikzpicture}
答案1
也许有更好的方法,但这是一种蛮力方法。您需要在序言中加载tikzlibraries
patterns
and 。arrows.meta
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns, arrows.meta}
\begin{document}
\begin{tikzpicture}
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\draw (0,0) circle (1cm);
\draw (1,-.3) node[right] {(2,0)};
\draw (-1,-.3) node[left] {(-2,0)};
\draw[pattern=north west lines] (0,-1) --(0,1) arc[start angle=90, end angle=-90, radius=1cm];
\draw[-{To[length=5pt,width=10pt]}] (0,-1) arc[start angle=-90, end angle=-45, radius=1cm];
\draw[-{To[length=5pt,width=10pt]}] (0,1) arc[start angle=90, end angle=135, radius=1cm];
\end{tikzpicture}
\end{document}
答案2
这使用装饰和\clip
。
\documentclass[tikz]{standalone}
\usetikzlibrary{patterns,decorations.markings}
\begin{document}
\begin{tikzpicture}[arrowmark/.style 2 args={decoration={markings,mark=at position #1 with \arrow{#2}}}]
\draw (-2,0) -- (2,0);
\draw (0,-2) -- (0,2);
\begin{scope}
\clip (0,-1) rectangle (1,1);
\draw[draw=none,pattern=north west lines,pattern color=black!50](0,0)
circle(1cm);
\end{scope}
\draw[postaction={decorate},arrowmark={.375}{>},arrowmark={.875}{>}
] (0,0) circle (1cm);
\draw (1,-.3) node[right] {(2,0)};
\draw (-1,-.3) node[left] {(-2,0)};
\end{tikzpicture}
\end{document}
答案3
使用 PSTricks 只是为了好玩。
\documentclass[pstricks,border=12pt,12pt]{standalone}
\begin{document}
\begin{pspicture}(-5,-5)(5,5)
\pswedge[fillstyle=vlines,hatchcolor=gray]{3}{-90}{90}
\psline(0,-5)(0,5)
\psline(-5,0)(5,0)
\psset{arrows=->,arrowscale=2}
\psarc(0,0){3}{-46}{135}
\psarc(0,0){3}{134}{-45}
\uput[-90](4,0){$(2,0)$}
\uput[-90](-4,0){$(-2,0)$}
\end{pspicture}
\end{document}