Common tasks in LaTeX

This page describes some common tasks required for linguistics or making biblio­graphies, assuming you’ve already started learning LATEX.

This is meant to be a reference, not a narrative. I’ve tried to link back here whenever you need the information.

The command line

All operating systems have a command line/prompt. Some lucky LATEX users don’t need to know about it, but linguists do because we need so many customizations. At some point you will want to do the following things:

  • Find the command line in Windows and Mac.
  • Run a command. This means type it in the command line, then hit Enter.
  • Change directories using cd directoryname* in WindowsMac or Unix.
  • Optional: Make a script to run repetitive commands in WindowsMac or Linux.

name means you should fill in the relevant name of the file, directory, etc. When the name includes spaces you usually need quotes, e.g. cd "\Documents and Settings\E-Ching\My Documents".

Running latex

When people talk about compiling a .tex file with latex, or running latex, it’s actually a bit more complicated.

Simplest case

  1. Go to the command prompt.
  2. Go to the directory containing your .tex file (see above).
  3. Run latex filename (the name of your .tex file minus the .tex).
  4. Run dvips filename.
  5. Run ps2pdf filename.pdf.

If your file contains cross-references

  1. Run latex filename.
  2. Run it again.
  3. Run dvips filename.
  4. Run ps2pdf filename.pdf.

If your file uses BibTeX

  1. Run latex filename.
  2. Run bibtex filename (the name of your .tex file minus the .tex).
  3. Run latex filename.
  4. Run latex filename again.
  5. Run dvips filename.
  6. Run ps2pdf filename.pdf.

All that work for one PDF file, and it doesn’t even open automatically!

This is why you might want to make a script for repetitive commands (see Windows vs. Mac/Linux). This Windows script lets me type just mylatex filename.

Running pdflatex

Running pdflatex is like running latex except that (1) you type pdflatex instead of latex and (2) you can omit the last two steps (dvips, ps2pdf).

This Windows script lets me type just mypdflatex filename.

Importing other people’s code

Using standard LATEX packages

To use a package that’s included in standard LATEX systems (including yours, we hope), just add \usepackage{packagename} to your document preamble, i.e. anywhere in the document before \begin{document}.

Importing from outside standard LATEX

When you import a tool that isn’t part of standard LATEX, you need to do a few things.

  1. Save it in the right place. LATEX wants all its original files in one place, and all your local customizations (and additions) in a different place, which differs from system to system.
    • TEX Live – The texmf-local subfolder inside the main texlive folder.
    • MacTeX – Similar to TEX Live. In the Finder’s Go menu, select Go to Folder; in the resulting dialog window, type /usr/local/texlive. The texmf-local subfolder is what you want.
    • MikTeX – You can specify the folder for local customizations, but I’ll call it texmf-local for convenience.
  2. Exactly the right place. You need to get exactly the right subfolder of a subfolder of a subfolder. Usually the website offering the download will tell you, but here’s the quick guide:
    • .sty files (packages) go into texmf-local\tex\latex
    • .bst files (bibliography styles) go into texmf-local\bibtex\bst
    • .tex, .cls and .fd files go into texmf-local\tex\latex
  3. Inform LATEX of the change. I have yet to work out which of these commands is for which situation, so I just run all of them until LATEX finally understands that something has changed.
    • texhash
    • mktexlsr
    • updmap-sys or if that doesn’t work, updmap
    • fmtutil-sys or if that doesn’t work, fmtutil --all


Linguists like XƎTEX because it lets us type IPA characters directly into .tex files, but its real purpose in life is to access non-LATEX fonts via the fontspec package (required). This quick introduction explains how to try it out.

Note: I call it XƎTEX for short, but really we’re using its simplified cousin XƎLATEX, in the same way that LATEX is a simplified version of TEX.

Running xelatex

Running xelatex is like running latex except that (1) you type xelatex instead of latex and (2) you can omit the last two steps (dvips, ps2pdf).

This Windows script lets me type just myxelatex filename.

Making XƎTEX compatible with pstricks

Common XƎTEX commands

Note: All XƎLATEX commands listed here should go into the document preamble.

  • \usepackage{fontspec} % Required by XeTeX
  • \usepackage{xltxtra} % XeTeX imitates/improves on LaTeX

The fontspec package can take advantage of non-Windows fonts.

  • \setmainfont[Mapping=tex-text,Numbers={OldStyle,Proportional}]{Charis SIL} % For the serif font: enables LaTeX curly quotes and dashes; sets appearance of numbers; sets font name
  • \setsansfont[Mapping=tex-text,Numbers={OldStyle,Proportional}]{Lucida Sans Unicode} % Similar options for the sans serif font, fails gracefully
  • \defaultfontfeatures{Scale=MatchLowercase} % Matches font sizes, otherwise sans serif looks huge
  • \newcommand{\doulos}{\fontspec[Mapping=tex-text,Numbers={OldStyle,Proportional}]{Doulos SIL}} % Lets you use the Doulos SIL font with the command {\doulos text}

Note: If you install new fonts, make sure to inform LATEX.


Exporting LATEX

  • LATEX to HTML. I’ve been very impressed with the TeX4ht program included with TEX Live. You can download it and read more about its usage at the TeX4ht info page.
  • LATEX to Word. Because the HTML converter seems so much better than any of the others, I usually convert to HTML (see above), then open the HTML file in Word. But see this helpful page on converting from LATEX to PC textprocessors.
  • Word to LATEX. I have no personal experience of these programs, but they exist: two free methods (OpenOffice can save LaTeX, rtf2latex2e), Word-to-LaTeX converter (shareware), and GrindEQ’s Word-to-LaTeX module (free to download, expensive to register?). Many more options described at this page.

BibTeX with Word

It is possible to use BibTeX with Word instead of LATEX, using the following programs.

  • Zotero – the Word plugin accompanying the browser plugin
  • Bibtex4Word (Word 2003 or later) – a Word add-in.

If you follow this unusual path, you will also want a reference management tool. This makes it possible to type in references without learning LATEX.