3. From Source Code to Typeset Output
Every time you want to create or edit a LaTeX document, there are three basic steps you will always need to follow:
- Write or edit the source code.
- Pass the source code to the latex or pdflatex application (“LaTeX the document”).
- If there are any error messages, return to Step 1.
- If there are no error messages, a PDF file is created.
- View the PDF file to check the result. If you need to modify your document, go back to Step 1.
You will therefore need:
- A text editor (to perform Step 1). For example Vim, Emacs or Gedit.
- The TeX software[(La)TeX for different
machines] (to perform Step 2). If
you don't already have TeX on your machine, you will need to
install it. The most convenient way to do this is
to install from the TeX Collection DVD ROM, which is distributed
to all TeX User Group (TUG) members, but you can also download and install free
TeX distributions, such as TeX Live,
MiKTeX or MacTeX, from the Internet (see
below). There is also proTeXt,
an enhancement of MiKTeX that aims to be an
easy-to-install TeX Distribution. For more information including
up-to-date links, go to http://www.ctan.org/starter.html.
- A PDF viewer (to perform
Step 3). For example
Adobe Reader,
Sumatra,
Evince or
Okular.
This can be rather complicated for a beginner, especially for those with no experience writing computer code. Fortunately, there are some all-in-one applications (often called a front-end) that provide a text editor (for Step 1), buttons or menu items to run the latex or pdflatex command-line application (for Step 2) and, in some cases, a viewer to perform Step 3.
The next section describes one such front-end called TeXWorks. I have chosen to describe TeXWorks because it is a free, cross-platform application. Binaries are available for Microsoft Windows, Mac OS X and GNU/Linux. The screen shots of TeXWorks in this book were taken from the Linux version running under Fedora. If you run TeXWorks on other operating systems, it may have a slightly different look, but it has the same functionality.
New versions of TeX Live and MiKTeX include TeXWorks for MS Windows, and new versions of MacTeX include TeXWorks for Mac OS X users. GNU/Linux users can use their Add/Remove Software utility to install TeXWorks. Alternatively, you can download TeXWorks by following the links provided at http://www.tug.org/texworks/.
If you're confused by all the options, let's keep things as simple as possible:
- MS Windows:
You have a choice between MiKTeX (or proTeXt) and TeX Live. MiKTeX provides a smaller and quicker installation, but the downside is that you may not have the classes or packages you want to use. MiKTeX can install these whenever you try to LaTeX a document that uses them, but you need an Internet connection while it does this. TeX Live installs everything, so it takes longer and needs more space, but you should have the majority of packages and classes that you need.
- TeX Live:
-
- Fetch and unpack
http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip
- Run install-tl and follow the instructions. This can take an hour or more.
- Fetch and unpack
http://mirror.ctan.org/systems/texlive/tlnet/install-tl.zip
- proTeXt:
-
- Go to http://tug.org/protext/
- Click on the “download the self-extract protext.exe” link to download and run the executable.
- Go to http://tug.org/protext/
- MiKTeX:
-
- Go to http://www.miktex.org/
- In the left-hand panel, there is a link to the download page
for the latest version. At time of writing, it is MiKTeX 2.9.
Click on that link.
- Scroll down to the section “Installing a basic
MiKTeX system”.
- If you're happy with the selected mirror location, click on the
“Download” button.
- Run the executable.
- Go to http://www.miktex.org/
- Mac OS X:
- Go to http://tug.org/mactex/
- Follow the instructions on that page.
- Go to http://tug.org/mactex/
- GNU/Linux:
- Fetch and unpack
http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
- Follow the instructions at
http://tug.org/texlive/quickinstall.html
- Once TeX Live has finished installing, run your
system's “Add/Remove Software” tool.
- Find “texworks”, select the newest version and install.
- Fetch and unpack
http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
If you run into problems, there are mailing lists at http://tug.org/mailman/listinfo/tex-live and http://docs.miktex.org/manual/lists.html for TeX Live and MiKTeX, and MacTeX help at http://www.tug.org/mactex/help/. There is also a list of places where you can ask for help in Appendix C. Need More Help?.
This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).