1

In order to assign proper line number for displayed equation, I need to wrap each displayed equation around

\begin{linenomath*}
\end{linenomath*}

I would like to define a new environment that wrap these two lines around

\begin{align*}
\end{align*}

etc. Here is my unsuccessful attempt to implement this:

\documentclass[12pt,letterpaper]{amsart}

\usepackage{amssymb,lineno}
\linenumbers

\newenvironment{myeqn}
    {
      \begin{linenomath*}
        \begin{align}
        \end{align}
      \end{linenomath*}
    }

\begin{document}

What I want

\begin{linenomath*}
  \begin{align}
    x^n + y^n &= z^n
\label{one}
  \end{align}
\end{linenomath*}

What I got

\begin{myeqn}
  x^n + y^n &= z^n
\label{two}
\end{myeqn}

\end{document}

What's the right way to implement this? MANY THANKS!

1 Answer 1

2

This sort of works; at least, the output is the same (albeit disputable).

\documentclass[12pt,letterpaper]{amsart}

\usepackage{amssymb,lineno}
\linenumbers

\newenvironment{myeqn}
 {\csname linenomath*\endcsname\align}
 {\endalign\csname endlinenomath*\endcsname}

\begin{document}

What I want
\begin{linenomath*}
  \begin{align}
    x^n + y^n &= z^n
\label{one}
  \end{align}
\end{linenomath*}

What I got

\begin{myeqn}
  x^n + y^n &= z^n
\label{two}
\end{myeqn}

\end{document}

enter image description here

When you wrap align in some other environment, you need to use the “inner form”, not with \begin and \end.


A generic environment where the desired one is given as argument.

\documentclass[12pt,letterpaper]{amsart}

\usepackage{amssymb,lineno}
\linenumbers

\NewDocumentEnvironment{linenodisplay}{mb}
 {\begin{linenomath*}\begin{#1}#2\end{#1}\end{linenomath*}}
 {}

\begin{document}

Here is \texttt{align}
\begin{linenodisplay}{align}
  x^n + y^n &= z^n \\
  x^n + y^n &= z^n
\end{linenodisplay}
and here is \texttt{align*}
\begin{linenodisplay}{align*}
  x^n + y^n &= z^n \\
  x^n + y^n &= z^n
\end{linenodisplay}
Also \texttt{equation}
\begin{linenodisplay}{equation}
a=b
\end{linenodisplay}
and \texttt{equation*}
\begin{linenodisplay}{equation*}
a=b
\end{linenodisplay}

\end{document}

You might need to add \usepackage{xparse} if your LaTeX release is earlier than 2020-10-01.

enter image description here

4
  • This answers the question I posted (thanks!), but I realized belatedly that I also need a version for \begin{align*}\end{align*}. When I modify your sample code by replacing \align and \endalign by \align* and \endalign* I got gibbish results. Might should I handle this new case? Also, why did you say that "output is the same (albeit disputable)"?
    – underflow
    Aug 9, 2021 at 21:07
  • @underflow \csname align*\endcsname and \csname endalign*\endcsname. Disputable is the double numbering…
    – egreg
    Aug 9, 2021 at 21:19
  • @underflow I also added a generic form.
    – egreg
    Aug 9, 2021 at 21:26
  • The generic form is most helpful. The double number is a long-standing "feature" of lineno vs amslatex :-)
    – underflow
    Aug 10, 2021 at 2:24

You must log in to answer this question.

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