不等式解中的实线

不等式解中的实线

在解决一元线性不等式时,我想显示数轴。如何绘制这样的实线?

不等式解

答案1

这是一个 MWE,它可以满足您的大部分要求:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\pagestyle{empty}
\begin{document}

\begin{tikzpicture}[x=0.25cm,y=1cm]
  \coordinate (A/l) at (-4,0);
  \coordinate (A/r) at (6,0);

  \coordinate (A/lt/6/l)  at ($(-4,0)+(0,2)$);
  \coordinate (A/lt/6/r)  at ($(6,0)+(0,2)$);

  \coordinate (A/gt/-4/l)  at ($(-4,0)+(0,1)$);
  \coordinate (A/gt/-4/r)  at ($(6,0)+(0,1)$);

  \foreach 
    \pt 
    in 
    {A,A/lt/6,A/gt/-4} 
    { 
      \draw ($(\pt/l)-(2em,0)$) -- ($(\pt/r)+(2em,0)$);
    } 

  %% create and draw end points for each level of graph
  \node[draw,fill,inner sep=4pt,circle] (A/lt/6/n)  at (A/lt/6/r) {};
  \node[draw,inner sep=4pt,circle]      (A/gt/-4/n) at (A/gt/-4/l) {};
  %%
  \node[draw,fill,inner sep=4pt,circle] (A/r/n)  at (A/r) {};
  \node[draw,inner sep=4pt,circle]      (A/l/n)  at (A/l) {};

  %% draw horizontal lines for each level of graph
  \draw[line width=4pt,arrows=->]       (A/lt/6/n) --  ($(A/lt/6/l)-(2em,0)$);
  \draw[line width=4pt,arrows=->]       (A/gt/-4/n) -- ($(A/gt/-4/r)+(2em,0)$);
  \draw[line width=4pt]                 (A/r/n)    -- (A/l/n);
  %% draw vertical lines
  \draw[dashed] ($(A/lt/6/l)+(0,3ex)$) -- ($(A/l)-(0,5ex)$);
  \draw[dashed] ($(A/lt/6/r)+(0,3ex)$) -- ($(A/r)-(0,5ex)$);

  \node at ($(A/lt/6/n)+(-60:3ex)$) {$6$};  
  \node at ($(A/r/n)+(-60:3ex)$)    {$6$};  

  \node at ($(A/gt/-4/n)+(-140:4ex)$) {$-4$};
  \node at ($(A/l/n)+(-140:4ex)$)     {$-4$};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

这是一个使用 Tikz 并使用 tikz 样式的条件的解决方案(因此您可以将圆圈放置在所需的位置,从 0(开始)到 .5(一半)到 1(结束)。

命令如下:空/满取决于您想要显示的圆圈类型。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}

\usetikzlibrary{decorations.markings}

\tikzset{
    thickest/.style={line width=3pt},
    empty/.style={decoration={markings,
    mark=at position #1 with {\fill[white,draw=black,thin] circle (3pt);}},postaction={decorate}},
    full/.style={decoration={markings,
    mark=at position #1 with {\fill circle (3pt);}},postaction={decorate}},
}


\begin{document}
\begin{tikzpicture}[x=3mm,y=1.2em]
       \draw (-4,0) -- (6,0);
       \draw (-8,2) -- (10,2);
       \draw (-8,4) -- (10,4);

       \draw[dashed] (-4,-1) -- (-4,6);
       \draw[dashed] (6,-1) -- (6,6);

       \node[anchor=north east] at (-4,0) {-4};
       \node[anchor=north west] at (6,0) {6};
       \node[anchor=north east] at (-4,2) {-4};
       \node[anchor=north west] at (6,4) {6};

% ARROWS

\draw[thickest,empty=0,full=1] (-4,0) -- (6,0);
\draw[thickest,empty=0,-stealth] (-4,2) -- (10,2);
\draw[thickest,full=0,-stealth] (6,4) -- (-8,4);


\end{tikzpicture}
\end{document}

答案3

像往常一样,使用 PSTricks 只是为了好玩。我认为数字不应该重复,以节省更多击键次数。

\documentclass[pstricks,border=12pt]{standalone}
\begin{document}
\begin{pspicture}(7,4)
    \psset{linewidth=.5\pslinewidth,linestyle=dashed}
    \psline(2,.5)(2,3.5)
    \psline(5,.5)(5,3.5)
    \uput[d](2,.5){$-4$}
    \uput[d](5,.5){$6$}
    \psset{linewidth=5\pslinewidth,linestyle=solid}
    \psline{o-*}(2,1)(5,1)
    \psline{o->}(2,2)(6,2)
    \psline{<-*}(1,3)(5,3)
\end{pspicture}
\end{document}

在此处输入图片描述

相关内容