1

i am trying to write some equations and have trouble with the formatting. I assumed that having a table would be good, but if anyone has a better idea, I wanna hear your suggestion. This is my code in latex.

\begin{center}
\begin{tabular}{c c c}
$identifier ::$\\
$& identifier\_first\_character$ \\
$& \mid identifier$ & $identifier\_consecutive\_character$

\end{tabular}
\end{center}

The equation should be like this, in the image

Mico
  • 506,678
  • First, your code is no for equations. Second, you can get the same result with verbatim environment – juanuni May 19 '15 at 04:21
  • @juanuni Verbatim doesnt give a good result. I get a lot of unneccessary quotes . – GermanShepherd May 19 '15 at 04:26
  • I am going to suggest that you look at this posting http://tex.stackexchange.com/questions/127618/create-and-center-nice-ebnf for formating BNF and EBNF syntax specifications. Before you use the package (or any package) read the documentation, best found at http://texdoc.net/texmf-dist/doc/latex/mdwtools/syntax.pdf This is what I required my CS students to use for a Survey of Programming Languages course. – R. Schumacher May 19 '15 at 04:58

1 Answers1

1

With fancyvrb package you can get it

\documentclass{article}

\usepackage{lipsum}
\usepackage{fancyvrb}

\newsavebox{\FVerbBox}
\newenvironment{FVerbatim}
 {\VerbatimEnvironment
  \begin{center}
  \begin{lrbox}{\FVerbBox}
  \begin{BVerbatim}}
 {\end{BVerbatim}
  \end{lrbox}
  \mbox{\usebox{\FVerbBox}}
  \end{center}}

\begin{document}
\lipsum*[2]
\begin{FVerbatim}[fontsize=\small]
identifier ::
        identifier_first_character
      | identifier identifier_consecutive_character
\end{FVerbatim}
\lipsum[3]

\end{document}

enter image description here

juanuni
  • 1,987