I'm not sure where this lies between a comment and an answer. The length pushed it towards the location of the latter.
Here is perhaps a promotion of LaTeX in lieu of your hate for its syntax that matches that of your example to a fair degree.
Whenever you define an environment in LaTeX, for example via
\newenvironment{myenv}
{<begin myenv>}% \begin{myenv}
{<end myenv>}% \end{myenv}
it (...LaTeX) defines two commands: \myenv
and \endmyenv
. To test this, you'll notice an error in your console when trying to compile the following minimal example:
\documentclass{article}
\newcommand{\mycmd}{test}% \mycmd
\newenvironment{mycmd}{hi}{there}% \begin{mycmd}...\end{mycmd}
\begin{document}
\mycmd
\end{document}
That error being
! LaTeX Error: Command \mycmd already defined.
Or name \end... illegal, see p.192 of the manual.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...
l.3 \newenvironment{mycmd}{hi}{there}
Even though you didn't define the an additional command by the name of \mycmd
. So, using your code snippet, is it very possible to have LaTeX understand exactly what you're after if you use
We have
\equation
A =
\bmatrix
a & b
c & d
\endbmatrix
\endequation
where ...
whatever your definition for equation
and bmatrix
may be (existing and redefined or not). In fact, the following minimal example compiles without problem:
\documentclass{article}
\usepackage{amsmath}%
\begin{document}
We have
\equation
A =
\bmatrix
a & b \\
c & d
\endbmatrix
\endequation
where ...
\end{document}
As commented by egreg, there are instances where this my be "surprising" and yield output contrary to one'e expectation. However, the extent of this may not influence you without more detail.
:-|