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.
-
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]
-
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:
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.
HINT: Use the "v" symbol for the arrow pointing down.