Hello, welcome to the LaTeX lecture.
This is a quick introduction in the
LaTeX document typesetting system
which many of you will be using
for either typesetting your Part II
dissertation or your master thesis
or your PhD thesis. It's generally the
most widely used document preparation
system in computer science and
many other mathematical sciences.
So what is LaTeX?
It's a macro package for another
software system known as TeX.
TeX is pronounced as I've shown here.
It's not tex because it's
really meant to be uppercase
Greek letters Tau,
Epsilon, Chi ... tech.
And it's a system that a well known
American computer science professor,
Donald Knuth from Stanford University,
started developing in the mid 1970s
when he got a little bit fed up
with the many mistakes that the
typesetters had added to his book
series The Art of Computer Programming.
So he decided to sit down for maybe a year
or two to write some nice typesetting system,
so computer science authors could
typeset their own books.
And as these things go,
it then took nearly a decade to complete it,
and this has become the most
widely used typesetting system in
mathematics and physics and computing,
in many engineering disciplines,
mostly because it has excellent facilities
for typesetting mathematical notation.
A lot of attention to detail has gone
into designing the fonts carefully
to work well with mathematics,
and lots of little algorithms to arrange
symbols automatically in a pleasing way,
while providing a comparatively simple and
efficient language for typing in formulas.
So TeX was originally written in the
Stanford Artificial Intelligence Language,
later reimplemented by Knuth in Pascal,
and was then later semi-automatically
ported to the C programming language,
and is now commonly maintained
in what's known as the TeX Live
open-source distribution,
and as such you can find it as part of many
operating-system distributions,
Linux distributions,
for example,
but it's also widely available for Windows,
Mac, and pretty much
any commonly used computer
platform for typesetting purposes.
It's not a WYSIWYG tool in the sense that
TeX itself does not have a interactive
mode of using it. TeX is
working more like a compiler.
You provide a plain-text input file
and then it gets compiled into a
file that can be sent to a printer.
The traditional
processing pipeline with TeX is
that you write a name.tex file,
send it through the command-line tool latex.
Then this produced originally
something called a DVI file,
a device independent page description
file. And then there was a wide range of
printer drivers available that could
print pages onto various printers based
on the instructions in these device
independent files.
But then the Adobe company
standardized other printer
control languages: Postscript, PDF.
So for a while it was customary to
translate DVI into Postscript files
with dvips, and this tool also had an
ability to include figures, usually
provided in embedded postscript,
that led to a postscript file which
many printers understand directly.
But which was a bit inconvenient for
viewing in web browsers or for sending
to other people. For that another
format was defined, called PDF.
The Portable Document Format,
which can be converted with a ps2pdf
tool and that is today the most widely
used format for publishing scientific papers.
Then someone else came along and
decided to extend the TeX tool and
put next to the DVI output driver
also directly a PDF driver.
So if you use the PDF text
command or the pdflatex command,
it can translate in a single step
the TeX source code into a PDF file and
it can include other images made in PDF,
PNG, JPEG, a range of standard
file formats.
The original TeX came with its own macro
library of commonly used functions,
commands called plainTeX,
but that turned out to be quite low level,
so another well known computer
science researcher,
Leslie Lamport from SRI later
DEC Research institutes,
also in the Palo Alto area,
wrote a quite comprehensive
macro package called LaTeX
that allows you to describe a document
in a somewhat
higher-level fashion, where you can,
rather than providing individual commands,
“Please switch here to boldface”,
“Please switch here to italics”,
you identify in the document
this is the start of a new section
and it will automatically take
care of section headings and so on.
There exists a huge ecosystem of
add-on packages for TeX,
and in particular the LaTeX package.
So for example, these
slides I've produced using
a LaTeX add-on package called
Beamer which is specifically optimized
for making presentation slides.
What resources are there available?
There is first of all Leslie Lamport's
book “LaTeX, a document preparation system”
which I've got a copy available here.
This is not freely available on
the Internet, so Leslie Lamport
makes some income from that.
Still, it is an extremely
well written documentation.
It not only teaches you how to
use LaTeX software package,
but it also teaches you a lot of
tricks and conventions about proper
scientific typesetting conventions and
rules for how to make a text look nice.
If you roughly read the first
about 64 pages of that book,
that gives you a solid introduction in
everything you need to know to get started.
The rest of the book is more
for reference materials.
There are on the Internet quite a number
of other tutorials available that you
may also find useful to get started,
and there is a summary of these at
this latex-project.org help web page.
There is a very comprehensive
TeX frequently-asked-question list
available online. If you want to get LaTeX,
if you have for example Ubuntu or
Debian Linux, it comes with the
operating system distribution.
You just type “apt-get install texlive”.
That's sort of a medium size install.
There are also other packages for
a very minimalistic installation.
The entire TeX Live with everything
is a bit over
2 gigabytes large, so you may want
to have some space for that,
but the default is a bit smaller.
For macOS,
there exists a MacTeX distribution,
which is a tech life version
packaged up for the Macintosh.
For Windows there are several
options available.
There is a more minimalistic
distribution called MiKTeX that just
installs a small installer and then
interactively allows you to load
additional components as you need them.
There is another one called
proTeXt that is based on MiKTeX
but installs more by default
and has some additional tools,
but the TeX Live distribution,
which was originally mostly
maintained for Unix systems, is
now also maintained for Windows,
so you can also try that if
you're a Windows user.
For more advanced use,
if you're actually not just
writing documents,
but if you're trying to extend
the LaTeX ecosystem if you try to
install create macro packages to
solve problems in a reusable way,
for example,
if you're trying to design
a house letter style or a
common thesis style for
an organization or so,
then the LaTeX companion,
which is a quite thick, over 1000
pages, book written by the current
maintainers of the LaTeX system,
is a very comprehensive resource,
not just on teaching you how to
write extensions to LaTeX,
but also giving a quite detailed
overview of many of the existing
extensions that are already available.
So LaTeX and TeX, as I mentioned,
are most famous for the syntax they
offer in order to typeset mathematics
and subsets or imitations of the
LaTeX equation syntax have also
found their way into other products.
So there is for example,
for Microsoft part of Microsoft Word
is an equation editor that has some
LaTeX-like facilities available.
And also allows you to enter
formulas in a LaTeX-like way.
However, it does not have the actual LaTeX
typesetting engine behind it, so
the typographic quality that you get
out is a little bit simpler and more
primitive than what LaTeX would do.
If you have writing documents for the web,
there exists an excellent JavaScript
library called MathJax that allows you to
write in the middle of your HTML web page a
equation in LaTeX syntax and
then when the page is loaded,
JavaScript is activated:
it scans your entire page,
searches for these LaTeX fragments
and typesets them and replaces them
with symbols and image fragments in
order to give a quite high quality
rendition of these equations.
There are also various web content
management systems that internally use
LaTeX or other software products.
So for example, Mediawiki,
the content management system used
by Wikipedia, allows you to enter
LaTeX
formulas; will actually use Latex to
turn them into little pictures that
are then inserted into the document.
There are other software packages,
MATLAB, for example,
has a plotting system that allows
you to use LaTeX in order to typeset
mathematical notations, for example,
in the axis labels of plots.
I mentioned already a particular goal of
LaTeX is to encourage logical markup that
helps you to maintain a consistent style.
So you're not meant to fiddle continuously
with font sizes and font styles,
but you write a macro and the use of
the macro expresses something that's
a commonly recurring theme in the document.
For example, you have some mathematics,
for example, a lemma, theorem,
a proof would typically be a macro,
and they would automatically be
consistently styled and maintained.
The fact that LaTeX uses plain-text
input may sometimes seem a little bit arcane
and more akin to software development,
but it also has many advantages.
You have full control over the
state of your document,
so in other WYSIWYG tools,
Microsoft Word or similar,
there have again and again been
reports that as the document gets
very complicated, little
bugs, misconfigurations find their way into
the binary data structure of the document,
and slowly the author may lose control
over their document because of the,
they no longer can quite control in
what state the document is with these
proprietary binary file formats,
whereas plain text source,
like your source code you can
maintain in version control systems,
like Subversion or Git,
you can collaborate via these
version control systems
with other authors such that everyone
can easily see, with
Unix tools like “diff” who has changed what,
so it is quite amenable to automation.
There exists a lot of tools
that will output LaTeX that,
for example some specialist language
is nicely typeset in LaTeX.
It's easy to automate,
so anything you've learned
about automated build,
with Makefiles and similar you can apply
because LaTeX has just a command line tool,
there's no mouse clicks required.
You have a free choice of editors,
whether you are more an Emacs
or vi fan, or I know some colleagues
who prefer to write LaTeX in Word.
They actually use Microsoft Word as
a plain-text editor because they
appreciate the spell checker and
grammar checker built into Word.
You can mix and match
tools; nobody tells you which
particular editor you use.
It behaves very robustly
with very large documents,
PhD thesis or books, very long
technical reports.
And because it's not just
a typesetting system,
it's actually a Turing complete
macro programming language,
this vast ecosystem of extension packages
has emerged over the last three decades,
and so whenever you have a need to use
some particular specialist notation,
certain types of figures,
chemical formula,
logic, proofs,
pseudocode in different
programming languages,
circuit diagrams,
flowcharts and so on,
there is usually a quite elaborate
solution available. Just to prove
the point, I have loaded here
the skak package,
which allows you to typeset chess
positions and you just write down,
say, I want to start a new
game and you type in a couple of
moves and then \showboard and
you immediately see the board
and then you can make some more
moves and show the next board and
you have a very high quality tool
for typesetting chess textbooks.
And it's extremely mature.
It has been around for a bit over 30 years.
There has been a
longstanding bug bounty on TeX,
where Donald Knuth
was so confident about his
software that he offered to double
the bug-bounty prize each time
when someone found another bug,
he eventually had to level this
off at $1024. And he also discovered
that receiving a bug-bounty cheque
from Donald Knuth was such a
badge of honor that everyone just
framed them and put them on their
wall rather than actually
cashing them in. It's freely available.
It's highly portable, highly stable,
open source.
It is used by many science publishers.
So many conference organizers, journals
will offer LaTeX class styles to help
you match exactly their house style.