Introduction to LaTeX on Linux

Introduction

LaTeX is the typesetting system and a markup language that allows for the creation of documents. LaTeX is heavily utilized by the academic and scientific community. LaTeX produces beautiful type and is written in a language that is fairly intuitive. This article will discuss a brief history, introductory usage examples, front-ends, and further readings.

About LaTeX

Latex on linuxFrom its website, LaTeX is a high-quality typesetting system; it includes features designed for the production of technical and scientific documentation. LaTeX is the de-facto standard for the communication and publication of scientific documents. LaTeX is available as free software. LaTeX was first released in 1985 by Leslie Lamport as an extension of TeX. Tex was developed by Donald E. Knuth. It was first released in 1978. LaTeX is used, as mentioned, earlier in academic environments for book publication and article publication. Not to go off-topic, but LaTeX is also used to create the formulas displayed on wikimedia applications such as Wikipedia! In addition to its ability to display formulas and beautifully created pages, LaTeX can do much more but that goes beyond the scope of this article. Look at LaTeX’s homepage for further documentation on LaTeX.

Installation

I will cover installation for LaTeX on Debian (& Ubuntu), Fedora, and ArchLinux.

To install LaTeX on Debian (& Ubuntu) run the following linux commands:

# apt-get update
# apt-get install texlive texlive-base

If you want the full LaTeX package run

# apt-get install texlive-full

The latter command should be unnecessary, for the purposes of this article. However if you run into any issues, go back and install the texlive-full package.

On Fedora:

# yum install texlive texlive-latex

On ArchLinux:

pacman -S texlive-most

While your at it (installing LaTeX) also grab “texworks”. A package exists for Debian and Fedora. On ArchLinux you will have to grab this package from the AUR. This will simplify some of the things I would like to go over. However, you can create .tex files in any text editors, programmers editors such as vim, geany, etc..



Usage

After installing LaTeX, your pretty much set. But lets cover the basics of the language first.

\ { } $ - _ % ^ # $

The characters above each have special meanings. For example backlashes usually indicate the beginning of a control sequence such as a formula or a specific symbol such as \alpha. Dollar signs indicate switching between normal text and text representing mathematical formals. Brackets are used to group characters together. Carat and underscore represent your standard super and sub scripts. The basics of the document structure depend on the sort of document you wish to create. For basic articles the \documentclass, \begin, and \end sequences should suffice. Writing some of this may seem repetitive but no worries, many front ends to LaTeX come preinstalled with many templates for different sorts of documents (I’ll cover this later).

So lets get down to some actual examples. To create the formula for time value of money, I would write the following in my text editor of choice. As shown below:

\documentclass[a4paper,12pt]{article}
\begin{document}
$PV = \frac{FV}{(1+\textit{i})^n}$
\end{document}

TeXworks

This is written in TeXworks. However, you could have used vim or any other text editor (ensure you save your document as a .tex). In TeXworks, I would now press the green play button. In Bash, I would issue the following:

pdflatex $text.tex 	      

Like in TeXworks, this would compile a pdf for me. TeXworks goes one step further by displaying a pdf. I could also get this functionality in Bash by doing something like:

pdflatex $text.tex && mupdf $text.tex	        


The resultant pdf would show the following:

TVM Money Example

Lets move onto a more complicated .tex file. I’ll write a quick page discussing valuation of FCFs and determining present value of capital with constant or variable growth

I started off my article by writing the following in TeXworks:

\documentclass[a4paper,12pt]{article}
\begin{document}
\pagestyle{headings}
\markright{Valuation}

Valuation of Money is a concept the refers to the future value of current capital. We can apply this concept to Free Cash Flows (FCFs). The formula for FCF Valuation is as follows: \[ \sum_{i=1}^\infty = \frac{FCF_i}{(1+WACC)^i} \] \\ where:\\ $FVF_c =$ is the sum of all future cash flows of a company $FVF_i =$ is the estimated fcf of a firm at year \textit{i} $WACC =$ is the weighted average cost of capital\\ This formula works for both constant and variable rates of growth. But the Gordon Model makes constant growth valuation a breeze! The Gordon Model for constant valuation is: \[ P_0 = \frac{D_1}{k-g} \] \\ where:\\ $P_0 =$ current price $g =$ expected growth $k=$ expected return \end{document}

If you have been following along in TeXworks, compile it now by pressing the play button or use the pdflatex command to generate the .pdf.

You should see the following:

Example document
In this .tex file I used \[ and \] to also indicate math text, similarly to $. Double backslash is used indicate line break like <br> in HTML. I also used the \sum sequence to display summation. Now I’ll cover some front ends to LaTeX



Front Ends

There are several front ends that exist with LaTeX. I’ll show you several and provide their respective URLS. I’ll also briefly cover one additional tool that utilizes LaTeX’s features.

For this article, I used TeXworks:

Texworks

From its website: The TeXworks project is an effort to build a simple TeX front-end program (working environment) that will be available for all today’s major desktop operating systems Its homepage is located here.

Another front-end which acts as a WYSIWYM (What You See is What You Make) is LyX. LyX is fairly beefy project that is cross platform and open source. It has a features page. Which in addition to outlining its features, contains a screen cast outlining all the features that it provides (most of those features are merely an interface to LaTeX’s more powerful features that may be new to the unfamiliar user). Check out this information at LyX’s homepage here. Below is a screen shot of LyX. As you can see below, LyX can render imported (as shown below) script or display the type created from within the program while maintaining the underlying code (WYSIWYM != WYSIWYG). Its a pretty feature complete application. projects.

LyX

A third GUI to LaTeX, is Kile. It has many of the features of LyX and TeXworks. Kile (shown below) is a QT interface to LaTeX’s features. All three (LyX, TeXworks, and Kile are Open Source, Cross Platform, and come with a galore of templates.



kile

One last program I thought I would mention is Zim. It isn’t a front end to LaTeX, however it allows for the usage of LaTeX as a plugin. As a note taking application for *Nix, I think this is an incredibly useful and powerful feature due to the power that comes with using LaTeX. Run the following linux commands to install Zim:

apt-get install zim #Under Debian or Ubuntu
yum install zim #In Fedora
pacman -S zim #In ArchLinux

After running it for the first time, Zim will prompt you to create a notebook. After doing so enable the “Insert Equation plugin” under Edit –> Preferences –> Plugins. Now in the menu press Insert –> Equation Voila. Now whenever you are jotting down notes you can also capture those complex equations that you could never type up before. Screen shot of Zim below:

zim

Conclusion

I think this article touched up on the basics. From here, I would recommend checking out the documentation from LaTeX’s homepage. They offer links to many tutorials, how-to’s, and document in several formats about LaTeX. Its a fairly extensive and powerful program. Once, you start learning the basics and have a need, you will realize the documentation exists you will find that learning new features are fairly easy. Documentation links from their page that discuss many more advanced topics such as displaying limits, functions, Greek letters, integrals, various misc. symbols, or how to apply this to a Wikipedia article and much much more. Quite frankly, I would have to write a book to cover all the functionality that is found in LaTeX. It is quite impressive to say the least. Try LaTeX today!



Comments and Discussions
Linux Forum