答案1
您可以考虑使用tikzmark
。基本上,这个想法是在数学周围放置标记,然后使用这些标记将括号和标签放置在覆盖的中tikzpicture environment
。
您需要在文档中为此留出足够的空间,即在图表上方和下方留出一些额外的空间,以便当括号和标签覆盖在页面上时,它们会占据空间,而不会与内容冲突。或者,您可以单独创建图表,然后将其作为图形图像包含。
代码:
\documentclass[11pt,a4paper]{article}
\usepackage{mathtools,tikz}
\usetikzlibrary{tikzmark,decorations.pathreplacing}
\begin{document}
\tikzmark{a}
\[
\tikzmark{c}[1,2,3,\dots]\tikzmark{d}\;\tikzmark{e}[1/2,3/2,\dots]\tikzmark{f}\;\tikzmark{g}[\sqrt{2},\sqrt{3},\dots]\tikzmark{h}\;\tikzmark{m}[\pi,\dots]\tikzmark{n}
\]
\tikzmark{b}
\begin{tikzpicture}[remember picture, overlay, decoration={brace, amplitude=5pt}]
\foreach \i / \j in {a/0, b/10pt, c/0, d/0, e/0, f/0, g/0, h/0, m/0, n/0} \coordinate (\i) at ([yshift=\j]{pic cs:\i});
\draw [decorate] (c |- a) -- (a -| f) node (r) [midway, above, yshift=5pt] {Rationals};
\draw [decorate] (g |- a) -- (a -| n) node [midway, above, yshift=5pt] {Irrationals};
\draw [decorate] (b -| h) -- (c |- b) node [midway, below, yshift=-5pt] {Algebraics};
\draw [decorate] (b -| n) -- (m |- b) node [midway, below, yshift=-5pt] {Transcendentals};
\draw [decorate] (c |- r.north) -- (r.north -| n) node [midway, above, yshift=5pt] {Reals};
\end{tikzpicture}
\end{document}
答案2
实现此目的的一种可能性是使用underoverlap
包。要理解以下代码,请同时查看其文档。
\documentclass{article}
\usepackage{amsmath}
\usepackage{underoverlap}
\begin{document}
\[
\overbrace{
\UOLunderbrace{
\overbrace{
\boxed{1,2,3,\dots \text{ Integers}\vphantom{\sqrt{2}}}
\quad
\boxed{1/2,3/2,\dots\vphantom{\sqrt{2}}}
}^{\text{Rational Numbers}}
\quad
}[
\boxed{\sqrt{2},\sqrt{3},\dots}
]_{\text{Algebraic Numbers}}
\UOLoverbrace{
\quad
\underbrace{\boxed{\pi,e,\dots\vphantom{\sqrt{2}}}}_text{\makebox[0pt]{Transcendental Numbers}}
}^{\text{Irrationals}}
}^{\text{Real Numbers}}
\]
\end{document}
为了理解这一点,您可以在第一次阅读时忽略以下装饰命令:
答案3
这是一个pstricks
解决方案,尽可能忠实于 OP 的帖子。它依赖于命令\psDefBoxNodes
,来自pst-node
,允许将文本定义的框视为其轮廓上有 $10$ 个节点,其中有 $2$ 个节点(在框的中心和基线的中心),从而允许非常精确的连接。另外,我使用无衬线字体 Cabin Condensed:
\documentclass[x11names]{article}%
\usepackage[utf8]{inputenc}
\usepackage[TS1,T1]{fontenc }
\usepackage{fourier}
\usepackage{cabin}
\usepackage{amsmath}
\usepackage{auto-pst-pdf}
\usepackage{pst-node}%
\newlength\myboxwd
\settowidth\myboxwd{\textsf{1/3, 7/2, etc.}}
\newcommand\mystrut{\vphantom{\sf g$\mathsf{\sqrt 3}$}}
\newcommand\myBoxNodes[2]{\psDefBoxNodes{#1}{\fcolorbox{IndianRed4! 75!}{white}{\mystrut\makebox[\myboxwd]{#2}}}}
\begin{document}
\fontfamily{CabinCondensed-TLF}\selectfont
\setlength\fboxrule{1pt}
\begin{postscript}
\myBoxNodes{INT}{Integers} \enspace\myBoxNodes{FR}{1/3, 7/2, etc.}\enspace \myBoxNodes{ALG}{$\mathsf{\sqrt \text{2}, \sqrt \text{3}}$, etc.} \enspace \myBoxNodes{TR}{$\mathsf{\pi}$, e, etc.}
\psset{shortput = nab, nodesep=3pt, angle=90, arm=6pt, linearc=0.1, linewidth=0.6pt, linecolor=IndianRed3! 60!}
\pcbar[nodesep=16pt, arm=10pt, linearc=0.15](INT:tl)(TR:tr)^{Real Numbers}
\pcbar(INT:tl)(FR:tr)^{Rationals} \pcbar(ALG:tl)(TR:tr)^{Irrationals}
\psset{angle=-90}
\pcbar(ALG:br)(INT:bl)^{Algebraic Numbers} \pcbar(TR:br)(TR:bl)^{\makebox[0pt]{Transcendentals}}
\end{postscript}
\end{document}