As mentioned in the post below,
$$...$$ should not be used in LaTeX:
$$...$$ is not to be used and
\[...\] has to be used, why is
$$...$$ still made available? Why cannot
$$...$$ be mapped to
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It only takes a minute to sign up.Sign up to join this community
$ has no predefined meaning. One of the first lines in
that assigns the character its commonly used function of “math shift”. Any character could be assigned this meaning, but Knuth started with it and LaTeX followed suit.
In the considerations below,
$ will mean “a character with category code 3”.
$ work? There are several cases to consider.
If TeX is in vertical mode, it starts horizontal mode and rereads the
If TeX is in restricted horizontal mode, it discards the
$ and enters inline math mode.
If TeX is in (unrestricted) horizontal mode, it looks at the next token without expanding it; call it t. If t is
$ then TeX enters display math mode and discards both found
$ tokens. If t is not
$, then TeX enters inline math mode, discards the
$ token and rereads t.
If TeX is in display math mode, it looks for the next token without expanding it; call it t. If t is
$, TeX ends display math mode (and does a whole lot of things). If t is not
$, then TeX issues an error message and inserts
$, which causes ending display math mode (assuming the user hits return or
\errorstopmode is not in effect). Token t is reread. In both cases, horizontal mode is resumed without inserting
If TeX is in inline math mode, it ends it (doing a whole lot of things) and resumes horizontal mode (restricted or unrestricted).
Note: there are some subtleties regarding
\leqno but are not relevant for the big picture.
You can see that
$$ is somewhat hardwired in the language: it is not a primitive such as
\par that we can give new meanings to at will (knowing what we're doing, of course).
When LaTeX was born, the macros
\] were provided for starting/closing inline math mode and display math mode. However, since the format was based on Plain TeX and many people were already accustomed to using
$ for entering in and exiting from math mode, Leslie Lamport decided not to disable it, which would be possible by the simple instruction
after having defined all the macros that use math mode. Why not disabling it? Because porting code from Plain TeX would have been easier. However, there's no mention of
$$...$$ in the manual and for good reasons: this construction doesn't behave correctly when the
fleqn option is used; math displays built with
$$...$$ will be centered anyway. Not so for those built with
\[...\] or the equivalent
$$...$$ illegal would mean making illegal also
$...$ for inline math mode. Not an option now, it might have been possible when LaTeX was created. Doing it now would break thousands of older documents.
$$...$$ be mapped to
\[...\]? Because of the reasons above. It could be done by making
$ into an active character as my answer to Defining `$$$ $$$` to align shows. However, this breaks several other legal constructs, so it's not an option either.
There is no fanatism in advising users not to employ
$$...$$; if people wants to, they're given free will and they can refrain from listening to experts. They'll probably shoot on their own foot, but it's their problem.
I'll continue to advise users not to use
$$...$$. Do you want to listen to this advice? Fine. Don't you? Fine again, but if your document breaks, you're on your own.
The correct answer to why is
$$...$$ still made available is: Because LaTeX is old. This is actually not the only thing that is deprecated; you have
\it and friends,
eqnarray*, a bunch of packages,
Why is LaTeX not "cleaned up"? Well, first, you want at least some extent of backward compatibility. Second, you get people using the bad code; what should happen then?
Should LaTeX crash with an error: "Hey dude, you better use 2014 syntax than a 1992 one, I'm not going to support this old crap"? (Not a good idea indeed, given the amount of people who use LaTeX and are not quite good at any programming, happy that it does something which looks reasonable to them.)
Should a warning appear? (Notice that many warnings appear, and if people read them, we would have so much less work answering questions here. And especially for
$$, since it's a TeX primitive and LaTeX layer has only a little control over it, it can't even issue a warning.)
So the only option left is: You keep the deprecated syntax.