答案1
这是一个宏\cclasses
,它将为给定的一组类绘制图像:
\cclasses{EXPSPACE,EXPTIME,PSPACE,NP,P,NL}
\cclasses{PSPACE,NP,P}
在下面的代码中,\xcontrol
和\ycontrol
可以改变以调整椭圆的偏心率。可以通过调整 的公式来调整阴影步骤\drk
。
\documentclass{article}
\usepackage{tikz,amsmath,ifthen}
\newcommand{\xcontrol}{.4}
\newcommand{\ycontrol}{.1}
\newcommand{\mayeq}{\overset{?}{=}}
\newcommand{\cclasses}[1]{\begin{tikzpicture}
\foreach \c[count=\n] in {#1}{\xdef\numclasses{\n}}
\foreach \c[count=\n, evaluate=\n as \m using \numclasses-\n+1, evaluate=\n as \drk using 10+80*\n/\numclasses] in {#1}{
\fill[gray!\drk] (0,\m/3) ellipse ({\xcontrol+.5*\m} and {\ycontrol+.5*\m});
\ifthenelse{\n=1}{}{\node at (0,\m/3+\ycontrol+.5*\m){$\mayeq$};}
\node[right,font={\sffamily}] at (0,{(\m/3+\ycontrol+.5*\m)-.45}){\c};}
\draw ((0,\numclasses/3) ellipse ({\xcontrol+.5*\numclasses} and {\ycontrol+.5*\numclasses});
\end{tikzpicture}}
\begin{document}
\cclasses{EXPSPACE,EXPTIME,PSPACE,NP,P,NL}
\end{document}
答案2
答案3
有些事要开始。
\documentclass[tikz,border=2mm]{standalone}
\usetikzlibrary{shapes.geometric, positioning}
\begin{document}
\begin{tikzpicture}[myellipse/.style 2 args={ellipse, fill=black!#1, label={[anchor=north, below=2.5mm]#2}}, font=\sffamily]
\node[myellipse={10}{EXPSPACE}, minimum width=12cm, minimum height=6cm, draw] (e1) {};
\node[myellipse={20}{EXPTIME}, minimum width=10cm, minimum height=5cm, above=2mm of e1.south] (e2) {};
\node[myellipse={30}{PSPACE}, minimum width=8cm, minimum height=4cm, above=2mm of e2.south] (e3) {};
\node[myellipse={40}{NP}, minimum width=6cm, minimum height=3cm, above=2mm of e3.south] (e4) {};
\node[myellipse={50}{P}, minimum width=4cm, minimum height=2cm, above=2mm of e4.south] (e5) {};
\node[myellipse={60}{}, minimum width=2cm, minimum height=1cm, above=2mm of e5.south] (e6) {NL};
\end{tikzpicture}
\end{document}