我想在下图中的标签下添加一个(下)括号,分别表示标记为“A”和“B”的结构部分。我的做法使括号太接近实际结构:
\documentclass[10pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{matrix,decorations.pathreplacing}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw[blue] (0,0) grid (3,2);
\draw[pattern=dots, pattern color=blue, draw=blue](2,0)rectangle+(1,1);
\draw[pattern=dots, pattern color=blue, draw=blue](2,1)rectangle+(1,1);
\path [(0,2) -- (2,2)];
\draw [decoration=brace, decorate] (0, 2.west |-0,2) -- (2,2.east |-0,2)
node [midway, above=.25ex, font=\footnotesize] {A};
\path [(2,2) -- (3,2)];
\draw [decoration=brace, decorate] (2, 2.west |-2,2) -- (3,2.east |-3,2)
node [midway, above=.25ex, font=\footnotesize] {B};
\end{tikzpicture}\hspace*{3em}
\end{frame}
\end{document}
答案1
括号可以用 来加高raise
。由于我不太明白您是否需要过度括号或不足括号,因此我添加了两个选项(并从代码中删除了几个错误)。
\documentclass[10pt]{beamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{patterns}
\usetikzlibrary{matrix,decorations.pathreplacing}
\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw[blue] (0,0) grid (3,2);
\draw[pattern=dots, pattern color=blue, draw=blue](2,0)rectangle+(1,1);
\draw[pattern=dots, pattern color=blue, draw=blue](2,1)rectangle+(1,1);
\path (0,2) -- (2,2);
\draw [decoration={brace,raise=1pt}, decorate,thick] (0, 2) -- (2,2)
node [midway, above=.25ex, font=\footnotesize] {A};
\path (2,2) -- (3,2);
\draw [decoration={brace,raise=1pt}, decorate,thick] (2, 2) -- (3,2)
node [midway, above=.25ex, font=\footnotesize] {B};
\end{tikzpicture}
\begin{tikzpicture}
\draw[blue] (0,0) grid (3,2);
\draw[pattern=dots, pattern color=blue, draw=blue](2,0)rectangle+(1,1);
\draw[pattern=dots, pattern color=blue, draw=blue](2,1)rectangle+(1,1);
\path (0,2) -- (2,2);
\draw [decoration={brace,raise=1pt,mirror}, decorate,thick] (0,0) -- (2,0)
node [midway,below=.25ex, font=\footnotesize] {A};
\path (2,2) -- (3,2);
\draw [decoration={brace,raise=1pt,mirror}, decorate,thick] (2,0) -- (3,0)
node [midway,below=.25ex, font=\footnotesize] {B};
\end{tikzpicture}
\end{frame}
\end{document}