Eberly College of Science Mathematics Department, Center for Interdisciplinary Mathematics
REU banner

LaTex, and writing a math paper




Useful LaTex packages

For practice, follow all of the directions below using commands in the terminal that we learned about yesterday. You may find it useful to use more than one terminal window (one for your text editor and one for shell commands).

  1. Create a new directory on your Desktop called "LaTex".

  2. Change your current working directory to your new "LaTex" directory.

  3. Create a new file called "hello.tex" in your new directory. This will be your first LaTex document. LaTex files traditionally end with the ".tex" suffix.

    The common work-flow for creating documents with Latex is

    1. Edit your .tex file.

    2. Compile your .tex file with the pdflatex command.

    3. If you get compile errors, fix them and recompile.

    4. Inspect your .pdf output in a pdf viewer.

    This is the same kind of work-flow used in writing Fortran and C programs, so it is a good introduction. Here is how it goes...

  4. Type the following code into your "hello.tex" file.

        hello world!
        My favorite book is

    Be sure to save your changes.

    LaTex is a "markup" language, which tells printers and other tools what you want your document to look like. None of the tags above beginning with a backslash will appear in your final pdf document.

  5. At your shell command line, compile "hello.tex" using the following command.

            pdflatex hello.tex

    This compiles your LaTex file. It creates a bunch of new files in the process.

  6. Use the Preview or Acrobat portable document format viewers to inspect your new "hello.pdf". Compare what you got out with what you put in and see if you understand what happened. How does the arrangement of the text you got out differ from what you put in?

  7. Make a backup copy of the file "hello.pdf" for future reference.

  8. Update "hello.tex" file to be the following.

        hello world!
        should be number one in the list
        should be number two in the list

    Be sure to save your changes.

  9. Compile "hello.tex" like you did above. This time, however, you are going to get an error. Read the error message, see if you can figure out what is wrong with your changes, and fix things.

  10. Once you have fixed things, you can inspect "hello.pdf" to see how LaTex typesets an enumerated list. Notice that we did not have to do the numbering ourselves – LaTex handled all that.

  11. Remove hello.log and hello.aux.

    (you do not really need to do this - pdflatex with overwrite them as needed, but it is another chance to practice shell commands)

  12. The reason we have used LaTex for decades is that it provides a free common platform for writting pretty mathematical equations, and that it allows us to focus on what we mean rather than what we see.

    Create a new file "myfirstmath.tex" with the following content.

    % comments in LaTex are started by the percent symbol
    % if you want to type "%" in Latex, use \%.
    \usepackage{amsmath} % this is a library package for math commands
    % The "ams" in amsmath stands for American Mathematical Society
    my first equation is not 100\% true.
        2 + 2 = 5 + \sqrt{3 + x^2} = 45 \leq \frac{z_6}{3 + \beta}.
    My second equation is inline: $ 2 + 3 > 5 \times 1 $
    My 3rd equation is the system
        x + y = 5,
        10 x - 10 y = 30.
    But we could also typeset  this system as
        x + y &= 5,
        10 x - 10 y &= 30.
    Maybe Equations~\eqref{eq4a} and \eqref{eq4b} look better than
    Equations~\eqref{eq3a} and \eqref{eq3b}
  13. Compile "myfirstmath.tex" once and inspect "myfirstmath.pdf" What commands did what? Also, notice that there are a few question marks.

  14. Compile "myfirstmath.tex" a second time and inspect "myfirstmath.pdf". What happened to the question marks?


That is basic LaTex. To get some practice, create your own LaTex document explaining how the quadratic formula is used to solve a quadratic equation using the commands above.