![在标签下添加下括号,`tikz`](https://linux22.com/image/478600/%E5%9C%A8%E6%A0%87%E7%AD%BE%E4%B8%8B%E6%B7%BB%E5%8A%A0%E4%B8%8B%E6%8B%AC%E5%8F%B7%EF%BC%8C%60tikz%60.png)
我想在下图中的标签下添加一个(下)括号,分别表示标记为“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}