答案1
快速尝试:
\documentclass{article}
\usepackage{tikz,array}
\usetikzlibrary{positioning,decorations.pathmorphing}
\newcommand{\Interval}[4]{%
\tikz{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{.35cm}#2$] (a) at (0,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{.35cm}#4$] (b) at (1.6,0);
\draw[-{latex},] decorate[decoration=zigzag] {(a)--(b)} (-.4,0)--(2,0);
}
}
\begin{document}
\newcommand{\insertinterval}[1]{\rule{0in}{.7cm}\parbox{2.5cm}{#1}}
\begin{tabular}{|c|c|c|} \hline
\insertinterval{\Interval{[}{a}{]}{b}} & $ ? < x < ? $ & $? a , b?$ \\ \hline
\insertinterval{\Interval{[}{a}{]}{b}} & $ ? < x < ? $ & $? a , b?$ \\ \hline
\insertinterval{\Interval{]}{a}{[}{b}} & $ ? < x < ? $ & $? a , b?$ \\ \hline
\insertinterval{\Interval{]}{a}{[}{b}} & $ ? < x < ? $ & $? a , b?$ \\ \hline
\insertinterval{\Interval{ }{ }{ }{ }} & $ ? < x < ? $ & $? a , b?$ \\ \hline
\end{tabular}
\end{document}
我们定义一个接受四个参数的\newcommand
名称,如下所示:\Interval
\newcommand{\Interval}[4]{%
\tikz{%
\coordinate [label={center:$#1$},label=below:$\rule{0pt}{.35cm}#2$] (a) at (0,0);
\coordinate [label={center:$#3$},label=below:$\rule{0pt}{.35cm}#4$] (b) at (1.6,0);
\draw[-{latex},] decorate[decoration=zigzag] {(a)--(b)} (-.4,0)--(2,0);
}
}
并在表中需要的地方调用它。