Managing Latex packages manually in Ubuntu 12.04

Ubuntu is great, but making it play nice with latex is a bit of a pain. There are three parts to this:

  1. Ubuntu comes with APT, a really nice package management system that lets you easily install, update, and remove software that has been helpfully packaged by both Canonical and the wider Debian community.
  2. Tex Live, the official release of latex, comes with tlmgr, an equally great package manager for managing the all of the latex packages on CTAN.
  3. Ubuntu’s distribution of latex omits tlmgr and forces developers to repackage the latex packages to fit into the APT scheme. (source)

This seems to be why my previous post about fixing moderncv for Ubuntu was so popular. It is not obvious to most users that to fix the

LaTeX Error: File `marvosym.sty' not found.

error, the user has to both (1) find the Ubuntu package that provides marvosym.sty and then (2) install that Ubuntu package along with every other latex package that happens to be bundled with it.

All of that is fine if a kind-hearted developer had the foresight to bundle the latex package you want/need in a convient form for installation with APT. If not, you have two options:

  1. Keep Tex Live under the control of Ubuntu’s package management and manually install the Latex packages you need. An easy way to do this is described below.
  2. Break out Tex Live from Ubuntu’s package manager and use tlmgr for Latex package management. This gives you MikTex style latex package management for Ubuntu, but you are responsible for keeping Tex Live up to date. See the answers to this Stack Exchange question for details of how to do it.

For now I’m sticking with Option 1. Here is a worked example to install the Latex package outlines for Ubuntu:

  1. Look at the path Latex searches to find packages with ‘kpsepath tex’ which should give output similar to:
    nathanvan@nathanvan-N61Jq:~$ kpsepath tex | sed -e 's/:/\n:/g'
    .
    :/home/nathanvan/.texmf-config/tex/kpsewhich//
    :/home/nathanvan/.texmf-var/tex/kpsewhich//
    :/home/nathanvan/texmf/tex/kpsewhich//
    :/etc/texmf/tex/kpsewhich//
    :!!/var/lib/texmf/tex/kpsewhich//
    :!!/usr/local/share/texmf/tex/kpsewhich//
    :!!/usr/share/texmf/tex/kpsewhich//
    :!!/usr/share/texmf-texlive/tex/kpsewhich//
    :/home/nathanvan/.texmf-config/tex/generic//
    :/home/nathanvan/.texmf-var/tex/generic//
    :/home/nathanvan/texmf/tex/generic//
    :/etc/texmf/tex/generic//
    :!!/var/lib/texmf/tex/generic//
    :!!/usr/local/share/texmf/tex/generic//
    :!!/usr/share/texmf/tex/generic//
    :!!/usr/share/texmf-texlive/tex/generic//
    :/home/nathanvan/.texmf-config/tex///
    :/home/nathanvan/.texmf-var/tex///
    :/home/nathanvan/texmf/tex///
    :/etc/texmf/tex///
    :!!/var/lib/texmf/tex///
    :!!/usr/local/share/texmf/tex///
    :!!/usr/share/texmf/tex///
    :!!/usr/share/texmf-texlive/tex///
    
  2. Note that the entry on line 21 is ‘/home/nathanvan/texmf/tex//’, which tells latex to search every subdirectory under ‘/home/nathanvan/texmf/tex’ to find packages that haven’t been found yet. You’ll have something similar for your home directory.
  3. Make a ‘texmf/tex/latex’ directory under your home directory:
    nathanvan@nathanvan-N61Jq:~$ mkdir -p ~/texmf/tex/latex
    
  4. Find the pacakge you want on CTAN, say outlines, because you read this blog post and want to try it out.
  5. Download the ‘the contents of this directory bundled as a zip file‘, as CTAN likes to say it, and save it to ‘~/texmf/tex/latex’
  6. Unzip it right there:
    nathanvan@nathanvan-N61Jq:~$ cd texmf/tex/latex
    nathanvan@nathanvan-N61Jq:~/texmf/tex/latex$ ls
    outlines.zip
    nathanvan@nathanvan-N61Jq:~/texmf/tex/latex$ unzip outlines.zip
    Archive: outlines.zip
    creating: outlines/
    inflating: outlines/outlines.pdf
    inflating: outlines/outlines.sty
    inflating: outlines/outlines.tex
    inflating: outlines/README
    nathanvan@nathanvan-N61Jq:~/texmf/tex/latex$ ls
    outlines outlines.zip
    

And then you are done installing the latex package. It works great without any big hassles.

Edit: If the package you were installing contains fonts, this won’t quite work. See Steve Kroon’s comment below for details of how to fix it.

Edit: Thanks to jon for pointing out the correct directory structure for ~/texmf in the first comment to this answer. For the curious, more details, including why the directory is called texmf, can be found here.

10 thoughts on “Managing Latex packages manually in Ubuntu 12.04

  1. Pingback: Install Tex Live 2012 « livesoncoffee

  2. helmingstay

    Note — for some packages, you might need to run latex on the .ins file. For example, with the undertilde package, the following works after downloading the relevant files, as above:

    latex undertilde.ins

    Reply

Leave a Reply