LaTeX is amazing for writing math, but when it comes to equations, beginners often get confused. Many people mix $$...$$, \[...\], equation, and align all together, which creates errors and formatting problems.
In this guide, we will explain everything step by step, with examples and best practices.
$$ … $$ vs \[ … \]
Using $$ . . . $$ for display math. This is old TeX syntax and not recommended with amsmath. It can cause spacing and numbering problems.
\[ a^2 + b^2 = c^2 \]
Always use \[ . . . \] for display math.
The equation Environment
If you want LaTeX to automatically number your equation, use the equation environment.
\begin{equation}
E = mc^2
\end{equation}
Writing \[ . . . \] or $$ . . . $$ inside equation. This creates double display mode errors.
Just use equation by itself.
For Multiple Equations (align Environment)
When you need to show multiple equations or align them by =, use align.
\begin{align}
a^2 + b^2 &= c^2 \\
x + y &= z
\end{align}
Here & marks the alignment point.
Mistake
- Putting equation inside align
- Using $$ … $$ inside align
- Forgetting to control numbering
Numbering Control (\nonumber and \tag)
Sometimes you don’t want every equation to have a number. Then use \nonumber or \notag.
\begin{align}
a^2 + b^2 &= c^2 \nonumber \\
x + y &= z
\end{align}
Or you may want a custom tag.
\begin{equation}
E = mc^2 \tag{Einstein}
\end{equation}
Problems When Mixing Everything
If you mix $$, equation, and align randomly in the same document, problems appear.
- Extra spacing issues
- Wrong numbering
- Conflicts with
amsmathpackage - Compilation errors
Best Practices (Golden Rules)
Here are the golden rules for equations:
1. Inline math → $ ... $
2. Display math (unnumbered) → \[ ... \]
3. Single equation (numbered) → equation environment
4. Multiple equations / alignment → align or align*
5. Never use $$ ... $$ if you load amsmath
6. Use \tag{} for custom numbers
7. Always load amsmath for better equation handling.
Conclusion
Friend, if you follow these simple rules, your LaTeX document will be clean and error-free.
Beginners often mix everything together and get errors, but with these best practices, your equations will look professional.