Monday, November 29, 2010

Installing & Configuring TeX Live and Texmaker on Ubuntu

Well this is not a entirely a new thing and there are many resources to learn this. But, one may have to spend hours crawling through forums and web pages searching and collecting necessary information. Here you have everything you want to know to start preparing your LaTex document.

TeX Live is probably the best LaTeX document processing system available for Linux. There is another system called teTeX but this is not supported any longer. TeX Live is said to be much more comprehensive than teTex. So Tex Live seems to be the best option. (Ubuntu documentation for LaTex)

Installing Tex Live 
You have two options; You can go for Tex Live full version or basic version. Well up to now Tex Live basic version was enough for me (I am using LaTeX for preparing my final year project thesis).
basic version
$ sudo apt-get install texlive
full version
$ sudo apt-get install texlive-full
more info
I am not sure about the actual download size but after installation it will consume around 130MB of memory from your hard disk.

LaTeX editors
Kile and Tex Maker are quite popular latex editors. Kile is for KDE. Tex Maker is a cross-platform editor and has been a faithful servant for my Ubuntu Gnome environment. If you don't like installing additional libraries needed for KDE, then Tex Maker is the way to go. For installing Tex Maker I used Synaptic Package manager and it downloaded around 240MB of files. If you are planning on using Kile on Gnome, downloads will total more than 300MB. To be on the safe side I should mention that from few forums I came across I learned people preferred Kile UI s over Tex Maker. Still, I am quite happy with Tex Maker.

Configuring Tex Maker
If you are not using a bibliography for your document Tex Maker is ready to use. You can simply select the compiling method from the Tools bar and click on run. That will compile and build your latex document if there are no errors in syntax of your latex document. (latex tutorial)

If you want to use a bibtex then there are few more things to do.

First you have to find "Configure Texmaker" window. Here is where to find it. Go to Options > Configure Texmaker in the menu bar and select Quick Build

As shown in above image select User as the Quick Build Command and enter the following command. (This for creating a pdf file of your document)
pdflatex % | bibtex % | pdflatex % | pdflatex %

This is the exact command order that should be given, if you are using the terminal to build a PDF file of your LaTeX document. You will have to replace '%' with your document name ( Click here if you want know what these commands do)

NOTE: If you are setting above as your Quick Build Command, Tex Maker 2.0 will have problems when it comes to building documents with errors. The possible reason is Tex Maker waits indefinitely at each detected error. But if you are running above commands separately there will be no problems and it will show any errors detected in your document. (Or you can use F6 F11 F6 F6 function keys)


IMPORTANT: Bibliography style you specified must be already available in your TeX Live installation. Otherwise build will fail and prompt you with a message telling that it was unable to find a log file.

After specifying the bib style you have to tell LaTeX compiler the location of your bibliography(.bib) file. The path must not contain any space characters in it.
e.g.
\bibliographystyle{plain}
\bibliography{non/space/path/to/your/bib/file/nameofyourfile}
- file extension(.bib) is not included in the name.
This will be enough for you to get started with out any problems 

Adding a new bibliography style to TeX Live
First download the .bst (bibliography style) file you want. You can download the latest version of IEEE bibliography style file from here.
Next find the directory where default bibstyle.bst files are stored. (do a simple search for plain.bst file) Normally they are stored at,
/usr/share/texmf-texlive/bibtex/bst/base

Now copy your IEEEtran.bst file (IEEE bibliography style file) to above location. 
$ sudo cp /path/to/your/IEEEtran.bst /usr/share/texmf-texlive/bibtex/bst/base
After copying you have to update Tex Live. For that enter following command in terminal
$ sudo texhash
Now simply change your bibliography style to IEEEtran in your .tex file and do a Quick Build using Tex Maker.

Enabling Spell checker and Changing Language 
In the menu bar go to Options > Configure Texmaker and then select Editor. Change "Spelling Dictionary" path to a dictionary file pre-installed in your system, instead of the default file given by Texmaker
 
Linux stores its dictionary files at
/usr/share/myspell/dicts/
Select the desired .dic file from the directory and save.

Update:
If you can't find 'myspell' directory in above location then run following command. last 'en-gb' is for English - Great Britain. So choose the appropriate language code for you and replace 'en-gb' with it.
sudo apt-get install myspell-fr myspell-nl myspell-en-gb

------------
enjoy!