Replace the `$$ ... $$` macro with the `\[ ... \]` macros? - Prefer the way LaTeX lays it out, but `$` are faster to write

This is not a direct answer to your question but maybe a better solution: use snippet management to ease writing \[ ... \] constructions. This of course requires an editor with support for snippets management.

You could create a snippet that activates when writing $Tab (or some key command) and when it's activates it inputs

\[

\]

and places the cursor between them.

In many snippets managers this snippet is simply:

\[
$1
\]

For an explanation of how YASnippet, a snippet manager for Emacs, works, see Working with templates.


Personally, I think that you should just get into the habit of typing \[ and \] as quickly as possible and I think that you'll find that you soon develop the right "muscle memory" that it becomes as fast as typing $$.

But if you want to do a one shot conversion, then I have a script that might help you. I wrote it a while ago, probably when I was in a similar circumstance (the details are hazy in my memory) and wanted to convert my old files. I still use it when I get sent something by a collaborator or student that uses $$.

You can find it from my website, at https://github.com/loopspace/debuck

(The name is from the American word "buck" for "dollar".)


No it is not possible to redefine them the way you want. However, if you write your maths correctly you can use either of them without any problem. Consider this code:

\documentclass{article}
\begin{document}
\fbox{
\begin{minipage}{5cm}
This is a test
$$ \sum_{i=1}^{10} t_i $$
and
$$ \sum_{i=1}^{10} t_i $$
and another
\end{minipage}}
\fbox{
\begin{minipage}{5cm}
This is a test
\[ \sum_{i=1}^{10} t_i \]
and
\[ \sum_{i=1}^{10} t_i \]
and another
\end{minipage}}

%% This will make a slightly different layout
\fbox{
\begin{minipage}[t]{5cm}
This is a test
$$ \sum_{i=1}^{10} t_i $$

and

$$ \sum_{i=1}^{10} t_i $$
and another
\end{minipage}}
\fbox{
\begin{minipage}[t]{5cm}
This is a test
\[ \sum_{i=1}^{10} t_i \]

and

\[ \sum_{i=1}^{10} t_i \]
and another
\end{minipage}}

\fbox{
\begin{minipage}{5cm}
This is a test \math x=y+5 \endmath\  and \ldots

This is a test $ x=y+5$ and \ldots

This is a test \( x=y+5 \) and \ldots
\end{minipage}}
\end{document}

The first two boxes are identical, as they have been written correctly as a single paragraph. The second one the LaTeX way, as you observed in your question is a bit "loose". If you are aware of these differences you can use $$ without any issues. For inline math I always use $ and so far it hasn't caused the universe to collapse into a black hole!

Caveat: If you use any maths packages or amsmath you will be well advised to rather stay with \[..\], although for the example above just using usepackage{amsmath} will provide consistent results for both cases, but will fail if you use the option fleqn. See also Is $ ... $ okay to use, while $$ ... $$ is not recommended? and Why is \[ ... \] preferable to $$ ... $$?.