[Courses] [LaTeX] Course 1 - Introduction

Isabelle Hurbain isabelle.hurbain at free.fr
Wed Jul 17 23:44:52 EST 2002


Hello everyone,

I suggested three days ago on the IRC channel to run LaTeX courses, and as 
I had positive feedback about it, here is the first course ;)
This is text only ; you can have the PDF/TeX/DVI version on my website : 
<http://www.isabelle-hurbain.com/repository/latex/courses/>.
I hope you'll enjoy it ! Please do not hesitate to contact me for any 
question - or mistake (I've tried to make this as error proof as I could, 
but English is not my mother tongue...)

Isa - Balise



LaTeX course 1 : Introduction

Contents

1. But what is LaTeX anyway ?
2. What do I need to make LaTeX ?
3. LaTeX Hello World



1. But what is LaTeX anyway ?

LaTeX is a document preparation system. It allows you to create 
professional-looking documents without pain. The main idea of LaTeX is that 
the author of the document concentrates on the content and not the form of 
the document. To achieve this, LaTeX provides a set of macros and 
predefined styles.

Let's take a basic example. On a "standard" word-processing tool, to make a 
section title, most people use form-modifying commands. For example, they 
put it in Bold, Underlined, Size 16. With LaTeX, the form of your document 
is independant of its content : your section title will be in a \section 
command and you let LaTeX manage how it will be printed and diplayed.

You may ask : "What's the big point ?" Well, there are indeed at least 
three big points. The first is obviously that you don't have to remember 
what "style" you used for your previous sections, subsections, chapters and 
so on. The second is that when you decide that your section title font is 
too big, you don't have to change it in the whole document, you can do it 
with a single modification. The third is that, as the document is marked 
with sections, subsections and so on, it is much easier to do tables of 
contents - in fact, it can be done automagically.

The last point I'd like to underline is that LaTeX is really fantastic to 
typeset mathematical formulaes. You will soon see that once used, you 
cannot do without LaTeX for scientific publishing ;-)

I hope that this very short introduction has given you the envy to 
continue, so let's go !

2. What do I need to make LaTeX ?

LaTeX is not, like most word-processors, WYSIWYG (What You See Is What You 
Get) (or, more frequently, WYSIMOLWYG, What You See Is More Or Less What 
You Get). You first write your LaTeX source code, then you compile it into 
a .dvi file, which you can transform in .ps or .pdf. There are also means 
to convert into HTML for example.

So what you need are basically :
	- a text editor - Emacs, Vi, TextPad, UltraEdit or whatever you like
	- a LaTeX distribution. You can find teTeX under Linux Debian, and there 
is a TeX/LaTeX distribution bundled with almost all Linux distribution. 
Under Windows, if you use Cygwin there is also a teTeX ; you can also find 
MiKTeX and TeX Live (I'm sorry for Mac users, I don't use Mac so you'll 
have to find a Mac distro yourself :P )
	- a .ps or a .pdf viewer (or both). There are numerous - the most famous 
are gv / Ghostview for .ps and Adobe Acrobat Reader for .pdf.
\end{itemize}

All these things can be installed very easily - just do it the way you 
install any other program.

Once all is installed, let's write our first LaTeX document.

3. LaTeX Hello World
3.1 The document

We will look at a very simple document :

\documentclass[a4paper, 11pt]{article}
\title{My first \LaTeX{} Document}
\author{Isabelle HURBAIN}
\begin{document}
\maketitle
Hello, world !
\end{document}


You can copy and past it into, for example, a new text file named 
"helloworld.tex".

3.2 Compilation
Save it, and compile it. To compile the file, just cd to the directory you 
saved it into and type

latex helloworld.tex

in a console tool (or a command in Windows).

You should see some lines displaying, and three new files are created.

	- The .dvi file is the output of the compilation - what you can view and print
	- The .aux file is an auxilliary file, which contains things like section 
numbers and figures numbers, so that it is possible to create a table of 
contents or a table of figures
	- The .log file is the file that logs all LaTeX information - LaTeX 
compilation messages and errors.

3.3 Visualization
Your LaTeX distribution probably provides a way to visualize .dvi files - 
in teTeX there is xdvi, in MiKTeX there is YAP...

If you find a .dvi viewer, you can directly view the helloworld.dvi file. 
If not, you can use

dvips helloworld.dvi

to get a ps file, or

dvipdfm helloworld.dvi

to get a pdf file. (dvipdfm can be slightly different, you may also find 
dvipdf or others).

Nice isn't it ?

3.4 Explanations
Let's look a bit more at the code. As you can see, all the commands begin 
with a \ ; \ is a special character in LaTeX that can be typed with 
$\backslash$. The other special characters ({, }, $, %, # and _) can be 
obtained with \{, \}, \$, \%, \# and \_. A \\ breaks the line (but you 
should not use this much as we'll see later).

The first line,

\documentclass[a4paper, 11pt]{article}

is very important. It tells LaTeX several things. \documentclass{article} 
tells it to follow an article layout. There are other layouts, such as 
report, book, letter... which we will discover in this course.  The a4paper 
and 11pt in the square brackets are general parameters of the document. I 
will talk about it a bit further in these courses. It tells LaTeX that the 
result will be printed onto A4 paper, with a text character size of 11 
points. Of course, if you use letter paper, feel free to replace a4paper 
with letterpaper.

\title{My first \LaTeX{} Document}

defines the title of the document, with a lovely LaTeX symbol.

\author{Isabelle HURBAIN}

defines the author of the document.

\begin{document}

is the signal for LaTeX that the real document begins. The lines before 
this line are called the preamble of the document.


\maketitle

is a command to create a title from the information in the preamble 
(typically \title and \author, eventually \date).

After that, you can compose the document (here just ``Hello, world !''), 
and finish it by

\end{document}.

It is true that it seems a bit complicated for just that. However, look how 
simple it was to create the title...

4. In the next course
In the next course, we will learn how to create a real-world document, with 
titles and sections, and I will explain more deeply the form-content 
dissociation advantages.




More information about the Courses mailing list