Thursday, February 11, 2010

Linux Newbie : Why I cannot use Latex like those gurus?

Latex is another brilliant Linux / Unix specialty hidden behind the geek facade.  Interesting introduction here {warning PDF file} talks in detail about why and how document processing improves with increase in document complexity. In the words of the author "It is very hard to write unstructured and disorganized documents". I like the approach but feel that this might attract power users but for newbies its more of the same old school of Linux is for geeks. The purpose is not to criticize the authors. He / she did a great job and deserves credit for this article as well. Now the primary question is how and where to start, following tutorials almost always leads to temporary use. Even students writing thesis in latex only a few would later use it for submitting assignments or other work. The problem is two fold one the students or users are not introduced to latex in a friendly manner rather they use it as if trying to live up to the 'lofty standards' setup by advisers or seniors. The second problem was highlighted when a highly motivated student submitted a journal paper in pdf format (developed via pdflatex) to the supervisor. The supervisor demanded an MS-Word Copy of the paper so as to edit. The student completely disgruntled vowed never to use Latex again.
Therefore a complete change of heart is required to accept Latex. Once this step has been done getting to grips with Latex becomes easier and fun.

Step one: Getting Latex
The following method is for Ubuntu. Please google/ contact service manual on how to install on other distributions or here for steps.

Ubuntu / Debian : $ apt-get install texlive

Step two: Starting up
Its never an easy job getting used to something as complex and with such rich history like tex. Using a gui-based tex would be a perfect way to not getting to use tex later. Since in that scenario it is incorrectly compared to microsoft and open office. Yes those programs are good to get work done but they are not anything like tex. Why? This would become clear soon.
Write the following text in a file using editor of your choice (freedom at last). 
\title{Welcome to Freedom}
This is a sample document which showcases the freedom and peace of mind offered by using {LATEX}
The following command creates an output file (pdf format) with same name as the name of the tex file.
$ pdflatex firstTry.tex

So here lies the first charm of latex that my readers dont need to buy expensive EDITING software just to read what i write.

How did latex decide about the placement of the title and date and fonts. The key to success lies in the fact that the document design and text has been separated. Hence now the user can concentrate on producing text rather than deciding about placement of text, font sizes and  other details that confound a user trying to use a word processor.  This fact can be readily appreciated by a simple change in the above code. Change \documentclass{article} to \documentclass{report} or \documentclass{book}. The resulting pdf file exhibits that the formating of the document can be changed at any stage and the user is least bothered how the document looks while typing the document. This is immense relief.

This bare-minimum tex file ONLY demonstrates the principle of separation of  formatting and content.

Step three: Adding more functionality
Now that fear of tags has subsided. The following tags add more formating information.

Incorporate the above tags in the file as below.

\title{Welcome to Freedom}
    This is a sample document which showcases the freedom and peace of mind offered by using \LaTeX
\section{Formating Sections}
The best part is that you dont have to set font sizes and then try to place the
section headings
\subsection{Sub Sections are cool}
Adding simple tag of subsection simply adds more sections and special part is there is no numbering involved. The numbering is dealt with automatically at the time of preparing pdf file.
\subsubsection{Moving further inside we can enjoy better functionality}
This shows how easy it is create subsections within subsections. Simply continue
 to add sub behind the tag and it goes deeper and deeper.
\section{Simplicity is still the essence}
So the current document if shown to a novice will scare away but we are begining to get the feel of Latex.
Rest would be mostly easier part
The following screen shot exhibits the usage of the above tags.
Adding \tableofcontents after \maketitle adds table of contents automatically.

Step four: Moving on to power usage
Moving on to power usage requires the approach according to the Chinese proverb.

Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime.
Instead of going into the details of each and every command/ tag. Its far better to use the "i will learn it when I need it" approach. This can only be achieved by keeping a tap on where to get the desired information. One method is to use  "The (Not So) Short Introduction to LATEX 2E" as a reference and simply copy and use any commands (examples) and tweak to requirement.

For Example , In order to add mathematical equations and use them effectively the best manner is to actually go and check out an example in the tutorial and study them. The following code fragment adds the equations given in the screen shot that follows.
\section{Explaining how to write Mathematical Equations}
One simple way to write mathematical equations is $A_x^2$ or using the tags begin equation and end equation
    \sum_{i=0}^{\infty} X_i=0
    \omega = \Omega
    \sigma = \Sigma

The code fragments shows in order to write subscript _ is used while to write as superscript ^ is used. Also another thing to notice is that \sigma outputs lower case Greek alphabet sigma while \Sigma outputs an upper case Greek alphabet sigma. 

Another method more in line with the Chinese proverb is the use of the template files provided by the publishers. E.g., IEEE conference style file (IEEEconf.sty) comes with a pdf which explains all the features and how to use IEEEconf.sty. Similarly University of California Los Angeles (UCLA) thesis style file comes with a readme file which explains how to use it.

This way by maintaining high level of confidence and keeping learning Latex while ACTUALLY using it to accomplish different tasks leads to better understanding and long term use.


Anonymous said...

Thank you for the re-introduction to Latex. I loved using it in grad school, but have not used it in years. I will reference the tutorial you suggested ("lshort.pdf") and use Latex when I can. It really does make great documents easily.

PeonDev said...

As a college student, I started using LaTeX as a friend recommended it.
Using it is like using a programming language; the learning curve is high at first.

But I do not regret learning it. Yes, at times I would frantically browse forums and tutorials, looking for how to do simple tasks.
Yet when the time came to produce a 250 page document, have an index, glossary, table of contents and table of figures, there was no equal.

I want to also mention I use the KDE LaTeX UI, KILE.

It's an IDE, or a fancy environment that makes coding the document easier for many tasks. (You still have to type out some code, but most of the formatting is a click away).

If a professor asked me to submit documents as Microsoft Word docs, I would politely refuse. I don't support non-standard document formats.

Waqas said...

Can I use LateX on Windows? If so, kindly can you write a tutorial on how to do it? I think that will benefit other people too. Many thanks.

Zahid Irfan said...

Dear Mr. Waqas, Thanks for chipping in. If one uses Latex in Windows that very much possible. The usage is similar to one described above all you need to do is install Latex in Windows. The following link could be one place to start off.

Rest of the tutorial follows the same procedure except that one has to write the commands in Command Prompt of Windows.

If that does not work let me know I can then help you further. Just remember one thing set the download settings to package download when needed otherwise you will be in for loads of downloads without any reason :).