# Basics of LateX

In this post, we will explore more concepts about Latex the typesetting language.

Optional Commands

Optional commands appear in brackets [   ]  when you are using Latex. In the example below, we will set the font size to 20pt in the preamble of the document. The code is as follows.

\documentclass[4paper,12pt]{article} \begin{document}
Behold the power of \LaTeX
\end{document}

Here is what it looks like

Inside the brackets, we set the paper size to A4 and the font size to 12pt. Many if not most commands have optional commands that can be used to customize the behavior of the document.

Like most coding languages Latex allows you to make comments. To do this you need to place a % sign in front of your comment. As shown below

\documentclass[4paper,12pt]{article} \begin{document}
Behold the power of \LaTeX
%This will not print
\end{document}

Everything after the % did not print. To stop this action simply press enter to move to the next line and you can continue with your document.

Fun with Fonts

There are many different ways to set the fonts. Generally, you can use the \text**{  } code. Where the asterisks are is where you can specify the behavior you want of the text. Below is a simple example of the use of several different formats to the font.

\documentclass[4paper,12pt]{article}
\begin{document}
You can \textit{italicized}
Text can be \textsl{slanted}
Off course, you can \textbf{bold} text
You can also make text in \textsc{small caps}
It is also possible to use several commands at the same \textit{\textbf{time}}
Behold the power of \LaTeX
\end{document}

Notice how you put the command in front of the word that you want to format. This might seem cumbersome. However, once you get comfortable with this it is much faster to format documents then the point and click style of Word.

Environments

If you want a certain effect to last for awhile you can use an environment. An environment is a space you declare in your document in which a center behavior takes place. Generally, environments are used to improve the readability of your code. Below is an example.

\documentclass[4paper,12pt]{article}
\begin{document}
\begin{bfseries}
Everything is bold here
\end{bfseries}
\begin{itshape}
Everything is bold here
\end{itshape}
Behold the power of \LaTeX
\end{document}

An environment always begins with the \begin command and ends with the \end command. In the curly braces, you type whatever is required for your formatting goals. There are scores of commands you can place inside the curly braces.

Conclusion

There is so much more to learn but this is just a beginning. One of the main benefits of learning Latex is the fixed nature of the formatting and the speed at which you can produce content once you are familiar with how to use this language.

# Intro to LaTex

History

LaTex is an open-sourced typesetting document developed about 30 years ago by Leslie Lamport and based on the Tex typesetting of Donald Knuth. It is commonly used in the domains of physics and math for producing mathematical equations and other technical documents. Below is a simple example of an equation developed using LaTex

LaTex is a document markup language, which means that you indicate the commands and then it is processed to produce the desired effect. This is in contrast to Microsoft Word which utilizes a WYSIWYG (What you see is what you get) approach.

Benefits

Using LaTex provides several benefits. Cross-referencing is easily accomplish especially with the help of BibTex. It is also multi-lingual and able to make glossaries, indexes, and figures/tables with ease. In addition, LaTex is highly portable and opening a file on any computer is not a problem. Sometimes moving to another computer using Microsoft Word can cause issues with formatting.

Another benefit is psychology, using LaTex allows the author to focus on content and not appearance when writing. It is easy to get distracted when using Word to try and make something work through the point and click mechanism we are so used to when writing.

Cons

It takes extensive time to use LaTex. It looks similar to coding which is intimidating for many. However, once a certain mastery is achieved. Producing documents can be faster as everything is text-based and not point click based using a mouse.

Using LaTex

To use LaTex you need to install TexLive and TexWorks. TextLive is a LaTex distribution and TexWorks is one of many LaTex editors. The editor allows you to manipulate the LaTex code that you generate.

Once you have installed both programs you can type the following into TexWorks. Make sure the typeset is set to pdfLaTex. This allows the output to be a pdf file.

\documentclass{article}
\begin{document}
This is an example of what LaTex does
\end{document}

What happened is as follows

1. We entered the command \documentclass{article}. All commands begin with a slash followed by the name. The curly braces are required arguments. In this case, we are using the article template which is one of many templates available in LaTex.
2. The next command is \begin and this command indicates the beginning of the actual text of the document. Everything above the \begin command is part of what we call the preamble.
3. Next is the actual text that we want to appear in the pdf.
4. Lastly, we have the \end command which tells LaTex that the document is finished. Everything between \begin and \end command is part of the environment.

Conclusion

There is so much more that can be accomplished with this typesetting software. The possibilities will be explored in the near future.