1

I'd like to use Syntax and lhs2TeX together, but Syntax's usage of <> in production rule names seems to conflict with lhs2TeX:

\documentclass{article}
\usepackage[nounderscore]{syntax}

%include lhs2TeX.fmt

\begin{document}
\begin{grammar}
<foo> ::= <bar>
\end{grammar}
\end{document}

if I try to typeset this:

$ lhs2TeX a.lhs -o a.tex
$ pdflatex a.tex

I get

! Use of \gr@implitem doesn't match its definition.
l.97 ...n{grammar}\begingroup\par\noindent\advance
                                                  \leftskip\mathindent\(

Is there a way to use these two packages together?

2

Leading < characters are interpreted by lhs2TeX as shorthand for the spec environment (i.e. literate Haskell that should not be picked up by the compiler), as explained in chapter 3 of its usage guide. I was able to work around this by simply adding a leading space before the < on the production rule's left-hand side:

\documentclass{article}
\usepackage[nounderscore]{syntax}

%include lhs2TeX.fmt

\begin{document}
\begin{grammar}
 <foo> ::= <bar>
\end{grammar}
\end{document}

This version is processed by lhs2TeX and pdflatex as expected.

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.