我想使用花括号来说明集合 $A = (-\infty,1] \cup [2,+\infty) $,如下图所示。
但是,为了表达左侧和右侧的无穷大,我想将花括号的结尾设为直线。我该怎么做?
梅威瑟:
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
% Axis
\draw (0,0) -- (6,0) node[below]{$ x $};
% A
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(2,-1)--(0,-1) node[pos=0.5, below, font=\normalsize] (b1) {} node[left] at (0,-1) {straigt ending here ...};
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(6,-1)--(4,-1) node[pos=0.5, below, font=\normalsize] (b2) {} node[right] at (6,-1) {... straigt ending here};
\draw[very thin] (b1)--(1,-1.5) node[below] {$A$} node[below right=3pt] (c1) {};
\draw[very thin] (b2)--(c1) {};
% x-axis labels
\draw[very thin] (2,-0.1) -- (2,0.1) node[below] at (2,-0.1) {$ 1 $};
\draw[very thin] (4,-0.1) -- (4,0.1) node[below] at (4,-0.1) {$ 2 $};
\end{tikzpicture}
\end{document}
答案1
您可以简单地在支架末端画一个白色(纸张颜色)的矩形。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
% Axis
\draw (0,0) -- (6,0) node[below]{$ x $};
% A
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(2,-1)--(0,-1) node[pos=0.5, below, font=\normalsize] (b1) {};
\filldraw[white] (0,-1) rectangle ++(.07,-.1);
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(6,-1)--(4,-1) node[pos=0.5, below, font=\normalsize] (b2) {};
\filldraw[white] (6,-1) rectangle ++(-.07,-.1);
\draw[very thin] (b1)--(1,-1.5) node[below] {$A$} node[below right=3pt] (c1) {};
\draw[very thin] (b2)--(c1) {};
% x-axis labels
\draw[very thin] (2,-0.1) -- (2,0.1) node[below] at (2,-0.1) {$ 1 $};
\draw[very thin] (4,-0.1) -- (4,0.1) node[below] at (4,-0.1) {$ 2 $};
\end{tikzpicture}
\end{document}
或者,您也可以clip
在 内放置一个矩形scope
。在这种情况下,您可以在 内放置一个节点,scope
并在范围之后使用节点来定位省略号。
\documentclass[border=1cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}
\begin{document}
\begin{tikzpicture}
% Axis
\draw (0,0) -- (6,0) node[below]{$ x $};
% A
\begin{scope}
\clip (.08,-1)node(A){} rectangle ++(2,-.5);
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(2,-1)--(0,-1) node[pos=0.5, below, font=\normalsize] (b1) {};
\end{scope}
\node[left] at (A){$\cdots$};
\begin{scope}
\clip (5.92,-1)node(B){} rectangle ++(-2,-.5);
\draw [decorate,decoration={brace,amplitude=2,aspect=0.5}]
(6,-1)--(4,-1) node[pos=0.5, below, font=\normalsize] (b2) {};
\end{scope}
\node[right] at (B){$\cdots$};
\draw[very thin] (b1)--(1,-1.5) node[below] {$A$} node[below right=3pt] (c1) {};
\draw[very thin] (b2)--(c1) {};
% x-axis labels
\draw[very thin] (2,-0.1) -- (2,0.1) node[below] at (2,-0.1) {$ 1 $};
\draw[very thin] (4,-0.1) -- (4,0.1) node[below] at (4,-0.1) {$ 2 $};
\end{tikzpicture}
\end{document}