3

An example:

If I don't want to number an equation within the equation environment, I need to do two things:

  1. Load the amsmath package at the preamble.

  2. Use the command \nonumber at the end of the equation.

Without the amsmath package, the compiler would not recognize the \nonumber command. As far as my understanding goes:

  1. The equation environment is part of Latex's core functions, and there is no package needed to call the environment. Its code specifies that it will always number the equation within.

  2. The amsmath package allows the use of the command '\nonumber'.

My confusion is that it seems like the \nonumber command has interfered with the equation environment.

More specifically, the \nonumber command must somehow have communicated with the equation environment because once a \nonumber command is executed, the next equation environment automatically adjusts the numbering.

I find this hard to understand because loading a package doesn't mean erasing the existing commands. Moreover, it doesn't seem to me that the \nonumber command could have modified the code of the equation environment.

My question is: How could the equation environment recognize an unnumbered equation, which was done by a separate package, and adjust its numbering accordingly? More generally, how are packages integrated into existing LaTeX core functionalities?

My question might not have expresses fully my confusion so any additional information would be appreciated.

Torbjørn T.
  • 206,688
A Slow Learner
  • 377
  • 1
  • 3
  • 9
  • 5
    I find this hard to understand because loading a package doesn't mean erasing the existing commands. Moreover, it doesn't seem to me that the '\nonumber' command could have modified the code of the 'equation' environment. — Neither of these statements is true. To include a package means to run arbitrary code (whatever exists in that page), and it most certainly can erase or modify existing commands and environments. – ShreevatsaR Feb 16 '18 at 07:42
  • 5
    (Meant “package”, not “page”, in previous comment.) Also, unfortunately for your example, \nonumber is defined in LaTeX itself (in around the place where the equation example is defined), not in the amsmath package. (But in general the kind of thing you describe is quite possible; a package can simply redefine things that were defined by LaTeX or other packages.) – ShreevatsaR Feb 16 '18 at 07:54
  • How about when loading a package having a command that was already defined in a different package and Latex notifies the error? – A Slow Learner Feb 16 '18 at 08:09
  • @ShreevatsaR Btw, my compiler somehow would not recognize the \nonumber command without the {amsmath} package... Anyway, supposing my example is correct, then did you mean that the {amsmath} package might have erased the original ‘equation’ environment and rewritten a new environment with the same name that allows the use of the /nonumber command? Thank you for your answer. – A Slow Learner Feb 16 '18 at 08:23
  • 2
    @TheOblivious - Please see this answer for a discussion of the properties of various displayed-math environments. The discussion also touches how loading the amsmath package modifies the properties of the equation environment. – Mico Feb 16 '18 at 08:27
  • 2
    The premise of your question is untenable: There are no LaTeX "compilers". TeX is, at its heart, a macro expansion language. It provides various (generally very low-level) "primitive" instructions, and it provides methods for extending the program's capabilities by defining new macros. LaTeX is, basically, a very extensive collection of macros (and their close relative, environments), which build on and augment the primitive instructions. LaTeX packages, in turn, provide further macros, which can provide either new capabilities or modify existing macros. – Mico Feb 16 '18 at 08:36
  • 2
    Please also read the posting What is the difference between TeX and LaTeX? and especially this answer, which discusses some aspects of the division of labor between (La)TeX engines, formats, and packages. – Mico Feb 16 '18 at 08:41

0 Answers0