DEV Community

Cover image for Latex For Beginners Part 3
Mustafif
Mustafif

Posted on

Latex For Beginners Part 3

In this part we will be discussing about Equations & Listings, the ugly and the beauty in it.

Equations

If you have used Microsoft Word's equation, it's a pain to use, and will grow more grey hairs than needed. In terms of writing documents in the sciences, Latex is always the #1 choice, so how exactly do we do equations?

Well there's three or 2.5 ways of doing them...

In-Text Equations

In Text equations are done using $...$, these are used to add equations inside the texts hence the name, and are generally the most used.

Let's look at a silly example:

\section{Some math}

\par To find the integral of $\sqrt{4+x^2}$ we must use trigonometric substitution where $x=2tan\theta$
Enter fullscreen mode Exit fullscreen mode

Try compiling this example and see what is produced

Equations Environment & Split

To do a single line equation use the equation environment, and put the equation inside, but if you need to do multi-line, then you need to also put in the split environment.

% single-line equation
\begin{equation}
% if you don't want the numbers 
% put equation* instead 
x^2 = 98
\end{equation}

% multi-line equation
\begin{equation}
   \begin{split}
       x^2 &= 98\\
       % & is used to align the equations 
       % \\ is used to put new lines 
       x &= \pm \sqrt{98}
   \end{split}
\end{equation}
Enter fullscreen mode Exit fullscreen mode

It's hard to put a bunch of the symbols and such in a single post, so instead I'll refer you to the Overleaf tutorial that shows all of the different math symbols.

The next post will show how to nicely use projects like TexCreate to help you with your projects.

Top comments (0)