Other LaTeX How-To's

how to double-space a document

Use the setspace package, then set the spacing you want:

\usepackage{setspace} 
\doublespacing

Other options:

  1. \singlespacing
  2. \onehalfspacing
  3. \setstretch{x}, where x is the desired spacing (e.g. \setstretch{3} = triple spacing)

how to number pages: Page # of n

I wanted page numbering that referenced total number of pages (e.g., "Page 1 of 4"). It took me a long time to figure this out, but this is how I got it to work:

\usepackage{fancyhdr,lastpage}
\pagestyle{fancy}
\fancyhf{}
\rfoot{\scriptsize{Page \thepage\ of \pageref{LastPage}}}
\renewcommand\headrulewidth{0pt} % Removes funny header line



how to center a table

Enclose the tabular environment within the "center" environment, like so:

\begin{center} % put inside center environment
\begin{tabular}{l l l l}
label 1 & label 2 & label 3 & label 4 \\
\hline % put a line under headers
item 1 & item 2 & item 3 & item 4 \\
...
\end{tabular}
\end{center}


vim beamer templates

If you use Vim (a vi based text editor), there exists a nice LaTeX suite for it that I use exclusively to edit my LaTeX documents. If you happen to use Vim and the corresponding LaTeX suite as I do, I've created some nice presentation templates that you may find useful. I use the method of splitting my presentation up into three documents as explained in the beamer tutorial (take a look at its explanation before you continue here). If you don't like this method, you can just put the header from the "main.tex" document onto "beamer.tex" and just get rid of "article.tex". If you like this method fine, just use the templates as is.

how to use the templates

  1. Download the three template files: main.tex, beamer.tex, and article.tex. Place them in a useful location.
  2. Open up the three templates with the following command:
    vim -R /path/to/main.tex /path/to/article.tex /path/to/beamer.tex
    Remember to replace "/path/to" with the relevant path to the file. Note: The option "-R" opens these files read-only, so you don't accidentally write over the templates.
  3. Let's look at the main.tex template. It includes the bottom of the header and three slides. (You may want to add more slide templates if you regularly create more than 3 slides in your presentations.)
    \title{<++>}
    \author{<++>}

    \begin{document}
    \begin{frame}
    \titlepage
    \end{frame}

    \begin{frame}
    <++>
    \end{frame}

    \begin{frame}
    <++>
    \end{frame}

    \begin{frame}
    <++>
    \end{frame}

    \end{document}
    Note the various instances of "<++>" in the document. These act as "placeholders" within the document to make editing much faster. Press ctrl-j. If all goes well, this should take your cursor to the first instance of the "<++>" (inside the title bracket) while simultaneously deleting these placeholder symbols, thereby letting you quickly enter the title. Once you are finished with the title, press ctrl-j again; now you should be within the author brackets. Enter your author, then press ctrl-j once more. Now you should be within the first slide. See how this works? This will allow you to quickly fill in the template, without having to type in the repetitive header and frame environment codes, and without having to move your cursor all over the document by hand.
  4. Once you are done editing this document, save it as a new file (again, you don't want to save this over your template file). Then you can move onto the "beamer.tex" document by pressing esc, then typing :next. Edit this document the same way: the only thing you need to enter here is the new filename of the altered "main.tex" file. Press ctrl-j to take you directly there.
  5. Once you are finished, save this file as well (under a different name), and move onto your "article.tex" file and do the same thing.
Now you can just compile your new documents and be done. These templates save me quite a bit of time; hope you find them useful!