LaTeX Basics

There are many reasons for learning to produce a LaTeX document. The main one is that LaTeX is the de facto standard for the communication and publication of scientific documents. Most journals in mathematics and many of the other sciences expect papers to be submitted in some form of LaTeX. It is not uncommon in some graduate classes that homework be submitted as LaTeX output. And currently (that is during the coronavirus pandemic) it is the best way to produce papers that are easy to send by e-mail and easily read by the recipient.

If you already know how to produce a LaTeX document, you can ignore most of the instructions here. If you are new to LaTeX here is how to use Overleaf to produce a LaTeX document.

Step 1: Getting started.

  • Register for a (free) Overleaf account by going to Overleaf/register.
  • Next view the 2 minute video at Writing a basic LaTeX document with overleaf. You should understand the first minute of the video (0:00-1:02). For the part after 1:02 (when he is typing stuff such as \documentclass) just try to get the idea of how to (re)compile a document.

    Step 2: Your first Latex Project

  • Log into your Overleaf account at Overleaf.
  • Select the New Project icon (left column tool bar with green background), and then from the drop down selection chose Blank Project.
    A window should pop up asking you to name your New Project. Let us use no originality (and avoid offending the computer gods) and call the first project "Hello World"
    Delete the code in the source window and take the following code and cut and paste it into Overleaf (or whatever you are using for LaTeX) and paste in (or better yet type it in yourself) the following:
    \documentclass{article}  % Tell LaTeX what type of document we are making.
                             % Percent signs are used for comments and what is
                             % to the right of them is ignored.
    
    \begin{document}  %  Start the document.
    
    
    Hello world.   
    
    
    
    Ordinary text (that is non mathematical text) is just typed
    as usual ordinary text.  But LaTeX will decide where the line
    breaks are.
    
    A new paragraph is started by leaving one or more blank lines.
    
    So this is a new paragraph.
    
    
    % Mathematical formulas in a line are put between \(  and \)
    
    The basic quadratic equation is \(ax^2 + bx + c =0\).  
    
    
    % Displayed mathematical formulas are put between \[ and \]
    
    This can be done in one line \[ ax^2+bx+c=0. \]
    But it is usually easier to read your code if you make it look
    displayed 
    \[
      ax^2+bx+c=0.
    \]
    (LaTeX will not care, but if you are looking at your code a month after
    writing it you will.)
    
    Let us give a slightly more complicated displayed equation
    which gives a good idea of what general LaTeX looks like:
    \[
    	x = \frac{-b \pm \sqrt{b^2-4ac}}{2a}.
    \]
    
    A basic formula in much of analysis is the sum of a geometric 
    series
    \[
       \frac{a}{1-r}= a+ar + ar^2 + ar^3 + ar^4+ \cdots = \sum_{n=0}^\infty ar^n
    \]
    which converges for $|r|<1$.
    Thus if
    \[
    	S = 3 + 3 x + 3 x^2 + 2 x^3 + \cdots = \sum_{n=0}^\infty 3x^n
    \]
    we have
    \[
          S =   \frac{3}{1-x} 
    \]
    
    \end{document}  % This tells LaTeX we are done.
    
    
    The output of this should look like click here to see it. A point that is confusing at first is that in LaTeX there are several ways to do the same thing. For example to do in line mathematics both
    \( ax^2 + bx + 2 \)
    
    and
    $ a x^2 + bx + c $
    
    give the same output. Worse yet is displayed formulas where all three of
    \[
    a x^2 + bx + c
    \]
    
    $$
    a x^2 + bx + c
    $$
    
    and
    \begin{equation*}
    a x^2 + bx + c
    \end{equation*}
    
    give the same output. So in some of the videos recommended below things will look a bit different than what I have above. You and use whatever you find easiest.

    Some useful LaTeX resources: