# Why put the dollar sign before and after the array environment

So I am trying to type in a table ducumenting different mathematical equations under different heading, something like this: and it is suggested to me that array environment is better than table since the majority of data entry is in math mode, not text mode.

But in the answer to this question@mico wrap the array environment with single $sign, even though that in this (website)[https://latex.wikia.org/wiki/Array_(LaTeX_environment)], the example code is not wrapped in dollar sign. I tried to compile @mico's code without the dollar sign and it doesn't work. I wonder what is the role of this single dollar sign. Surely it is not meant to signal in line math mode? isn't the whole point of array environment meant to signify that? ## 1 Answer As you've discovered, LaTeX must be in math mode -- either inline math mode or display math mode -- when it encounters an array environment. In the posting which you reference in your query, the $ symbols serve to initiate and terminate inline math mode. I could have also used $$ and $$, or \begin{math} and \end{math}, to switch in and out of inline math mode.

You wrote, "I wonder what is the role of this single dollar sign." As stated in the preceding paragraph, single \$ symbols may indeed be used to initiate and terminate inline math mode.

In contrast, in the wiki example which you reference, the array environment code occurs inside an array (or similar) environment. Therefore, (La)TeX is already in math mode, and there's thus no need to switch into math mode in order to process \begin{array} ... \end{array}. (Aside: I wrote "or similar" because the wiki code isn't actually processed by LaTeX. Instead, it is rendered by an entirely different underlying engine. )