我使用以下命令在实线中得到半开区间:
\begin{tikzpicture}[scale=7]
\draw[->, thick] (-0.1,0) -- (1.7,0);
\foreach \x/\xtext in {0/8,0.2/$S_1$,0.4/$T_4$,0.6/$S_3$,0.8/$T_2$,1/$S_3$,1.2/14,1.4/$S_3$,1.6/16}
\draw[thick] (\x,0.5pt) -- (\x,-0.5pt) node[below] {\xtext};
\draw (0.2,0.5pt) node[above] {$c$};
\draw[[-), ultra thick, blue] (0.2,.01) -- (.4,0.01);
\draw[(-, ultra thick, green] (0.6,.02) -- (1,0.02);
\end{tikzpicture}
现在,我需要有一个开放-关闭间隔,但我无法在最后得到那个关闭间隔,使用以下命令:
\begin{tikzpicture}[scale=7]
\draw[->, thick] (-0.1,0) -- (1.7,0);
\foreach \x/\xtext in {0/8,0.2/$S_1$,0.4/$T_4$,0.6/$S_3$,0.8/$T_2$,1/$S_3$,1.2/14,1.4/$S_3$,1.6/16}
\draw[thick] (\x,0.5pt) -- (\x,-0.5pt) node[below] {\xtext};
\draw (0.2,0.5pt) node[above] {$c$};
\draw[(-], ultra thick, green] (0.6,.02) -- (1,0.02);
\end{tikzpicture}
我可以请人帮忙吗?
答案1
当可选参数包含右括号时,请使用一对额外的括号来“隐藏它们”;否则,TeX 会认为右括号关闭了可选参数。在这种情况下,
\draw[(-], ultra thick, green] (0.6,.02) -- (1,0.02);
使用
\draw[{(-]}, ultra thick, green] (0.6,.02) -- (1,0.02);
完整示例:
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows}
\begin{document}
\begin{tikzpicture}[scale=7]
\draw[->, thick] (-0.1,0) -- (1.7,0);
\foreach \x/\xtext in {0/8,0.2/$S_1$,0.4/$T_4$,0.6/$S_3$,0.8/$T_2$,1/$S_3$,1.2/14,1.4/$S_3$,1.6/16}
\draw[thick] (\x,0.5pt) -- (\x,-0.5pt) node[below] {\xtext};
\draw (0.2,0.5pt) node[above] {$c$};
\draw[{[-)}, ultra thick, blue] (0.2,.01) -- (.4,0.01);
\draw[(-, ultra thick, green] (0.6,.02) -- (1,0.02);
\end{tikzpicture}
\begin{tikzpicture}[scale=7]
\draw[->, thick] (-0.1,0) -- (1.7,0);
\foreach \x/\xtext in {0/8,0.2/$S_1$,0.4/$T_4$,0.6/$S_3$,0.8/$T_2$,1/$S_3$,1.2/14,1.4/$S_3$,1.6/16}
\draw[thick] (\x,0.5pt) -- (\x,-0.5pt) node[below] {\xtext};
\draw (0.2,0.5pt) node[above] {$c$};
\draw[{(-]}, ultra thick, green] (0.6,.02) -- (1,0.02);
\end{tikzpicture}
\end{document}
使用该arrows.meta
库,您可以使用Arc Barb
和Bracket
箭头提示:
\documentclass{report}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,arrows}
\begin{document}
\begin{tikzpicture}[scale=7]
\draw[->, thick] (-0.1,0) -- (1.7,0);
\foreach \x/\xtext in {0/8,0.2/$S_1$,0.4/$T_4$,0.6/$S_3$,0.8/$T_2$,1/$S_3$,1.2/14,1.4/$S_3$,1.6/16}
\draw[thick] (\x,0.5pt) -- (\x,-0.5pt) node[below] {\xtext};
\draw (0.2,0.5pt) node[above] {$c$};
\draw[{Arc Barb[]}-{Bracket[]}, ultra thick, red!70!black] (0.6,.02) -- (1,0.02);
\draw[{Arc Barb[length=10pt,width=30pt]}-{Bracket[length=10pt,width=30pt]}, ultra thick, red!70!black] (0,.02) -- (0.4,0.02);
\end{tikzpicture}
\end{document}
答案2
抱歉我的英语不好,我来自 vzla,这里有一个我在间隔工作中使用的代码:
\documentclass{article,11pt,letterpaper}
\usepackage{tikz}
\usetikzlibrary {arrows.meta}
\usetikzlibrary {patterns,patterns.meta}
\begin{document}
\begin{tikzpicture}
\begin{scope}[>=latex]
\draw [line width=0.7pt][<->](-0.5,0)--(7,0);
\end{scope}
\draw [pattern={Lines[angle=45,distance={3pt/sqrt(2)}]},pattern color=blue,line width=0.6pt](4,0)--(4,0.5)--(5,0.5)--(5,0)--cycle;
\draw [pattern={Lines[angle=135,distance={3pt/sqrt(2)}]},pattern color=red,line width=0.6pt](1,0)--(1,0.5)--(4.5,0.5)--(4.5,0)--cycle;
\fill [color=black](4,0.5) circle (2.3pt);
\fill [color=white,draw=black,line width=0.7pt] (5,0.5) circle (2.3pt);
\fill [color=white,draw=black,line width=0.7pt] (1,0.5) circle (2.3pt);
\fill [color=black] (4.5,0.5) circle (2.3pt);
\draw [line width=0.7pt](0,-0.05)--(0,0.3);
\pgftext[base,x=0cm,y=-0.3cm,] {\small $0$};
\pgftext[base,x=1cm,y=-0.3cm] {\small $1$};
\pgftext[base,x=4cm,y=-0.3cm] {\small $4$};
\pgftext[base,x=4.5cm,y=-0.3cm] {\small $4.5$};
\pgftext[base,x=5cm,y=-0.3cm] {\small $5$};
\end{tikzpicture}
\end{document}
结果如下: