帮助使用 pgf 绘制图形

帮助使用 pgf 绘制图形

这是我想要绘制的图像:

图像

答案1

这也许可以做得更优雅。

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.pathreplacing,calc}
\begin{document}
\begin{tikzpicture}[%
box/.style={draw,rectangle},
decoration={brace,amplitude=4}]
  \node (posint) [box] {positive integer};
  \node (negint) [box,right=of posint] {negative integer};

  \draw [decorate,thick]
    ($(negint.south east) + (0,-.3)$) -- node (mida) {} ($(posint.south west)  + (0,-.3)$);

  \node (int) [box,below=.4cm of mida] {integer};
  \node (frac) [box,right=of int] {fractional number};

  \draw [decorate,thick]
    ($(frac.south east) + (0,-.3)$) -- node (midb) {} ($(int.south west)  + (0,-.3)$);

  \node (rational) [box,below=.4cm of midb] {rational number};

  \draw [->] (posint) -- (negint);
  \draw [->] (int) -- (frac);
\end{tikzpicture}
\end{document}

答案2

抱歉,这不使用 pgf。

\documentclass[a4paper]{article}
\usepackage{amsmath}
\newcommand{\myline}[2]{\underbrace{\,#1\,}_{#2}}
\newcommand{\dblbox}[2]{\fbox{#1}\makebox[3em]{\rightarrowfill}\fbox{#2}}
\newcommand{\mytopstrut}{\vbox to 3ex{}}
\newcommand{\mybotstrut}{\vtop to 2ex{}}
\begin{document}
\[
\myline{\dblbox{positive integer}{negative integer}\mybotstrut}{
  \hspace{11.5em}\myline{\dblbox{integer}{fractional number}\mybotstrut\mytopstrut}{
    \fbox{rational number}\mytopstrut
  }
}
\]
\end{document}

答案3

Egreg 做了我想做的事。我需要一个移动 TeX:-)
哦,好吧,这个在 eplain 中,所以希望有足够的区别:

\input eplain
\def\mybox#1{\vcenter{\boxit{\hbox{#1}}}}
\def\To{\hbox to 3em{\rightarrowfill}}
$$ \displaylines{
  \underbrace{\mybox{positive integer}\To\mybox{negative integer}}\cr
  \hfil\underbrace{\mybox{integer}\To\mybox{fractional number}}\cr
  \hfil\mybox{rational number}}
$$
\bye

相关内容