The PRACTICAL guide for Latex beginners (part 1)

It all started three months ago at the very first week of my Master when I saw my friend Serge who was about to write his report in Latex. I personally had experience with LaTex before when writing my paper but well, it was surely beautiful and fascinating yet somewhat still very complicated for me. ” It might be very time-consuming and inconvenient if I write all my reports in LaTex” said myself at that time.

Yes, it was!! It was very inconvenient, it was very time-consuming and it was actually sometimes tempting to just come back to write everything in MsWord.

But only AT FIRST! For my case, first three or four reports were quite annoying as I needed to google every time I wanted to insert a new symbol or just draw an image or even change the headline etc.  Fortunately I was patient and adventurous enough to stay with LaTex and now I never regret switching to LaTex.

However, what I noticed during those time is that there is not much PRACTICAL guides for those complete LaTex beginners even though there are some tutorials or even many books but from my experience, they are not very suitable and attractive for the new users. Thus, this blog (part 1 and part 2) aims to be an ‘instant noodle’ for those novices who want to jump into LaTex and use it right away rather than reading hundreds introductory pages with so much strange terminologies.

So, fasten your seat-belt and start the trip to Latex world!

What is LaTex?

 It is just another way of inputting text, image and other information to a document. Your traditional way may be MsWord-like way, where you type all the sentences while inserting special symbols or mathematical equations through a graphical user interface (GUI). Specifically, this way is  actually command-line user interface so when you switch from MsWord to LaTex, it feels similar to move to Linux after using Window where you are doing everything with comfortable yet limited GUI. How limited it is you wonder? Just remember how tedious and time-consuming writing your Physics lab’s reports during freshmen year were? Totally not productive and smart at all!!!!

What are the advantages of LaTex? (just say a few)

  • It looks much more beautiful and professional than MsWord documents. Just look at one’s CV written in LaTex and you will see why.
  • Convenient and time-saving to input mathematical equations and Greek letters.
  • Really easy to format your page.
  • If you insert an image and later the content of that image changes, LaTex will automatically change. No manual work needed here.
  • Significantly reduce the time and effort to produce a formal document.
  • Nearly 100% of scientific papers are written by LaTex, so I urge you engineering students, who are close to write your bachelor/Msc/Phd thesis or academic paper or just course work’s weekly report to get used to LaTex since it would be much easier for your life from now on.

Why is it difficult at first?

Remember how difficult it is the first time you have used MsWord? Everything is so hard at first because it is NEW and it takes time to get used to something. It can also be annoying as you need to figure out every basical things like how to insert a picture, how to draw a table , etc. But do not give up because LaTex is actually quite easy and powerful.

Hmm, but maybe I should say this at the front. Practice makes perfect. The only short-cut to fast forward this settling duration is to PRACTICE and PRACTICE more and more, with your own report and papers.

______________________________________________________________

It’s time. Enough words. Let’s start to play around with LaTex! You are advised to follow all the steps behind to see how it works.

Software

Actually, LaTex is not the name of a software to produce documents (like MsWord) but it is only a way so you need to install a software to run LaTex. For this, I would recommend TeXstudio for its balance between simple design and great functionality. You can download and install it from here:

http://texstudio.sourceforge.net/

Then just click on the file you have downloaded and follow the instruction. An other option (which is getting more and more popular) if you do not want to install anything is to use some online LaTex editors such as ShareLaTex or WriteLatex. It is up to your preference to choose the one that fits you.

Hello World program

Let’s try some writing in LaTex. Open your TexStudio program and create a new file (Ctrl+N) then copy and paste this paragraph:

\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}

\begin{document}
Hello World! I am a new Latex user!
\end{document}

Press F1 (which is the short-cut for building the document in TexStudio) and see the result. Congratulations! You have created your first LaTex document!!

Basic structure of a Latex document

As you can see from the piece of code  above, there is only a sentence in line 5 (highlighted) actually appearing in the built document. Other parts are only for declaration i.e letting LaTex know what kinds of setting you want. The first line says that you want a document of A4-sized paper with font size of 11pt and the style is like the pre-defined article style in LaTex. There are other built-in styles in LaTex such as book (for real book) or letter (for writing letters).

The next thing you need to do is to declare which package  you want to use in line 2.  Here I simply use package english since I want to write in English. For more complicated purpose you may need to include more packages (talk about it later).

Finally, the actual content of the document will be enclosed in \begin{document}  and \end{document}, so everything you write outside of this should be considered invalid.

Too easy? Let’s make something more advanced!

Ok, this time, copy and paste this piece of code and again, press F1 and see the miracle happens:

\documentclass[a4paper, 11pt]{article}
\usepackage[english]{babel}
\usepackage{fancyhdr}

\pagestyle{fancy}
\fancyhf{}
\lhead{Test LaTex document}
\chead{}
\rhead{\today}
\lfoot{}
\cfoot{\thepage\ }
\rfoot{}

\begin{document}
Hello World! I am a new Latex user!

\textbf{Exponential example:}
\begin{eqnarray}
e^{0} = 1 \\
e^{1} = e
\end{eqnarray}

\end{document}

Now do you see the difference compared to the Hello world example? Now we have the headline and footnote as well as various new features (equation, boldface…).  To do this, we need to add the new package fancyhdr, which is for making the headline and footnote then we actually use the page style fancy (line 4) then we just need to specify the actual text we want to put on the left headline (lhead), central headline (chead) or center footnote (cfoot) and so on. Note that we can put \today and LaTex will automatically know to put the date of today into the right headline and similarly \thepage means that the current page of the document. Told you, everything is ready in LaTex and you just need to call it.

In addition, we also try to make a sentence bold by using \textbf{} command. Also, for typing exponential notation, just use ^ then follow by the text you want to put on the superscript (enclosed by {}). You do not even need to number the equation by yourself.  It stays automatically and beautifully at the center. Super easy huh?

Enough for today maybe?

So up to now, we have tried pretty complicated LaTex documents (and it is not gonna be much more complicated than this) so that you can have a glance on what LaTex is and how it works. Part 2 of this blog will cover some vital components of a formal document (image, equations, page layout etc.) and I promise it is going to be very easy and practical so that you can start to use it on your next report immediately.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s