答案1
这是一个开始:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usetikzlibrary{shapes.multipart}
\usetikzlibrary{positioning}
\usetikzlibrary{patterns}
\begin{document}
\centerline{\begin{tikzpicture}[scale=3]
\draw[dashed] (-1/2,0) -- (-1/2, 4);
\draw[dashed] (1/2,4) -- (1/2,0);
\begin{scope}
\clip (-1,0) coordinate (a) |- (1,4) coordinate (b) -- (b |- a) arc (0:180:1);
\fill [pattern=north east lines] (-.5,0) coordinate (p) rectangle (.5,4) coordinate (q);
\end{scope}
\draw (-1.25,0) -- (1.25,0);
\draw (-1, -.05) -- (-1, .05);
\draw (-1/2,-.05) -- (-1/2,.05);
\draw (0,-.05) -- (0,.05);
\draw (1/2,-.05) -- (1/2,.05);
\draw (1, -.05) -- (1, .05);
\draw (-1, -.3) node {-1};
\draw (-1/2, -.3) node {-1/2};
\draw (0, -.3) node {0};
\draw (1/2, -.3) node {1/2};
\node [fill=white] at (0,2.5) {$F_1$};
\draw (1, -.3) node {1};
\draw[dashed] (-1,0) .. controls (-1,0.555) and (-0.555,1) .. (0,1)
.. controls (0.555,1) and (1,0.555) .. (1,0);
\end{tikzpicture}}
\end{document}
我不知道这是否是最有效的方法,但它确实有效。结果是
请注意,这是在 www.sharelatex.com 上完成的。
下载为 pdf 时,东北线图案显示正确。感谢 cfr 为填充矩形的难点部分和文本周围的无填充框提供了出色的解决方案。
答案2
我回答这个问题只是因为希瑟询问了我的建议,而我无法在评论中轻易地做到这一点。
我会使用裁剪来填充。想法是裁剪成一个末端带有半圆形咬口的较宽矩形,然后填充一个没有咬口的较窄矩形。
\begin{scope}
\clip (-1,0) coordinate (a) |- (1,4) coordinate (b) -- (b |- a) arc (0:180:1);
\fill [pattern=north west lines] (-.5,0) coordinate (p) rectangle (.5,4) coordinate (q);
\end{scope}
限制scope
了剪辑的效果。这会产生类似
完整代码:
\documentclass[border=10pt,multi,tikz]{standalone}
\usetikzlibrary{patterns}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-1,0) coordinate (a) |- (1,4) coordinate (b) -- (b |- a) arc (0:180:1);
\fill [pattern=north west lines] (-.5,0) coordinate (p) rectangle (.5,4) coordinate (q);
\end{scope}
\draw (-2,0) -- (2,0);
\foreach \i [count=\j] in {-1,-1/2,0,1/2,1}
{
\draw (\i,0) coordinate (x\j) edge ++(0,2pt) -- ++(0,-2pt) node [below=5pt, anchor=mid, font=\scriptsize] {\i};
}
\draw [densely dashed] (a) arc (180:0:1) (p) -- (p |- q) (q) -- (q |- p);
\node [fill=white] at (0,2.5) {$F_1$};
\end{tikzpicture}