1
votes

I'm writing a document with a lot of equations and I would like to create new environments to write my equations in. Only for convenience, it works without, but it is fastidious to type. For single equations, I want to number the lines with lineo. With align environment, only use 1 equation number with the split environment, and number the lines. So I can do this in my document:

    \usepackage[displaymath, mathlines]{lineno}
    \linenumbers
...
    \begin{linenomath}
     \begin{equation}
     \end{equation}
    \end{linenomath}

and

\begin{linenomath}
 \begin{align
  \begin{split}
  \end{split}
 \end{align}
\end{linenomath}

This works, however, I'm trying to create new environments for it like this:

\newenvironment{my_equation}
    {\begin{linenomath}
      \begin{equation}
    }
    {
     \end{equation}
    \end{linenomath}
    }

\newenvironment{my_align}
    {\begin{linenomath}
      \begin{align
       \begin{split}
    }
    {
      \end{split}
     \end{align}
    \end{linenomath}
    }

These do not work. I got an error and the file won't compile. Am I doing things correctly? Which obvious solution did I miss? Thanks for your help!

1

1 Answers

1
votes

You can use the environ package:

\documentclass{article}

\usepackage{mathtools}
\usepackage[mathlines]{lineno}
\usepackage{environ}


\NewEnviron{my_equation}
    {\begin{linenomath}
      \begin{equation}
      \BODY
     \end{equation}
    \end{linenomath}
    }

\NewEnviron{my_align}
    {\begin{linenomath}
      \begin{align}
       \begin{split}
        \BODY
      \end{split}
     \end{align}
    \end{linenomath}
    }

\begin{document}


\begin{my_equation}
test
\end{my_equation}

\begin{my_align}
test
\end{my_align}

    
\end{document}