Tuesday, April 21, 2009

Installing packages in Latex

I am giving you a manual installation procedure for advanced packages in Latex for Windows. Installing it in Ubuntu is easier and I won't discuss here. Usually MikTex or other Latex editor softwares install packages automatically or give you the option to install it from the internet. But this does not work always. I am witting two procedure to install a missing package which worked for me. Remember after installation, you have to refresh the latex as instructed in red color.

1. Sometimes, installing a package is simple. I just type the package name in google ('package.sty') then copy the whole code in a ASCII editor, (e.g. vi or the latex editor itself) and save it with the extension '.sty'. (If you are using documentclass then the extension is '.cls'). This file now has to be placed in a correct directory which you can do in two ways. First, you can create a folder naming 'package' and put your 'package.sty' file in it. Now copy this folder to the location where you have your texmf folder into its subdiretory '...\texmf\tex\latex\'. Second, you can put your 'package.sty' in '...\texmf\tex\latex\misc'. See which one works. Run 'Refresh Now' from 'Start -> MikTeX -> MikTeX Option -> General -> Refresh Now' or in Vista I see its in 'Start -> MikTeX -> settings'. If you are not using MikTeX, find out the way to refresh your latex compiler.

2. (i) Download the package from CTAN (look in contrib or others wherever it is) or just search in google (e.g. install 'package' latex CTAN). After unzipping, you will find a folder with the same name. If that folder contains the appropriate 'package.sty' file you are all set otherwise it should contain a installation file 'package.ins'. Once yourun it, the required 'package.sty' should be created in the same folder. Now copy this folder into '...\texmf\tex\latex\'. Refresh your compiler now as written in red color before.

(ii) Some people suggest that you have to run the 'package.ins' file in this directory '...\texmf\source\latex\'. If the previous trial does not work, then copy your 'package' folder to this directory and then hit 'package.ins' and copy the folder to '...\texmf\tex\latex\'. Finally Refresh as given in red color before.

(iii) Again somewhere I find that you have to perform step 2(i) in '...\localtexmf\tex\latex'. See which one works.

3. Sometimes the package you find from internet contains the folder 'package' inside several other directories. Don't bother other folders or anything, just copy your needed folder 'package' wherever you find it and then paste into '...\texmf\tex\latex\'. And Refresh.

You may still find difficulties, in that case try to permute all the procedures I mentioned above and get google's help.

Even if you are not using MikTeX, the procedure should be same in principle, but the location of the directories might be different and you should be able to find the appropriate locations using analogy.

Lastly I hope you did not miss this advanced manual for latex 'The Not so short introduction to Latex 2'. Just google it. Thanks to Baris for letting me know that.

1 comment:

Baris Altunkaynak said...

No thank you. Just a quick correction though: ubuntu not ubantu...