Getting Started with LaTeX

Now that we know a bit about the history of LaTeX and its purpose and support, let's deal with how to install the program and then do something with it. Unfortunately, at this point my up-to-date knowledge is only on a Windows machine.

So, for a Windows machine, like Windows 10, my trusted sources for these files are http://www.tug.org/ and https://miktex.org/download

 1) I use the TeXworks version of a GUI for LaTeX: TeXworks-win-setup-.....exe executable (or something similar), which is currently about 24 MB.
 2) I use the MiKTeX executable for the TeX engine itself: basic-miktex-21.6-x64.exe (or something similar) which is currently about 128 MB. (Install MiKTeX first, because it may be all you need.)

There are other implementations of LaTeX for the Windows platform, and you can look those up if you want.

Once LaTeX is installed, all you should have to do to open up the LaTeX program is to double-click on any .tex file, which is the extension I use for my LaTeX files. At the very least a LaTeX editor windows should open up. If you have in the same folder a working complied version of the .tex file, an output windows should also open up, showing the LaTeX output files. In my LaTeX version, I can't print directly from this file, so instead, I open up the PDF version of the file and print as many pages of it as I want.

This brings me to the fact that you will probably want to install Adobe's PDF reader program, if you haven't already. By the way, if you try to recompile the TeX code while you have the PDF file in a PDF reader, you will get an error, because the rendering program won't be able to rewrite the PDF version of the file.

The following output file snippet

comes from the following .tex file, named prog1.tex:


\documentclass{article}

\title{Notes on the Quadratic Formula}
\author{My Name}

\begin{document}

\maketitle

%\begin{abstract}
%\noindent We wish to characterized how the roots of polynomials
%depend on their coefficients.
%\end{abstract}

\section{Introduction}

We write as our `general' quadratic equation as
\begin{equation}
       x^2 +bx+c=0\,,\label{eq:general.quadratic.equation}
\end{equation}
where $b$ and $c$ are complex numbers. Believing that every quadratic equation
has two roots $x_1$ and $x_2$, so that the quadratic can be factored as
\begin{equation}
       (x-x_1)( x-x_2)=0\,,\label{eq:(x-x_1)(x-x_2)=0}
\end{equation}
we can find the values of those roots in terms of the coefficients of the equation. How?
First, we expand (\ref{eq:(x-x_1)(x-x_2)=0}) to get
$$
       x^2 -(x_1+x_2)x+x_1x_2=0\,.
$$
The polynomials $x_1+x_2$ and $x_1x_2$ are said to be {\it symmetric}
because, under any permutation of subscripts on the $x$'s, the polynomials are unchanged.

\end{document}


The command \documentclass{article} tells LaTeX to use the article style file when interpreting such commands
\begin{abstract} ...\end{abstract}
\begin{equation} ...\end{equation}
\section{...}

But there are other kinds of documentclass types, such as report, book, slides, and letter

But I will only discuss \documentclass{article} functionality in all my writings on LaTeX.

The command \begin{document} is where the actual output rendering begins, or should begin. Somewhere after this command should be the \end{document} command. You could put it on the very next line, or anywhere after that, depending on how large a .tex file your computer can handle. Whatever you place after the command \end{document} is ignored by the compiler.

Now for the particulars:

1) An article normally has an abstract, but in this article, I commented it out so that no abstract will print. (Some publishers may not want you to include an abstract for a short article.) Of course, you could instead erase all that abstract environment that you aren't using, but what if you find out that you have to have one afterall? It's better to just remove the comments to reactivate it than to start from scratch. A % will comment out everything to the right of that character, and the complier will ignore it.

So, how would you print a % sign, rather than employ it for commenting out text? You 'escape' it by placing a backslash just before it, like \%. LaTeX has a number of special characters used for markup that default to special use if not escaped by a leading backslash, such as

\# \& \% \$ \_ \{ \}

The error message you get when attempting to print an unescaped special character can be hard to figure out, so it will help you to remember that not all characters can be printed verbatim. By the way, the normal use of the curly braces {,} is to define somekind of special environment, like for printing text in some nondefault font, like {\it symmetric}, which prints the word 'symmetric' in italic. But mostly it is used to delimit parameters of commands, like in \begin{equation} ...\end{equation}.

Finally, what about printing the backslash character? Just use this in text mode $\backslash$.


Now let's start our learning curve for how to do mathematics into print, beginning with inline text.

For this, we use a $ sign to start and stop the math code, such as was done by $x_1+x_2$ to get x1 + x2. The '_' underscores make subscripts and to get superscripts the '^' character, we use, as an example, $E = mc^2$ to get E = mc2.

Now we look at how to make a displayed equation For example, the code
\begin{equation}
       (x-x_1)( x-x_2)=0\,,\label{eq:(x-x_1)(x-x_2)=0}
\end{equation}
was labeled with \label{eq:(x-x_1)(x-x_2)=0}.

Now, you don't have to invoke a label if you don't want to, so there's no harm in labeling everyone of your displayed equations if you want to, and get it down as you go for future possible use. In the case of the above code, this second equation was referenced by the command (\ref{eq:(x-x_1)(x-x_2)=0}). One of the great advantages of LaTeX is that it will do automatic labeling/referencing for you. But the very first time the complier sees your program, it won't know how to make references on the first pass. So, if you invoke a reference to a label, on just the first pass the reference will look like '(??)'. So, if you see this, don't worry, you probably just need to compile the program again. (Or you may have a mismatch between the label and its reference.)