Sunday, April 24, 2011

LaTeX 'Ubuntu Documentation'

LaTeX is a language for describing a document. If you have used HTML, or edited a wiki then you will be familiar with the idea of using symbols or commands within a text file to describe the layout of text. LaTeX is commonly used in scientific publishing. It helps you to make well formatted papers, with good looking formulae. It also helps keep track of figure and equation numbers. LaTeX files can be converted into a huge number of formats such as PDF, PostScript, DVI, and HTML.
A LaTeX file is an ASCII file containing the text and markup commands. It can be written in a text editor such as Gedit or vim. It is converted into an output format using a LaTeX compiler. Some people like to write LaTeX files in a more integrated environment, with menus and buttons for formatting commands. There are also many add on packages that add features to LaTeX.


Like Linux, LaTeX is a collection of many interdependent tools and files. Rather than find and install them all you use a LaTeX distribution. LaTeX distributions in the Ubuntu repositories are:
  • TeX Live
  • teTeX (no longer supported, some of the teTeX packages in Ubuntu are transitionary packages to TeX Live)

TeX Live

One LaTeX distribution you can install is TeX Live. TeX Live has a more comprehensive selection of LaTeX tools than teTeX but takes up more space. It is also a newer addition to Ubuntu than teTeX. It is available for Ubuntu from version 6.10 and is in the Universe repository.
To install TeX Live, install texlive. This will install a basic subset of TeX Live's functionality. To install the complete TeX Live distribution, install texlive-full.


teTeX was a common LaTeX distribution for Linux. This is in the Main and Universe Ubuntu repositories and can be installed with synaptic or apt-get. At a minimum you will need to install the packages tetex-base, and tetex-bin. Extra packages for teTeX can be found in tetex-extra.

Add packages:

LaTeX can be extended using add on packages. Packages can either be installed using Ubuntu's packaging system, or by manually copying the files to the respective locations.

Installing packages manually

If a package you desire is not in Ubuntu's repositories, you may look on CTAN's web site or TeX Catalogue Online to see if they have the package. If they do, download the archive containing the files. In this example, we'll install example package foo, contained in foo.tar.gz.
Once foo.tar.gz has finished downloading, we unzip it somewhere in our home directory:
tar xvf foo.tar.gz

This expands to folder foo/. We cd into foo/ and see foo.ins. We now run LaTeX on the file:
latex foo.ins

This will generate foo.sty. We now have to copy this file into the correct location. For the purposes of this example, we will copy this into our personal texmf tree. The advantages of this solution are that if we migrate our files to a new computer, we will remember to take our texmf tree with us, resulting in keeping the same packages we had. The disadvantages are that if multiple users want to use the same packages, the tree will have to be copied to each user's home folder.
We'll first create the necessary directory structure:
cd ~
mkdir -p texmf/tex/latex/foo

Notice that the final directory created is labeled foo. It is a good idea to name directories after the packages they contain. The -pattribute to mkdir tells it to create all the necessary directories, since they don't exist. Now, using either the terminal, or the file manager, copy foo.sty into the directory labeled foo.
Now, we must make LaTeX recognize the new package:
texhash ~/texmf

The new package should now be installed. To use it in your LaTeX document, merely insert \usepackage{foo} in the preamble.

No comments: