0

I'd like to add add an (under)brace under the labels in the following diagram, indicating the part of the structure labeled "A" and "B", respectively. What I have makes the brace too close to the actual structure:

 \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}
4

Braces can be raised with raise. Since I didn't quite understand if you want overbrace or underbrace, I add both options (and removed several errors from the code).

\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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.