# How To Use LaTeX Typesetting

Learning LaTeX typesetting does not have to be hard. While it can be very involved, there are really just a few basics.Today I will strive to help you with the fundamentals. If you need additional options after that they are easy to find. LaTeX can be very useful so lets get started.

**Introduction**

You may wonder why I am using Latex over something like Microsoft Word. The problem with Word is that it hides what is really going on in the background and it has far less capability than Latex. I use it when I want to display math or caluclus and it also helps me learn those topics better. The reason why is that you have to completely understand how the math works before you can properly display it in a document or a web site. That is my logic and I hope it is obvious to others. Besides, if you are in a computer, math, or physics discipline then you will need to learn this anyway. So today I want to talk about how to use LaTeX typesetting in your documents.

**Defining LaTeX Typesetting**

LaTeX is a tool for creating very refined looking documents. It is quite different than Microsoft Word. Fundamentally, you have a page of source code that is compiled by an editor. That sounds all fancy and complicated but it is not. Editors and online tools make this quite easy.

**Reasons To Learn It**

LaTeX is used everywhere in the world. It is mostly used by scientists and engineers. This is because it is the easiest way to portray their math and diagrams into a document. You can also extend its usage quite a bit by the use of packages. There types of packages for anything conceivable to write about. Others use LaTeX typesetting for writing documents. It gives ultimate control over spacing, fonts, and organization. Making document templates is a very popular way to use this typesetting tool.

**Your First Document**

If you are creating a document from scratch you will need to give it a [.tex] file extension through whatever editor you are using. A pure LaTeX editor and online sites will do this in the background for you. Whichever you use the basics are the same. To start a document you do this:

\documentclass{article}

\begin{document}

Learning LaTeX typesetting does not have to be hard.

While it can be very involved, there are really just a few basics.

If you need additional options after that they are easy to find.

Today I want to talk about how to use LaTeX typesetting in your documents.

LaTeX can be very useful so lets get started.

\end{document}

That is how you start a document and write a little text. I will show you how to do more with this in later sections. First, make sure you save it with the [.tex] extension. Then use your editor to compile this source. There should be an obvious button that says compile or build.

The first line declares what kind of document you are using. An {article} is the most basic class. There are several other document classes as well. Everything else goes between the {document} tags.

**Modifying The Preamble In Latex Typesetting**

The preamble is the part of a document above the \begin{document} line. You can do a variety of things here. This is where you can specify font size and any special encoding.

It will look like this.

\documentclass[14pt, letterpaper]{article}

\usepackage[utf8]{inputenc}

The font size can be set to whatever you prefer. The [utf8] encoding is pretty universal as well. There are many other packages and options you can use here.

Adding A Title And Other Stuff

Titles, authors, and dates can easily be added to your document. This information goes in the preamble of your document. Use these commands in your preamble.

\title{How To Use Latex Typesetting}

\author{Jason Moore}

\date{April 2019}

Now you will also need to add another line in the body of your document. Add this right below \begin{document}.

\maketitle

This line will enable the information you just added to your preamble to show up. These are very popular options to add with LaTeX typesetting.

**Commenting Your Code**

This is quite easy to do when using LaTeX typesetting. Add a % to any line will tell the compiler to not do anything with it.

\documentclass[10pt, letterpaper]{article}

\usepackage[utf8]{inputenc}

\title{How To Use Latex Typesetting}

\author{Jason Moore}

\date{April 2019}

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

Learning LaTeX typesetting does not have to be hard.

While it can be very involved, there are really just a few basics.

If you need additional options after that they are easy to find.

Today I want to talk about how to use LaTeX typesetting in your documents.

LaTeX can be very useful so lets get started.

\end{document}

If you are following along in your own editor you will see that my commented line with a [%] does not show up in the document. It is for you. Use it to remind you of things and to tell yourself at a later date what your logic was. I know I have to do this or I will not remember why I did things.

**Formatting Your Text**

Well this is about LaTeX typesetting so talking about formatting had to come eventually. This is actually a huge topic on its own. For now I am just going to mention the basics to get you started. Later we can go more in depth together.

- To make words bold you use the \textbf{ } command.
- Italicizing is done with \textit{ }.
- Underlining is done with \underline{ }.

Let me show you some examples.

**Making Text Bold**

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

Use the sudo \textbf{fdisk-l} command at the terminal to get a list of block devices in your system.

\end{document}

The preamble is the same as before. Just ignore the title for now as I did not update it. I used \textbf{fdisk-l} to make that bold.

**Using Italics**

Now to italicize you do something very similar.

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

mdadm \textit{--create} \textit{--verbose} /dev/md0 --level=0 --raid-devices=2 /dev/sda /dev/sdb

\end{document}

Try that in your editor. You will see that --create and --verbose are now italicized.

**Underlining Text**

To underline portions of your text you do the same thing. Notice how everything I underlined is enclosed with this bracket.

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

dnf install \underline{@virtualization}.

\end{document}

This will have [@virtualization] underlined.

**Lists in LaTeX Typesetting**

Lists are easy and a good way to break up your content. They also get across a message well too. We will use a different environment for lists. We invoke it by using [\begin{itemize}. That sets up our environment. For each individual item or bulletpoint you will use [\item]. lets look at an example.

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

\begin{itemize}

\item dd if=/dev/sda of=/dev/sdb [clones one disk to another]

\item dd if =/dev/sda2 of=~/hdadisk.img [backs up sda2 as an image file]

\end{itemize}

\end{document}

This is an unordered list. It is just bulletpoints. You can see how easy that is. Note the beginning and ending of the [itemize] environment.

We can do the same thing with to make an ordered list. These are sometimes helpful so we should know how to do them. We use a different environment for this too. It is the [enumerate] environment.

\begin{document}

\maketitle

% Make sure and check for spelling errors before publishing.

\begin{enumerate}

\item firewall-cmd --add-port=9090/tcp

\item firewall-cmd --permanent --add-port=9090/tcp

\end{enumerate}

\end{document}

You can see how the [enumerate] environment lets us order our list.

**Displaying Math In Latex Typesetting**

Here comes the really fun part of this! A lot of us have had to write about an algebra or calculus concept at one time or another. Do you remember the first time you opened up Word and tried to figure that out? So how long did it take you to get frustrated? Well LaTeX type setting has been around a lot longer than Word and other similar types of software. I am going to be writing about the display mode capabilities today just in case you are wondering. Lets start off in simple terms. Get it, terms, in math? Oh never mind.

So here is basic Algebra.

\[ y + 8 = 30 \]

This is some Calculus.

$$E=mc^2$$

$$f(x)=3x^2+2x-5$$

These small equations are displayed by by enclosing them with $$ before and after the equation. This is called the display mode in LaTex typesetting.

**Math Expressions**

Expressions are a fundamental part of equations. They are what make up equations to be precise. Something like:

$$f'=3x^3+4x^2+9x-3$$.

The code to display that is f'=3x^3+4x^2+9x-3.

You can do most of algebra with that little bit of code. It will take care of simple expressions, logarithms and exponents. There are some nuances and other details that I will get into later.

**Parentheses In Latex**

These are every day items when doing math of any kind. In Latex typesetting you can control almost every aspect of how they look.

So if I want to make an equation behave a certain way with parentheses it is easily done. Lets take this one for example and then I will break it down into smaller pieces.

$$y=\left \{3x+6 \right \} + \left \{4x-2 \right \}$$

To do this you will enclose your whole line in $$ ... $$

You will use the \left and \right commands. After either \left or \right you add a space.

So your whole will look like this: $$ \left \{ .......... \right \} $$

The dots are where your expressions go.

The size can also be controlled. You can do \big{ , \Big{ , \bigg{ , \Bigg{ instead of using \left and \right . The reason is that \left and \right use automatic sizing. Sometimes you may want your parentheses a different size and have to manually size them.

$$y= \bigg \{4x-9 \bigg \}$$

You can recreate this simple line by using y= \bigg \{4x-9 \bigg \} in your editor or file.

**Fraction In Latex Typesetting**

Simple fractions are used continually in math and calculus. Elementary school and collegiate courses both use them constantly. They take the form of \frac {}{}. The top number or letter goes in the first pair of parentheses. The bottom number or letter goes in the second pair.

So lets do a simple problem. What is:

$$ \frac{2}{3} + \frac{3}{4} = ? $$

Of course the answer is to this problem is:

$$ \frac{2}{3} + \frac{3}{4} \rightarrow \frac{17}{12} $$

This is achieved with \frac{2}{3} + \frac{3}{4} \rightarrow \frac{17}{12}. Not too hard at all.

**Trigonometric Operators In Latex**

Once you get to Pre-Calculus in your schooling, trigonometry will be very common. Therefore, it is important to know how to display these operators properly when you are learning about them.

The basic forms are \sin, \cos, \tan, \csc, \sec, and \cot.

We can have problems like:

$$ \cos \frac{5\pi}{6} = ? $$

which is given by \cos \frac{5\pi}{6}.

$$ \sin \frac{4\pi}{3} = ? $$

which is done by \sin \frac{4\pi}{3}.

$$ \tan \frac{3\pi}{4} = ? $$

is displayed with \sin \frac{4\pi}{3}.

$$ \sec \frac{2\pi}{4} = ? $$

is given with this, \sec \frac{2\pi}{4}.

$$ \csc \frac{3}{2\pi} = ? $$

is done with the code \csc \frac{3}{2\pi}.

$$ \cot \frac{11}{4\pi} = ? $$

will be shown by the code cot \frac{11}{4\pi} .

There are a lot more trigonometric functions but this should get you started for now. These are examples for all the basic types of functions.

**Integrals Using Typesetting**

Basic integrals will pop up in your first year of calculus. Therefore, it is vital you know how to handle them. This is where calculus starts getting fun. I will just put the code below the problem as usual. The basic integral form is this:

$$ \int_{A}^{B} x^2 dx $$

\int_{A}^{B} x^2 dx

Another form of the integral looks like this:

$$ \int 5x^2 +3x +9 dx $$

\int 5x^2 +3x +9 dx

Here is a slightly different form but basically the same.

$$ \int 6x^3 - 4x^2 +7x -5 dx $$

\int 6x^3 - 4x^2 +7x -5 dx

This is a more complicated form of an integral.

$$ \int (8x-12) (4x^2-4x)^4 dx $$

\int (8x-12) (4x^2-4x)^4 dx

Integrals can get really complicated. There is a lot more I could list here and talk about here. However, these are the basic forms and will be enough for first and maybe second year calculus.

**Conclusion**

Typesetting in Latex is like many other disciplines. It is fairly easy to get started but can take a very long time to master. Fortunately, it is rare that anyone really needs to master it. most of us, myself included, pick up what we need as we go. It started with computer science and physics classes in school. That got me really interested in this and other topics. That is why it is so fun though. I was already interested in what I was doing and Latex was just an extension of those interests. If you find similar interests and if any of them include typesetting documents for one reason or another then I hope this guide will be useful. I will be adding subsections continually as I am making this my official guide and reference to myself. Hope it helps!