tags:

views:

434

answers:

5

Is there any reason to prefer the syntax \(myformula\) to the usual $myformula$ in LaTeX?

+1  A: 

Only that some editors can't balance $ signs, where they can balance the brackets in the \(\) form. If you have a good editor (and with emacs and auctex mode out there, who doesn't?), then it's not an issue.

Andrew McGregor
My editor handles $ signs perfectly. I'm just wondering whether there is a difference, since it is often advised to use `\[\]` instead of `$$`.
Olivier
+2  A: 

I use $formula$ and $$formula$$. But sometimes you need to catch the end of the math mode. The thing is that you can catch the begin of the math mode using \everymath or \everydisplay:

\everymath{\color{red}}

Unfortunately you can not catch end of the math mode. But if you use \( and \) you can redefine \):

\let\endmath\)% Save \)
\def\){\preendmath \endmath \postendmath}% Override
\def\preendmath{\,(*)}% For example
\def\postendmath{}% Any stuff
Alexey Malistov
I wasn't aware of `\everymath` and `\everydisplay`, this might come in handy! But `\everymath` works for me although I use `$formula$`. So the only advantage of `\(\)` is if I ever wanted to do something fancy only at the end of formulas? Why does that syntax exist at all?
Olivier
Perhaps another reason is that second `$` in `$formula$` is similar to the first one. To avoid any error with opening or closing `$` you should use `\(\)`. I use $$$s.
Alexey Malistov
See the answer below about not using `$$`...`$$`; you'll run into problems eventually.
Will Robertson
+3  A: 

I read in [1] (German text), that the use of $$ ... $$ leads to inconsistencies in vertical spaces before and after the formula, which shouldn't happen with [ ... ].

[1] ftp://ftp.dante.de/tex-archive/info/l2tabu/german/l2tabu.pdf (Section 1.6)

Rupert Jones
Yes, I consistently use `\[\]` for *display* equations. But here I am concerned with the similar issue for *inline* equations.
Olivier
That same document is available in English too: http://mirror.ctan.org/info/l2tabu/english/l2tabuen.pdf (section 1.6 and 3.3).
ShreevatsaR
+4  A: 

LaTeX can catch nesting errors with \(...\) but in practise there's no real advantage to using them over $...$. If you do use \(...\), then make sure to load the fixltx2e package to make them robust (i.e., e.g., usable in captions and section headings).

As others have said, on the other hand, \[...\] should be used instead of $$...$$.

Will Robertson
A: 

I believe that $...$ is not technically standard LaTeX, but that \( is. Since all latex compilers make use of the underlying TeX engine, this is never an issue, but from a pendant's perspective, there is that difference.

pavpanchekha