Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to type Backus-Naur form in LaTeX document. I found several packages on CTAN:

  • ebnf seems to not work with TeXLive 2009
  • latex-bnf does not align the declaration, etc.
  • There is a module for ConTeXt, context-bnf

Is there a package for modern LaTeX, or should I just use hand-formatting via verbatim?

share|improve this question
1  
Not verbatim, for goodness sake. If everything else fails, use an itemize or something like that. I hope someone comes up with a better solution. –  Konrad Rudolph Oct 23 '10 at 14:27
1  
Please note that I mentioned verbatim as last resort. Probably tabular would be closer to what I have in mind but neither of those solution is IMHO LaTeX-like (i.e. type the document and let computer to figure out how to format it). –  Maciej Piechotka Oct 23 '10 at 14:35
    
See also tex.stackexchange.com/questions/24886/… –  knut Aug 30 '12 at 20:19
add comment

2 Answers

up vote 9 down vote accepted

I stumbled across the syntax-mdw package the other day. It looks like it might typeset BNFs and syntax diagrams nicely. See the documentation (PDF) to get an idea of its capabilities.

share|improve this answer
2  
If the package's underscore hack causes problems then try \usepackage[nounderscore]{syntax}. –  mpartel May 28 '12 at 14:39
    
I needed to use [nounderscore] otherwise I got the error ! Missing \endcsname inserted. –  Flow Aug 30 '12 at 20:10
add comment

Try the bnf.tex at http://dante.ctan.org/tex-archive/macros/plain/contrib/bnf/ . It is simple enough that can form the basis of what you are looking and expand as you wish.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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