# Why is $…$ preferable to $$…$$?

I've heard that you should use $...$ for displayed equations instead of $$...$$, but why is that?

I'd assumed that it's so that you can more easily tell which are starting and which are ending delimiters, but if I always use a syntax-highlighting text editor, I can see that easily based on the color of the symbols.

Is there any reason for this suggestion?

-
I tend to prefer amsmath \begin{equation*} over $, because it feels more semantic and makes the source more human-readable. But I really don't know, is there any difference between these two? – Juan A. Navarro Jul 28 '10 at 20:48 @Juan: If you use amsmath, there is no difference. See the end of amsmath.sty. – Harald Hanche-Olsen Nov 8 '10 at 17:31 @Harald At least when using lineno, there is a difference... why doesnt lineno number a paragraph when it is followed by an indented equation – David Aug 15 '11 at 21:07 @David: I see – so the lineno package redefines \[…$? Well, seeing as this is peculiar to that package, if you really want an answer you should probably post a separate question. (I can't help you with it, sorry.) –  Harald Hanche-Olsen Aug 17 '11 at 11:57
Is /begin{displaymath} wrong as well, or can I use that? –  Canageek Oct 6 '11 at 21:46
show 1 more comment

Spacing is wrong.

It is a "deadly sin" according to l2tabu: http://www.ctan.org/tex-archive/info/l2tabu/english/

-
should be "required reading" –  Yossi Farjoun Jul 29 '10 at 0:24
Maybe worth noting that the difference between [ .. ] and $$..$$ is larger than that between ( .. ) and $..$. If your document is completely correct, you will not (I think) notice the difference between the latter in the final document but you will with the former. –  Andrew Stacey Jul 29 '10 at 9:37
Although the link is good, I find the answer a bit disappointing: What is wrong with the spacing? This explanation is also missing in l2tabu. –  Hendrik Vogt Nov 2 '10 at 15:24
@Jasper: Well, you quoted everything l2tabu has to offer on the subject. And yes, it does say that something is wrong with the spacing of $$, but it doesn't say what is wrong. That's what I actually meant in my comment above. Anyway, thanks for clarifying this! – Hendrik Vogt Apr 24 '11 at 12:32 Amusingly, l2tabuen.pdf suggests to use \uppi rather than $$\uppi$$ on page 14. So $$...$$ is “please don't do this” and a “deadly sin”, because of spacing in some cases (I have not seen a single one to date) and its TeX nature, while ... is perfectly correct? Oh, please. Yes, the use of fleqn and some other arguments are understandable and I do use LaTeX commands, but the issue has gone too far without a good argumentation which the one in l2tabuen.pdf is certainly not. – Harold Cavendish Aug 11 '11 at 18:35 show 5 more comments I suppose it could be useful if you share your files with someone else who doesn't have a syntax-highlighting text editor. Other than that, it probably doesn't matter much. Certainly if nobody else ever sees your LaTeX source files, I'd say write them however you want. This is neither here nor there, but personally I find neither of those as clear as $$...$$. - You meant equation*, didn't you? =p – Willie Wong Jul 28 '10 at 18:36 Sure, whatever variant it takes to get the effect I want. – David Z Jul 28 '10 at 18:37 add comment [Edit: I should add the disclaimer that the following is based on just "I read it somewhere sometime ago", so I have no references to backup my claims.] As far as I know $$ ... $$ is a TeX, amsTeX thing. LaTeX still supports it for one reason or another, but the "proper" one to use, as defined in the specifications, is $...$. All this just means that they are not promising that $$ will always work. So it is technically possible (though unlikely in the near future), that compatibility with $$ is removed from LaTeX and lots of your documents break. As to why one is in the specifications and not the other? I have no idea. - Given that TeX goes into display math mode by the occurrence of two identical characters with catcode 3, LaTeX would have to go through some contortions to prevent $$ ... $$ from working, especially if  ...  was still to work. I guess you could give some other character catcode 3, make  active, define it using \@ifnextchar to look for another  and give an error message, otherwise use the new math shift character to go into or out of math mode and of course after the definition of , make the other character have its original catcode...but that doesn't seem worth it. – TH. Aug 28 '10 at 12:21 LuaTeX have primitives for entering/exiting inline and display math modes (as well as sub/superscript), so making it possible to assign  a normal catcode. – Khaled Hosny Aug 28 '10 at 23:24 @TH: So that's why $$ still sorta works in LaTeX. I've been wondering why they couldn't disable it, and I seem to have misplaced my TeXbook. –  SamB Oct 4 '10 at 18:40
A workaround could be setting the default math typeface (appearing with $$) to a big red blinking all-caps font saying "you shouldn't use this", and then setting $...$ to change this mess back to something normal. Would this work? I am no TeX guru, so I do not know for sure. – Federico Poloni Sep 2 '12 at 21:12 add comment $$ is plain TeX and could have some side effects, also fleqn will not work anymore. Please have a look at l2tabu. In my opinion the best environment for equations is gather or align. If you use equation you sometimes get some strange spacings.

-
eqnarray gives strange spacing and is deprecated in favour of alignequation, on the other hand, should be fine … –  Konrad Rudolph Jul 28 '10 at 19:08
The reason fleqn doesn't work with $$...$$ is because it redefines \] to run some code at the end. –  Charles Stewart Jul 28 '10 at 21:37
1. While my memory prevents me from naming the guilty software, I have seen LaTeX syntax highlighting become confused by the $$...$$ construct when it parsed the $...$ construct correctly.

2. Agreed, worry about some partially broken editor isn't a high priority. But, I have found that I am more than partially broken. If I've made a mess of a file, the left-hand and right-hand information in the $ way has, on occasion, helped me figure out just what I was on about more easily than the symmetric  would have. - While this is certainly true enough, it's not the real reason. The real reason is that \[ ...$, which are macros, do some extra things (sometimes) that $$...$$, which are baked in to TeX, cannot be made to do. –  SamB Oct 4 '10 at 18:50

Here is one more reason (this is what converted me). If you use the \begin{proof}...\end{proof} environment, you occasionally end a proof with an equation. The automatic QED box then ends up on a line by itself, which is ugly. You can fix this by writing \qedhere at the end of the equation, but this doesn't work properly with $$...$$ – you have to use $...$ (or an environment, like equation/gather/align). To exemplify:

Don't:

\begin{proof}
This follows from
$$e^{x+y}=e^xe^y. \qedhere$$
\end{proof}


Do:

\begin{proof}
This follows from
$e^{x+y}=e^xe^y. \qedhere$
\end{proof}

-

$$ is TeX primitive syntax, which, as others have commented is hard to redefine (in classic TeX there is no command name which triggers entering or leaving display math). LaTeX doesn't officially support $$. The most noticeable failure if you use the syntax is that the fleqn option will no longer affect the display of the mathematics, it will remain centered rather than being set flush left.

However if you are using \[ it is best to use the amsmath package (it is best to load this package if doing any serious mathematical layout with LaTeX).

\[ is a short form of \begin{displaymath} which one might expect to act like an un-numbered form of . The amsmath package redefines \[ to be \begin{equation*} which is exactly an un-numbered form of the equation environment as defined by that package. In the core LaTeX definition \[ has the definition

  \ifvmode
\nointerlineskip
\makebox[.6\linewidth]{}%
\fi
$$ which means that the spacing if used between paragraphs is better that a primitive $$ (which causes a blank paragraph just consisting of the indentation and parfillskip glue to be inserted before the display) but it is inconsistent with equation and always uses \abovedisplayskip rather than \abovedisplayshortskip. In the AMS versions the spacing is more consistent,

-
Out of curiosity, what is the effect of the \makebox? –  Zack Feb 12 at 23:46
well as indicated it's an attempt to improve the behaviour if the equation starts a paragraph,  would force a blank line aligned on baselineskip but with just with just an indentation box and parfillskip glue then have the display skip, that forces the paragraph tp start with a zero height line which reduces the vertical space. –  David Carlisle Feb 13 at 9:06