4

This question already has an answer here:

Since I want to add line number in my manuscript, I have to wrap align environment into linenomath environment to have right numbering. I wanted to define new environment in preamble in which I want Latex to put the math inputting into these environments, but It didn't work. Can you help me please? Here is my codes.

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[switch*, displaymath,pagewise, mathlines]{lineno}
\leftlinenumbers
\linenumbers

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

\begin{document}
\begin{Align}
x+y=10
\end{Align}
\end{document}

marked as duplicate by clemens, user13907, JPi, Jesse, egreg align Sep 25 '16 at 15:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Not clear what you want. Should lines of display maths be numbered or not? – Bernard Sep 25 '16 at 12:28
  • 2
    ... "but it didn't work". Please be more specific. E.g., do tell us if you get an error and/or warning messages. – Mico Sep 25 '16 at 12:38
  • @Bernard I guess line numbers should be omitted for aligned math. – gernot Sep 25 '16 at 13:31
  • @gernot: But that is the default! B.t.w., the displaymath is obsolete: it's the default now. – Bernard Sep 25 '16 at 13:33
  • @Bernard True. Strange. So the purpose remains a mystery, but the problem is solved ;-) – gernot Sep 25 '16 at 13:37
2

This is a particular problem of the align environment, see also newenvironment: error with \begin{align} and \end{align}. In your case, you have to define your environment as

\newenvironment{Align}%
  {\linenomathNonumbers\align}%
  {\endalign\endlinenomath}
  • Yes, but lineno doesn't seem to work correctly with align: it displays two consecutive numbers (one above the other) for the last line, even if there's only one line. – Bernard Sep 25 '16 at 13:32
  • @Bernard Well, no harm is done: \linenomathNonumbers suppresses line numbers. – gernot Sep 25 '16 at 13:42

Not the answer you're looking for? Browse other questions tagged or ask your own question.