实线上的区间。如何构造实线上实数区间的符号图?

实线上的区间。如何构造实线上实数区间的符号图?

我正在尝试详细说明我的学生在数轴上区间符号的练习。

我尝试使用此回复的 LaTeX 代码这里在数轴上画出与下图相同的区间。但我没能画出黑色阴影部分,也没能画出内部为白色的圆,也没能画出内部为黑色的圆。

你可以帮帮我吗?

在此处输入图片描述

答案1

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary[arrows.meta]
\begin{document}
  \begin{tikzpicture}[
line/.style = {draw,thick, 
               shorten >=-2pt, shorten <=-2pt}
                     ]
\draw (-3,0) -- (7,0);
\foreach \i in {-3,-2,...,7} % numbers on line
\draw (\i,0.15) -- ++ (0,-0.3) node[below] {$\i$}; % tick and their labels

\draw[line, {Circle[length=4pt]}-{Circle[length=4pt, fill=white]}]  (1,0) -- (2,0);
\draw[line, {Circle[length=4pt, fill=white]}-{Circle[length=4pt]}]  (3,0) -- (4,0);
\draw[line, {Circle[length=4pt]}-{Triangle[length=4pt]}]  (5,0) -- (7,0);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

对于任何类型的间隔,您都可以定义自己的样式,其中定义了线选项,即包含现在写在\draw选项中的选项:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
  \begin{tikzpicture}[
line/.style = {draw,thick, shorten <=-2pt},
  La/.style = {line, shorten >=-2pt, 
               {Circle[length=4pt]}-{Circle[length=4pt, fill=white]}},
  Lb/.style = {line, shorten >=-2pt,
               {Circle[length=4pt, fill=white]}-{Circle[length=4pt]}},
  Lc/.style = {line, 
               {Circle[length=4pt, fill=white]}-{Triangle[length=4pt]}},
                     ]
\draw (-3,0) -- (7,0);
\foreach \i in {-3,-2,...,7} % numbers on line
\draw (\i,0.15) -- ++ (0,-0.3) node[below] {$\i$}; % tick and their labels

\draw[La]  (1,0) -- (2,0);
\draw[Lb]  (3,0) -- (4,0);
\draw[Lc]  (5,0) -- (7,0);
\draw[Lc]  (-1,0) -- (-3,0);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

编辑:我试着考虑 OP 的评论。由于我不太清楚,以下建议是基于猜测的。如果您喜欢数字线为灰色,只需添加选项gray,间隔更粗。如果喜欢更粗的间隔线,thick您可以尝试ultra thick。如果这对您来说仍然太小,您可以将其替换为line width=<desired width>

尝试考虑 OP 评论的一个例子是:

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
  \begin{tikzpicture}[
line/.style = {draw, ultra thick, shorten <=-2pt},
  La/.style = {line, shorten >=-2pt,
               {Circle[length=4pt, line width=1pt]}-{Circle[length=4pt,line width=1pt, fill=white]}},
  Lb/.style = {line, shorten >=-2pt,
               {Circle[length=4pt, line width=1pt, fill=white]}-{Circle[length=4pt, line width=1pt]}},
  Lc/.style = {line,
               {Circle[length=4pt, line width=1pt, fill=white]}-{Triangle[length=4pt, line width=1pt]}},
                     ]
\draw[gray] (-3,0) -- (7,0);    % <---
\foreach \i in {-3,-2,...,7} % numbers on line
\draw[gray] (\i,0.15) -- ++ (0,-0.3)    % <---
    node[below,text=black] {$\i$}; % tick and their labels

\draw[La]  (1,0) -- (2,0);
\draw[Lb]  (3,0) -- (4,0);
\draw[Lc]  (5,0) -- (7,0);
\draw[Lc]  (-1,0) -- (-3,0);
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容