Difference Between Inline and Display Math in LaTeX

In LaTeX, mathematical expressions can be presented in two primary formats: inline math and display math. Each format serves a different purpose and is used in different contexts. Below, we will explore the differences between inline and display math in detail, along with sample code.

1. Inline Math

Inline math is used for short mathematical expressions that are part of a paragraph. It allows the math to flow with the text, making it suitable for simple equations or symbols that do not require emphasis or separation from the surrounding text.

To create inline math, you enclose the mathematical expression with single dollar signs ($...$) or use the \(...\) syntax. Here’s an example:

        
The area of a circle is given by the formula $A = \pi r^2$.

In this example, the expression A = \pi r^2 will appear inline with the text, seamlessly integrated into the sentence.

2. Display Math

Display math is used for larger equations or expressions that you want to stand out on their own. This format centers the equation on a new line, making it more prominent and easier to read. Display math is ideal for complex equations, formulas, or when you want to emphasize the mathematical content.

To create display math, you can use double dollar signs ($$...$$), the equation environment, or the align environment for multiple equations. Here’s an example using double dollar signs:

        
$$ E = mc^2 $$

Alternatively, using the equation environment:

        
\begin{equation}
E = mc^2
\end{equation}

In both cases, the equation E = mc^2 will be centered on its own line, making it more visually distinct from the surrounding text.

3. Key Differences

  • Placement: Inline math is placed within a paragraph, while display math is centered on a new line.
  • Formatting: Inline math maintains the text flow, whereas display math is visually separated and often larger.
  • Use Cases: Use inline math for simple expressions and display math for complex equations or when emphasis is needed.

4. Example of Both Formats in a Complete Document

Here is a complete example of a LaTeX document that demonstrates both inline and display math:

        
\documentclass{article} % Specifies the document class
\begin{document} % Start of the document

The area of a circle is given by the formula $A = \pi r^2$.

Here is a famous equation in display mode:
$$ E = mc^2 $$

And here is an equation in the equation environment:
\begin{equation}
a^2 + b^2 = c^2
\end{equation}

\end{document} % End of the document

5. Conclusion

Understanding the difference between inline and display math in LaTeX is essential for effectively presenting mathematical content. Inline math is suitable for simple expressions within text, while display math is ideal for larger, more complex equations that require emphasis. By using these formats appropriately, you can enhance the clarity and readability of your LaTeX documents.