Manual update of LaTeX packages on Ubuntu

I installed LaTeX in both the OS that I have: Windows 7 and Ubuntu 12.04.

Recently I just discovered a new command of LaTeX that lets you change the default margins of your output document. This command requires the package called “geometry“.

In Windows 7 I use MikTeX to write any LaTeX document. The first time I used the new command, the program asked me to download and install the new package. After this operation, everything worked fine and I obtained an output file with custom margins.

However, when I tried to compile the exact .tex file on Ubuntu, I would get an Undefined control sequence error.

The strange thing is that I already installed every basic, extra, recommended and math packages.

After some research on web, I found out that maybe my geometry package was not the newest version.

So I decide to download the newest version from CTAN and manually update the package.

The overall process are:

1) Download the package that you want. You need to save the file XXX.dtx, where XXX is the name of the package. In this case is geometry.dtx

2) Now we need to get a file ending with .sty that LaTeX can use. To do so we just need to type in the terminal:

tex geometry.dtx

This command works only if you are inside the same directory of the package you downloaded. Otherwise you need to write the full path.

3) Locate the geometry.sty that the command above created and move or copy it to

/usr/share/texmf-texlive/tex/latex/geometry/

in order to replace the old one.

Or, as said in the source (below), for any manual update you should put the new version in /usr/local/share/texmf/tex/latex/geometry/ (which always gets searched *before* the texmf-texlive tree). However I have not tested this option so I don’t know if it works or not.

4) After any (manual) update you need to run the command

sudo texhash

to update the texmf-texlive tree. Otherwise new files will not be found out.

Sources:

Leave a comment