4 Mathematical Equations in Latex (Inline vs Display Style)

How to Write Mathematical Equations in Latex?

There are two ways to write a math equation in LaTeX.

  1. Inline: An inline expression occurs in the middle of the 
    text. For producing an inline expression, the math 
    expression should be written between the [latex]and[/latex]
  2. Display style: If you want your equation to be placed on the 
    centre of the page your equation should be written between 
    \[ and \]

Example:

Inline looks like [latex]x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}[/latex], while display looks like \[x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}\]

 

Inline: [latex]x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}[/latex], 
Display: \[x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}\]

 

NOTE: If you need inline math to appear as it does in display mode, you can use the \displaystyle command to do so. For example,

Inline with \displaystyle looks like [latex]\displaystyle \frac{1}{2}[/latex]

Chemical Equations

Example: 

a) Inline looks like [latex]\ce{Na2SO4 ->[H2O] Na+ + SO4^2-}[/latex], while display looks like \[\ce{Na2SO4 ->[H2O] Na+ + SO4^2-}\]
Inline: [latex]\ce{Na2SO4 ->[H2O] Na+ + SO4^2-}[/latex]
Display:\[\ce{Na2SO4 ->[H2O] Na+ + SO4^2-}\]

Exercises

Typeset the following chemical equation in display mode.

\[\ce{SO4^2- + Ba^2+ -> BaSO4 v}\]
HINT: Use the "v" symbol for the arrow pointing down.

 

 

License

Icon for the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License

Using Latex in Pressbooks Copyright © 2021 by Sanja Krajisnik and Jelena Loncar is licensed under a Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License, except where otherwise noted.

Share This Book