Вы находитесь на странице: 1из 3

How To

Creating Beautiful Documents

Using LaTeX If you care about creating polished and stylish documents, and if you have a
sense of aesthetics and like some finesse, try LaTeX!
Believe us, you’ll most likely fall in love with it and use it for the rest of your life!

L
aTeX is a document preparation There are major differences between the
system. It is used for high-quality word processing we are used to and what’s
typesetting and with it, you can available in LaTeX. Unlike the formatting
create beautiful, professional- we do with the content of the document in
looking documents. LaTeX is free WYSIWYG (what you see is what you get) word
and is distributed under the LPPL (Latex processors, creating documents in LaTeX is
Project Public License), which is slightly more like writing computer programs—we
different from the GPL. write LaTeX code and ‘compile’ it (yes, we
Who uses LaTeX? Well, LaTeX is used by compile the code!) and generate the document
small publishing companies and large software in the desired format. More technically, LaTeX
organisations; students and Nobel prize- is more like a ‘mark-up language’, just like XML
winning researchers; designers creating artistic or HTML. Unlike WYSIWYG word processors
posters, as well as authors writing journal where content is mixed with formatting, in
papers. In other words, it is used worldwide LaTeX, content of the document is separated
by people who care about writing ‘quality’ from formatting or the display mechanism (a
documents. rough analogy is using .css files for .html);

78 October 2008 | LINUX For You | www.openITis.com


How To

so, we can concentrate on the content of the document and


leave the specific formatting details to the software.
At first, I was totally surprised that we needed to write
code (like we do in programming) to create documents,
and LaTeX can be slightly intimidating in the beginning.
It is similar to the experience I had with the vi editor: I
was used to programming with interactive editing and at
first I was surprised that there were two different modes
that I had to work with. Once I got used to vi (or vim) for
programming, I didn’t like anything else, though it took
time to learn the commands and get used to it. Similarly, I
found it surprising that I should write code for LaTeX, but
then after using it for some time, I’ve got used to it and
now I only enjoy writing in it.
Figure 1: Default text rendering in MS Word

Why LaTeX?
The answer is simple: if you want to write documents Short History of LATEX
that just look great then the best option is to use LaTeX.
Sometime, you’ll be forced to learn LaTeX. If, for instance,
you’re doing your M. Tech or PhD and you want to write September 8, 2008
a paper or thesis, more likely than not, you’ll be forced to
create your document in LaTeX. For some niche domains like For those who keep wondering what TEX or LATEX is and why it was
mathematics, physics or chemistry where lots of symbols, developed, here is a short history.
Donald E Knuth, when he was working on his monumental book The Art
complex equations, tables and cross-references are involved, of Programming was not happy with the type-setting for his book. So he
created a type-setting system that would let him concentrate on the content
there is rarely any choice but to use LaTeX. Although mostly of the book rather than getting the type-setting software distracting and
used in academic circles and in commercial publishing, don’t getting him worried about formatting the output. For example, instead of
doing formatting for a quotation every time with center aligned and extra
underestimate the popularity and wide use of LaTeX—even border from the page, with different font, italicized, surrounded with double
novels and short stories are occasionally written using LaTeX! quote etc., he wanted just to say - this is a quote - and wanted the typesetting
system to take care of formatting it accordingly. He designed TEX to do that.
Those who don’t care much about writing good-looking However, TEX was still low level and difficult for beginners to use. So, Leslie
documents—I call them ‘impatient’ writers—and those not Lamport created a set of high level TEXmacros and made the common tasks
- such as creating table of contents - easier. Now-a-days, most of the people
from computer science or academic background, prefer using use LATEX instead TEX.
interactive word processors. Novices/beginners who don’t
want to write LaTeX code can use interactive document Figure 2: Default text rendering in document generated using LaTeX
processors that create LaTeX output such as LyX. But
remember: if you want to make the best out of LaTeX, writing with experience in using software like MS Word for large
code is the best way to go. documents such as a book will understand how frustrating
It’s best to show the difference visually. Just check out it is to work with a word-processor for a long time to get
Figures 1 and 2: the document is written in MS Word in the formatting, indexing, cross-referencing, etc, correct and
former, while the other is generated with LaTeX. Those consistent. LaTeX is very convenient to use in medium- to
who don’t know anything about typesetting can also find large-size documents that are complex. In my experience, for
minute differences between two documents: the spacing short documents such as memos or letters that we want to
between the words, how italics look, how the superscript and get done with quickly, it is not much use.
1
subscript symbols look, how the default settings look (these The next point is availability. LaTeX code is portable:
two documents were written with default settings on—and you can create a LaTeX document and use in any platform.
no, in MS Word, the bold face was not enabled for the text, It is available from AmigaOS, Mac OSX, Linux and Windows.
but it looks dark; so to differentiate the title, I’ve used bold This advantage is not available in many proprietary formats
there). To avoid bias, I’ve used the same fonts—for MS Word, such as the .doc format. Lots of free and open source
I used the default Times New Roman font; for LaTeX I’ve software is available. Since it is used widely, supporting tools,
used the pslatex package that replaces the default computer documentation and help is available.
modern fonts with PostScript fonts. Next in line is the choice of output formats. LaTeX is
also useful for creating a wide range of document output
LaTeX advantages formats. It is enough to write a LaTeX document (a text
The first and foremost is the quality of output. In my file) and, with that, we can create the document in almost
experience, LaTeX produces the best quality output and I any format that we usually use, including .ps, .doc, .html
would recommend you experience it yourself. and .pdf formats. So we can just keep the text file and
Avoid frustrations in creating large documents. Anyone generate the desired output format in the given platform,

www.openITis.com | LINUX For You | October 2008 79


How To

$ dvips hello
$ gv hello.ps
Hello world!
$ ps2pdf hello.ps

And now you can use a PDF viewer (such as Evince or


KPDF) and view the PDF file.
If you feel it’s a lot of work, you can use any of the LaTeX
editors that let you do this work automatically for you.
Figure 3: LaTeX output file
LaTeX in Linux
as and when required. There is a lot of free/open source software available for
This is very helpful when the content is of moderate or LaTeX. Many of the Linux distributions have LaTeX software
large size and we need different output formats. For example, readily available with their installations. We’ll cover some of
a publishing house might get articles from its contributors the important and more widely used software here.
in .doc format; typically, they convert it into LaTeX format! LyX: It is an interactive document processor that is
With this, they can enforce the common style they use for similar to conventional word processors; so novice LaTeX
the magazine for every article, with ease. They can create users will find it comfortable using this. You can download
.html files automatically for posting select articles in their LyX and learn more about it from www.lyx.org.
websites. They can provide the digital version of the article teTex: teTex is a free TeX distribution system that is
as .pdf versions online for select subscribers. They can create widely used in UNIX/Linux platforms. However, it is not
.ps (PostScript) files that are print-ready before printing the actively maintained any more. See www.tug.org/tetex
content. All this can be done with LaTeX documents when Kile: Kile is an integrated LaTeX environment; it is a
we have the necessary software supporting these features. friendly text editor that works on KDE. Kile has many useful
features: we can use readily available document templates
LaTeX ‘Hello world’ code and wizards, compile, convert, and view the documents
Let’s explore coding with LaTeX with hello world code. at one go, use the auto-completion feature to avoid typing
LaTeX commands, get more information on commands using
\documentclass[12pt]{article} context-sensitive help and so on. You can get it from kile.
\begin{document} sourceforge.net/download.php
\centering{ \textbf{Hello world!}} Texmaker: Texmaker is a free and open source
\end{document} LaTeX editor available for Linux (it is also available for
other platforms such as Windows and MacOS). See www.
In LaTeX, all the commands start with ‘\’. The required xm1math.net/texmaker/index.html 
arguments for the commands are provided within curly
braces ({}) and optional arguments are in square braces ([]). References:
The \documentclass command is to tell the type of the
document, for example, an article, book or letter; here we • At the project website for LaTeX, you can download
have selected the article type. We can also mention the size software for LaTeX, read documentation and learn
of the font for the document; 12pt is what we’ve selected more about it: www.latex-project.org
here. We can put all our code for the document within • Homepage for the organisation of TeX users known as
\begin{document} and \end{document}. TUG (TeX User Group): www.tug.org
In the body of the document, we have introduced • The Comprehensive TeX Archive Network (CTAN), where
\centering environment—the content provided within this we can get LaTeX packages, LaTeX software downloads
environment will be page-centred. The \textbf command and much more. When you have specific needs while
makes the text inside it bold face. That’s it; so how do we run using LaTeX and need a package to solve a particular
it and see the output? problem, this is the first place to look: tug.ctan.org
Save it as, hello.tex, for instance, and assuming that you • A free book on LaTeX written with beginners in mind;
already have latex pre-installed in your Linux machine, type provides a good introduction and overview of the
the following commands: features of LaTeX: www.maths.tcd.ie/%7Edwilkins/
LaTeXPrimer
$ latex hello
1 By: S.G. Ganesh is a research engineer in Siemens
This generates the .dvi file that you can view; Figure 3 (Corporate Technology). His latest book, “60 Tips on Object
shows the output. If you want to convert it to a PDF file, type Oriented Programming”, was published by Tata McGraw-
Hill in December last year. You can reach him at sgganesh@
the following three commands:
gmail.com

80 October 2008 | LINUX For You | www.openITis.com

Вам также может понравиться