I'm currently trying to create a custom environment with its own counter.
\documentclass[a4paper,11pt]{report}
\usepackage[fleqn]{amsmath}
\newcounter{grammarcounter}
\newenvironment{grammar}{
\refstepcounter{grammarcounter}
\begin{equation*}
\tag{$\Gamma_{\thegrammarcounter}$}
}{\end{equation*}}
\numberwithin{grammarcounter}{chapter}
\begin{document}
\begin{grammar}
\label{gr:label}
E ::= E + E \\
E ::= a
\end{grammar}
\end{document}
This works nicely for simple equations, but the line split \\ does not work inside the equation* environment. Ideally I would like to replace the equation* environment with the align* environment. However, when simply replacing equation* in the example with align*, I get LaTeX errors indicating \begin{align} on input line .. ended by \end{grammar}.
How can I create a custom equation environment with its own counter that respects line breaks?
\documentclass{...}
, the required\usepackage
's,\begin{document}
, and\end{document}
. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem.aligned
(orgathered
) environment nested ingrammar
.