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

3
  • First, your code is no for equations. Second, you can get the same result with verbatim environment
    – juanuni
    May 19 '15 at 4:21
  • @juanuni Verbatim doesnt give a good result. I get a lot of unneccessary quotes . May 19 '15 at 4:26
  • I am going to suggest that you look at this posting tex.stackexchange.com/questions/127618/… for formating BNF and EBNF syntax specifications. Before you use the package (or any package) read the documentation, best found at 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. May 19 '15 at 4:58
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

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.