7

I followed this answer to create this:

enter image description here

But I end up with this:

enter image description here

Code:

\documentclass{article}

\begin{document}

\[
\lefteqn{\underbrace{\phantom{S \rightarrow A}}_{n_0}} S \rightarrow
\lefteqn{\overbrace{\phantom{A \rightarrow A A}}^{n_1}} A \rightarrow A A
\lefteqn{\underbrace{\phantom{A A \rightarrow \epsilon A}_{n_2}}} A A \rightarrow \epsilon
\lefteqn{\overbrace{\phantom{A \rightarrow \epsilon}^{n_3}}} A \rightarrow \epsilon
\]

\end{document

2 Answers 2

11

You need to pay attention to put the super- and subscripts at the right place in your code. Since it is not fully clear to me from your handwritten example in combination with the code you provide how the two latter braces should be positioned: Did you mean the following?

\documentclass{article}

\begin{document}

\[
\lefteqn{\underbrace{\phantom{S \rightarrow A}}_{n_0}} S \rightarrow
\lefteqn{\overbrace{\phantom{A \rightarrow A A}}^{n_1}} A \rightarrow 
\lefteqn{\underbrace{\phantom{A A \rightarrow \epsilon A}}_{n_2}} A A \rightarrow \epsilon
\lefteqn{\overbrace{\phantom{A \rightarrow \epsilon}}^{n_3}} A \rightarrow \epsilon
\]

\end{document}

enter image description here

Or maybe this?

\documentclass{article}

\begin{document}

\[
\lefteqn{\underbrace{\phantom{S \rightarrow A}}_{n_0}} S \rightarrow
\lefteqn{\overbrace{\phantom{A \rightarrow A A}}^{n_1}} A \rightarrow 
\lefteqn{\underbrace{\phantom{A A \rightarrow \epsilon}}_{n_2}} A A \rightarrow \epsilon
\lefteqn{\overbrace{A \rightarrow \epsilon}^{n_3}}
\]

\end{document}

enter image description here

7

You can use the oubraces package:

\documentclass{article}
\usepackage{oubraces}

\begin{document}

\[
\overunderbraces
  {&&\br{3}{n_1}&&\br{1}{n_3}}
  {&S\to & A & \to & AA & \to \epsilon & A \to \epsilon}
  {&\br{2}{n_0}&&\br{2}{n_2}}
\]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .