LaTex Documents

Looking at a Sample File

  1. Download this sample file, and open it with TeXworks.

  2. Let's walk through some things.

    First you will notice that some text is in red. These are comments that do not compile and are set off by starting the line with the percent symbol "%." The comments I have in the sample file should explain much about these commands, but I'll repeat them here.

    Everything before the command

    \begin{document}
    is called the preamble and sets up the behavior of your document. I have comments explaining everything in the preamble, but let's look at a few.
    \documentclass[12pt]{article}
    This sets up your document as an "article" with 12 point font.
    \usepackage[top=1in, bottom=1in, left=1in, right=1in{geometry}
    This is a package to set up your margins.
    \usepackage{amsmath}
    \usepackage{amssymb,latexsym}
    \usepackage{amsxtra}
    \usepackage{wasysym} 
    
    These are packages for various mathematics and other symbols.
    \usepackage{amsthm}
    This sets up nice theorem, definition, and example environments.
    \usepackage{graphicx}
    This allows you to easily include graphics and labels in your document.
    \usepackage{setspace}
    \onehalfspacing
    This is George Greenwade's package. You can set spacing to be one-half or double using commands right here in the preamble (like \onehalfspacing).
    \usepackage{verbatim}
    Likely you will not need this unless you make LaTeX handouts. This allows you to include LaTeX commands in your document (as text) that do not execute. I use this to show you what LaTeX commands to type.
    \usepackage{arcs}
    You only need this if you are creating notation for arcs in geometry.

    You can include all of these in your LaTeX documents until you get good at controlling your own documents.

  3. The next group contains the proclamations. You can read my comments for the details, but briefly, we have:
    \theoremstyle{definition}
    This sets the style for proclamations (theorem, example, lemma, etc.) I like "definition."
    \newtheorem{definition}{Definition}[section]
    \newtheorem{example}{Example}[section]
    \newtheorem{theorem}{Theorem}[section]
    \newtheorem{proposition}{Proposition}[section]
    \newtheorem*{fact}{Fact}
    \newtheorem{corollary}{Corollary}[section]
    \newtheorem{lemma}{Lemma}[section]
    
    These set up your declarations. For example, the first one writes "Definition" and the section number after you begin a definition. This helps with automatic numbering. The fifth one, with a "*" after it, writes "Fact" after you begin a fact, but the "*" causes it to not have a number. You can put "*" after any one of these if you do not want numbering.

  4. Next come the definitions, or "shortcuts."
    \newcommand{\df}{\displaystyle \frac} 
    \newcommand{\dlim}{\displaystyle \lim}
    \newcommand{\dint}{\displaystyle \int}
    
    The first defines the shortcut "df" to mean "\displaystyle \frac" It is simply a typing convenience.

  5. Your document itself starts with
    \begin{document}
    and ends with
    \end{document}
    In between is where the magic happens.

  6. With the file "Stoudt Sample Document.tex" open, next to green compile button, remember you will see something like "pdfLaTeX+MakeIndex+BibTeX." If you changed the default earlier, it will say "pdfLaTeX." If not, click on the downward triangle next to that and choose "pdfLaTeX." Then click on the green "Compile" button.

    A new window should open with a PDF file of the document. This is where you really learn LaTeX. You look at the finished document, and go back to the *.tex file to see what commands created it. There is a lot to take in, but it is a great way to learn. The "Stoudt Sample Document.tex" has most of the math and typesetting you will need in undergraduate mathematics.

  7. It's time to practice.
On to the practice document.

Back to Dr. Stoudt's home page.