I define myself as a lover. I write all my documents using
.
In this post I’d like to review some features about writing and compilation. Since I’m a Linux user, and don’t have any idea on how does windows work, I’ll restrict myself to Linux OS… particularly Debian based ones, such as, Ubuntu, Mint, and so on.
Installing the Compiler
The easiest way of installing the compiler in Debian based Linux, is through the Terminal, (you should have sudoes power)
$ sudo apt-get install texlive
or if you prefer to install all the possible packages,
$ sudo apt-get install texlive-full
NOTE: the full installation needs about 1GB of free pace in your HD, which is not too much by this days, however, downloading the installation packages could long couple of hours with ease.
Choose an Editor
One cannot write a file in a Word Processor as OpenOffice or LibreOffice. Nonetheless, there are different processors which are useful for this end,
- Gedit: included in most Linux distributions
- Emacs: a very powerful processor
- Texmaker: specially designed for LaTeX, in GNOME environment
- Kile: specially designed for LaTeX, in KDE environment
and many others,
- Texila
- Texshop
- Texmacs
- et cetera
You could install one or all of them, again using the CLI, for example,
$ sudo apt-get install texmaker emacs gedit-latex-plugin
First LaTeX Document
From now on, I’d restrict to Emacs editor (which is my favourite), the terminal for compiling the document, and evince as viewer.
NOTE: In case you choose to try emacs yourself, I recommend to check some old post of mine, about an emacs error, about environments, or emacs and LaTeX.
Three first lines
All document has the three very first lines which define it.
\documentclass{report}
\begin{document}
\end{document}
The first one define the type of document one’d like to write, some classes are
- report: a book-like document, probably less complex
- book: specially for writing books
- article: for scientific articles
- letter: for writing letters
- beamer: for presentations (see for example this post)
- currvita: for writing curricula vitae
- and many more…
All that is written between the begin and end document is called the body of the document, in there all chapters, sections and so on is included.
A special part of the document is the area between the documentclass and the begin document. This is called preamble, and there all the special request about our document are specified.
Giving some Format
In order to start giving structure to our document, we need to know the kind of structures defined in ,
- part: for book and report classes
- chapter: for book and report classes
- section: for book, report and article classes
- subsection: as above
- subsubsection: as above
- paragraph: as above
- subparagraph: as above
by now, we restrict ourself to these three classes, because the other are quite different.
Each structure is understand as a command, thus it must be presided by the backslash and include into the body of the document,
\documentclass{report}
\begin{document}
\chapter{Introduction}
\end{document}
As you might notice, the name of the chapter is enclosed by curly brackets.
NOTE 1: From part to subsubsection, structures are numbered by default. If you’d like to avoid the number, use an asterisk as shown below,
\documentclass{report}
\begin{document}
\chapter*{Introduction}
\end{document}
NOTE 2: A huge difference between a chapter (which I’m calling structure) and environment (such as document), is that the former ends when a new structure is given, while the later has a beginning and an end.
Some Environments
There are lots of different environments that might be used while writing a document, such as,
- equation: for writing a single numbered equation. Use equation* for unnumbered ones.
- eqnarray: for writing multiple numbered aligned equations. Use \nonumber for avoid a numbered line, \\ split the line, and && for telling where to align(the sign could be surrounding a sign).
- quote: for quotations.
- itemize: for unnumbered list.
- enumerate: for numbered list.
- figure: for adding numbered and possibly captioned figures.
- table: for adding numbered and possibly captioned tables.
- tabular: for constructing tables.
- minipage: allows to construct a mini-paga on the document, like a post it!
- and a long standing list which cannot be possible cover in a post!
Compiling the Document
Since is a programming language, one necessarily has to compile the document to get a PDF or PS (human) readable file.
The very fist step is to save the plain text file, the extension must be .tex, as it’s customary, I’ll call our foo.tex. Since compilation usually generates a lot of trash files, the best place to saave the plain text is in a folder dedicated for latex files.
In Emacs the keys
Ctrl-x Ctrl-s
abbreviated by C-x C-s, saves the file… or buffer in Emacs jargon. The first time you save the file, a name must be given, ex., ~/Latex/foo.tex.
NOTE: I assume that a folder Latex was created in your home folder (~).
Once saved, go to the terminal and change the promt to the Latex folder,
$ cd ~/Latex
and compile the file with pdflatex command
$ pdflatex foo.tex
Finally open the document, with evince,
$ evince foo.pdf &
Yeah babe!!!! That’s right… your first document written in .
Writing Equations
I’m a physicist, so I’m used to write lots of equations. I’ll explain some examples,
\begin{equation}
\vec{F} = m \vec{a}
\end{equation}
results in
or the famous Einstein’s relation,
\begin{equation}
E = m c^2
\end{equation}
results in
More complicated examples,
\begin{equation}
\frac{\partial^2 }{\partial t^2}x(t) + \omega^2 x(t) = 0\;\Rightarrow\; x(t) = A\sin(\omega t)+ B\cos(\omega t)
\end{equation}
results in
With this example we opened the gate of Greek alphabet in mathematical mode, and Calculus notation… nevertheless, there exist endless possibilities. I encourage you to check symbols-a4.
The best of the compiled text, is that numbers (of section, chapter, equations, tables, or figures) are assigned by the compiler… therefore, you don’t need to remember those damn numbers. So, How do I refer to an equation?
First, give a name to the equation, with the label command
\begin{equation}
E = m c^2 \label{emc2}
\end{equation}
and then, call it with the ref command,
As we saw before, the mass relation (\ref{emc2}), bla bla bla...
After the compilation the precise number appears.
NOTE: The same principle work for any other structure of the document or numbered environment.
And the Title Page?
As you have notice, there’s a huge difference between WYSIWYG editors (Office-like) and WYWIWYG ones (which must be compiled). The maketitle command orders to the compiler to create a title page. The data should be included in the preamble, whilst the command form part of the document body,
\documentclass{report}
\title{My first document in \LaTeX{}}
\author{Dox Drum}
\date{\today}
\begin{document}
\maketitle
\chapter*{Introduction}
The harmonic oscillator is driven by the differential equation,
\begin{equation}
\frac{\partial^2 }{\partial t^2}x(t) + \omega^2 x(t) = 0\;\Rightarrow\; x(t) = A\sin(\omega t)+ B\cos(\omega t).
\end{equation}
\end{document}
Listing
As we saw above, list are made with the commands itemize or enumerate, whether you want it to be numbered or not.
Ex.:
\begin{itemize}
\item This got no number
\item Neither does it!
\begin{enumerate}
\item This is number one
\item number two
\end{enumerate}
\item Another with no number
\end{itemize}
which is a numbered list inside a unnumbered one.
Download the PDF document!
[...] Comments « Document edition with LaTeX [...]
Interesting introductive post about LaTeX (I am a lover, too)
I want to point out a little thing… You say that TeXMaker is oriented to Gnome users, and it can be a little misleading…
I use TeXMaker to do my daily LaTeX-ing, and it uses the Qt widget library (which is what KDE is based on), as Kile does.
The thing that makes TeXMaker (which competes with Kile in completeness) suitable for non-KDE users is that it depends only from Qt, and not from KDE libraries.
I think that pure-Gnome users can take a look at LaTeXila, which seems very promising.
Bye!
I’m using LaTeXila on my gnome environment, and it’s becoming really good. The only feature that’s missing for me is the search and reverse search (go to a certain point in your PDF, defined by your position in the LaTeX document, or the other way around).
It has spell checking, document summaries, GUI editing modes for certain tasks …
Inverse search is possible with Emacs and Evince, see: http://old.nabble.com/Inverse-Search-with-Evince—DBUS-td30794685.html