Using LaTeX: The Basics [part I]

[ Saturday, 17 November 2007, TLu ]

This is the first of a series of articles about using Tex system. A good place to begin would be by asking the question “Why is it worth using TeX?” We’ll also take a closer look at the various tools available to us, which makes working with TeX much easier. In the next articles we will focus on Master Thesis writing, Presentations and Correspondence.

Dragonia Magazine

Author: Tomasz Łuczak

What are TeX and LaTeX?

We had our first experience with TeX in the 10th edition of the Dragonia Magazine in an article about LyX. It was about an easy way to create text, with LaTeX in the background (creating really nice PDF file). Now the time has come to explain what this mysterious LaTeX really is.

TeX was invented to design really nice-looking books, including mathematical formulae. TeX is electronic typesetter, it “knows” how to typeset paragraphs, verses and columns, as well as how to use italics etc.

Between the author and the typesetter is a book designer. The designer writes his instructions into the manuscript and then gives it to a typesetter, who typesets the book according to these instructions. You may say that LaTeX takes the role of the book designer here. This allows the author to concentrate on the most important task, which is writing the text! To prevent the book designer from free interpretation of the author’s work the latter should write all the instructions and pertinent information in the text, especially concerning the logical structure of his work. This means marking the sections, subsections, enumerations and emphasised parts of the work within the text. It’s the graphic artist and the book designer who are responsible for the works’ look, but the rest is the work of the typesetter.

Since we have OpenOffice, why do we need LaTeX?

Nearly all text editors were created with the aim to electronically imitate the typewriter. That’s why they’re often called typewriters, and one may say that nothing revolutionary has happened here since the advent of original typewriters. TeX was created with the primary assumption of being an electronic version of hand-crafted typesetting.

LaTeX is an editor who ”knows” what type of job should be done by the typesetter (depending on a document class used). Standard classes are based on instructions formulated by publishers and the national canons developed by the masters of typographical design.

There is no chance of finding this kind of functionality in popular text editors, even those which are considered top rated. All we can count on are styles. All typographical and design issues rest upon us. As for authors, they are usually well versed in the subject of their writings, but are not generally typographical experts. One may say that’s a good situation since authors should concentrate on their writing, and leave the other issues, which are minor from their point of view, to the professionals. The problem is that these super editors do not have this kind of electronic specialist readily available. Consequently, we arrive at the point that our poor author should know typography, even when he has had no prior knowledge of it. To see why, it is worth comparing text written in a text editor with that written in a book which was typeset in the pre-computer era - the difference, and ease of reading the latter, is easily discernable.

That is the reason for the continued existence of TeX and LaTeX, to prepare easily readable text with very little author effort. An author is needed to write the text but not for the typographical design of his text.

How to start?

We need two elements here: good text editor and the TeX system.

Good distributions contain TeX packages, others will require a separate TeX installation. Unfortunately it is common to find that even if a distribution contains the TeX packages, it is sometimes not the full TeX version. Whilst it is possible to start with a short version of TeX, from a comfort point of view, it is well worth the effort required in installing the full version.

As for text editors, we can choose from the wide range available, from the simple versions to really sophisticated multi-tools. To assure ourselves of fast and easy work, we should pay special attention to a few important details when making the choice of an editor. Attention to these details will prevent the situation arising where it would take more time to learn the use of the editor than to actually write the text. One functionality especially useful when working with TeX documents is syntax highlighting, so we should pay special attention to this issue when choosing an editor. Other functionalities, like the possibility to pick commands from a combo list, visible hints displayed by the editor, or the possibility to run compilation from the editor level are especially useful for beginners. Some minor settings, like matching brackets, and closing environments automatically are also a good thing to have. It’s a matter of taste if an editor should be fancy or just functional. When we consider the fancy ones we have Kile, LEd, and Eclipse (with the special LaTeX plugin). As for the editors of the second category we should mention Emacs with AucTeX package and gVim with LaTeX suite. Both might be use as well in graphical or text mode.

To try examples presented in this article even Notepad will do (the only most important consideration here is that
the editor saves text without inserting additional formatting marks).

And here we go!

Before we begin we should mention a few words about document structure. Each work compiled with TeX consists of two
parts: the preamble and the main text

Preamble is the part of our document where we declare the document class, and choose additional packages to be used, define customised commands, change already existing commands and values of default parameters. The preamble starts at the beginning of a file and ends with \begin{document} (which is the point where the main text begins). Text is ended by \end{document}.

Basics

To let LaTeX “know” how to format the text we have to use some commands in this text. All those commands start with “\” sign and are case sensitive. If a command requires some parameters, they are introduced by using brackets “{}“. Optional parameters are introduced using square brackets “[]“. To comment a line we use “%“. An empty line separates paragraphs. And that’s all if it comes for the basic rules.

Preamble

At the beginning we have to pick a class of our document (e.g. letter, book, presentation or other). When a given class has options available, we can use them to change the class default settings, e.g. typeset headings using sans-sheriff font or change the default font size to 12 pt.

Depending on TeX distribution we have different number of available classes, but always article, book, report and letter classes are included.

% we pick the article class with default font size 10pt
% and paper size A4
\\documentclass[a4paper,10pt]{article}

The main text

When we have our preamble ready it’s time for the main text. When writing the main text we can make use of comments. This is really useful when working with long texts. Using comments helps finding a given fragments in the text. For example we may use the following comment:

% Check this out!

To make writing more easy, classes include commands enabling setting the logical structure of the text, i.e. chapters, sections, subsections etc. and include them in the table of contents.

We have similar situation with itemisation. Contrary to the headings case, itemisation needs a set of commands called an environment. The environment begins with the command \begin{itemize} and ends with \end{itemize}. Each item should be introduced using \item command. Itemisations might be nested.

If we need the table of contents we use \tableofcontents command in the place where we want TeX to generate it.

\\begin{document} % And here we go!

\\author{Name and Surname}   % author
\\title{My first text in LaTeX}  % document title
\\date{Somewhere today}     % place and date
\\maketitle{}     % this is the place where the title is generated
\\begin{abstract}
  Here we place an abstract
\\end{abstract}

\\tableofcontents % when we compile this file for the second time
                 % table of contents will be generated in this place

\\section{Section}
We have our first section and a long paragraph!
We have our first section and a long paragraph!
We have our first section and a long paragraph!

And here we have the second paragraph %and the comment
in this section. We can use a lot of spaces   between
  words.

\\subsection{Subsection}
Oh! We have subsections!

\\section{Enumerate and itemise}
\\subsection{Itemise}

\\begin{itemize}
\\item first,
\\item second,
\\item third.
\\end{itemize}

\\subsection{Enumerate}

\\begin{enumerate}
\\item first,
\\item second,
\\item third.
\\end{enumerate}

\\subsection{One in another}
\\begin{itemize}
\\item 1st,
\\item 2nd,
\\item 3rd:
 \\begin{enumerate}
 \\item 3rd first one,
 \\item 3rd second one,
 \\end{enumerate}
\\item 4th.
\\end{itemize}

\\end{document}

Here we have our first document. Now it is time to save it to a file, eg. file.tex. We should remember that filenames and directories’ names (where our file is located) should not include any spaces or special characters (like diacritics signs).

The compilation is performed using the correct commands in the editor, or by using the command line:

pdflatex file

(this command should be given from within the directory where the file is located). Next we can view the compiled document using our favoured PDF viewer.

We should now take notice of any issues that we might have missed while writing, such as: the table of contents, the look of the title and headings, margin size, etc. After we’ve picked the class of the document our designer gives the typesetter the task of setting the text according to the rules described in the chosen class.

Let us now change the settings of parameters in the chosen class — font size from 10pt to 12pt — and compare results. It’s easy to notice that all the headings are typed with the larger font. The same is for the table of contents (but still the font is smaller than in the main text).

Summary

This is only the beginning. In the next part we’ll try to cope with larger publications.

This text is based on the article published in Dragonia Magazine, a Polish online magazine about Free and Open-Source Software. You can download the latest Dragonia issue (first one in English from our mirror). The article has been slightly modified compared with the original version by the PolishLinux team.

Translated by p_lupkowski, Proof-read by Darryl Moody

Subscribe to RSS feed for this article!

9 Comments

fold this thread IMQ  Sunday, 18 November 2007 o godz. 6:03 pm #  Add karma Subtract karma  +5

I have seen TeX and LaTeX mentioned in various places on the web about how it is the best tool for creating great documents for presentation, thesis, etc. Better than most, if not all, typical word processor found in Office suite (Microsoft Office, Corel WordPerfect, OpenOffice.org, etc.) normally found on a desktop PC.

Obviously, I have never used TeX or LaTeX so I would be interested in following this series. Maybe I acquire a new skill along the way.

Keep this going!

:)

 
fold this thread bob  Monday, 19 November 2007 o godz. 7:47 am #  Add karma Subtract karma  +2

I always get a little happy when I see an article on LaTeX. When I was doing my graduate work I found that if I took the little extra time (I’ve used LaTeX a lot in my past, so anytime I chose to use it, it doesn’t add a lot to my work time), almost everytime my papers would come back as an A. They just looked so damn good.

If someone else starts to use it, good.

 
fold this thread Zaine Ridling  Tuesday, 20 November 2007 o godz. 8:59 am #  Add karma Subtract karma  +0

Fantastic article, and info I need to know. I tried to get LaTeX working on Linux recently but persistently stumbled. I create and keep all my important files and content in text form anyway, since it carries across clients, platforms, and time itself.

 
fold this thread Patricio F. Ortiz  Tuesday, 20 November 2007 o godz. 1:24 pm #  Add karma Subtract karma  +0

It’s great to see articles mentioning TeX and LaTeX. I’ve used it for years and typing math’s formulae is another of TeX’s strong points. What I would like to mention is that there is a lot of support for TeX/LaTeX in the web, the so called TUG (TeX Users Group) are really great source of information. TeX/LaTeX is really strong in academia and in the groups in Germany are particularly active. Another point worth mentioning is that TeX is actually a computer language, designed by one of the big names in modern computer applications: Donald Knuth. LaTeX is one of its many “wrappers”.

A good number of the modern books you see in press have been typeset using TeX/LaTeX. After so many years, TeX is truly cross platform: Linux, PC, Mac, etc. and no matter in which system you work, the result is device independent.

 
fold this thread Ubersoldat  Tuesday, 20 November 2007 o godz. 4:59 pm #  Add karma Subtract karma  +1

Cool article, I just hope that also you can point out how versatile is to work with TeX and vim. I made plenty of essays while on college using LaTeX and now my resume and some presentations, but in todays world I feel ashamed that the standard are doc files and that most people don’t know what TeX or LaTeX are.

I’ll wait for your other posts and see if you can bring anything new.

 
fold this thread Guillermo Garron from Go2Linux  Tuesday, 20 November 2007 o godz. 9:53 pm #  Add karma Subtract karma  +0

Hi, I have been investigating about Tex and Latex a week ago, to write an article about it, at http://go2linux.org (some friend from stumbleUpon asked me for it), nice article BTW, will help me on my job.

 
fold this thread dvk  Wednesday, 21 November 2007 o godz. 5:20 am #  Add karma Subtract karma  +0

Texmaker and Kile are nice frontends for latex on linux.

 
fold this thread reader  Sunday, 25 November 2007 o godz. 4:52 am #  Add karma Subtract karma  +1

I think the article is nice. It uncovers some aspects of LaTeX. For those beginners that do not want to bother too much about the syntax, or they want to learn it later, I suggest to use Lyx http://www.lyx.org/

 
fold this thread Dmitriy Kropivnitskiy  Tuesday, 27 November 2007 o godz. 8:44 pm #  Add karma Subtract karma  +0

Thank you for the article. Albeit this is a fairly good beginner’s primer to Latex, there are several documents out there (including official latex documentation) that explain basic document structure and syntax. I wonder if you are planning to write a more advanced article about other document classes (letter for example), libraries, fonts and ways to find out more information about available features on your own.

 
Name (required)
E-mail (required - never shown publicly)
URI

Adjust field size: shrink | enlarge)

You can use simple HTML in your comments. Some examples are as follows:
  • A hyperlink: <a href="polishlinux.org">GNU/Linux for everyone!</a>,
  • Strong text: <strong>Strong text</strong>,
  • Italic text: <em>italic text</em>,
  • Strike: <strike>strike</strike>,
  • Code: <code>printf("hello world");</code>,
  • Block quote: <blockquote>Block quote</blockquote>

About the Author

Tomasz Łuczak

TeaM-TL developer, Dragonia Magazine's editor, TeX and Tcl/Tk enthusiast. Lives in Katowice, Poland.

Sponsors

RSS: Comments

You can follow the comments to this article through a special channel RSS 2.0 .

Related articles: Tex

 more »

PolishLinux Top Content

Select distros:

vs

Shopping Ads

Google Ads