2

I defined a new environment called boxew. When I use the code

\begin{empheq}[box=\fbox]{align}
  \bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0 \\
  \bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0
\end{empheq}

I get boxed equations as I want. When I use the environment boxeq which I predefined:

 \newenvironment{boxeq}
    {\begin{empheq}[box=\fbox]{align} }
    {\end{empheq}}

it won't compile. See example below:

\documentclass{article}
\usepackage{amsmath,amssymb}
\usepackage{mathtools}
\usepackage{empheq}

\newenvironment{boxeq}
{\begin{empheq}[box=\fbox]{align} }
{\end{empheq}}

\begin{document}

Multiline:

\begin{empheq}[box=\fbox]{align}
  \bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0 \\
  \bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0
\end{empheq}

Multiline \texttt{boxeq}:
\begin{boxeq}
\bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0 \\
\bar{\nabla}^{\mu} \bar{h}_{\mu\nu} & = 0
\end{boxeq}

\end{document}

There is probably a small syntax error but I can't find it. Can you please help?

1 Answer 1

5

Here empheq relies on being able to explicitly see \end{empheq}. It is much easier to use modern tools to define boxeq. If your LaTeX format isn't after October 2020, remember to load xparse:

\NewDocumentEnvironment{boxeq}{b}{}{
  \begin{empheq}[box=\fbox]{align}
    #1
  \end{empheq}
}

this special env will grab the contents of the env (the b specifier) and then we can pass it on to empheq via #1.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .