Book Image

LaTeX Cookbook

By : Stefan Kottwitz
Book Image

LaTeX Cookbook

By: Stefan Kottwitz

Overview of this book

LaTeX is a high-quality typesetting software and is very popular, especially among scientists. Its programming language gives you full control over every aspect of your documents, no matter how complex they are. LaTeX's huge amount of customizable templates and supporting packages cover most aspects of writing with embedded typographic expertise. With this book you will learn to leverage the capabilities of the latest document classes and explore the functionalities of the newest packages. The book starts with examples of common document types. It provides you with samples for tuning text design, using fonts, embedding images, and creating legible tables. Common document parts such as the bibliography, glossary, and index are covered, with LaTeX's modern approach.You will learn how to create excellent graphics directly within LaTeX, including diagrams and plots quickly and easily. Finally, you will discover how to use the new engines XeTeX and LuaTeX for advanced programming and calculating with LaTeX. The example-driven approach of this book is sure to increase your productivity.
Table of Contents (19 chapters)
LaTeX Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction


LaTeX has been around for many years. Over time, developers and authors have contributed a lot of extensions to the LaTeX code base.

These extensions include the following:

  • Document class: This is a style file which is the frame of your document. It usually comes with meaningful default settings that can be changed via options when loading it. Its macros can be customized by the \renewcommand command. It often provides commands for authors to modify settings.

  • Package: This is a style file with a specific purpose that can be loaded in addition to the document class. Packages can be combined. Most of the time, we load many packages using the \usepackage command.

  • Bundle: This is a set of closely related packages or classes. In our first recipe, Writing a short text, you will get to know some bundles.

  • Template: This is a document filled with dummy text, which you can use it as a starting point, and just fill in your own headings, texts, formulas, and images. We will take a look at a template in our second recipe, Writing a thesis.

These add-ons are incredibly valuable! They are one of the reasons for the enduring success of LaTeX. We all agree that learning LaTeX can be hard with its steep learning curve. However, if you don't reinvent the wheel, and start with a good template or class and a quality set of packages, you can quickly achieve great results.

The purpose of this book is to assist you in this regard.

Getting ready

To be able to work with LaTeX, you need install the following on your computer:

  • TeX and LaTeX software, which are together called TeX distribution

  • A LaTeX editor, although you can use any text editor

  • A PDF viewer to view the final output

If you already have these installed, great! In that case, you can skip the next paragraphs and immediately proceed to the first recipe.

A PDF reader is probably already installed on your computer, such as the Foxit Reader, the Adobe Reader or the Preview app on the Mac. Furthermore, most editors come with an integrated PDF previewer. So, let's take a look at the TeX software and editors.

TeX and LaTeX distributions

There are collections of TeX and LaTeX software that are ready to use and easy to install. Their websites provide information on installing and updating them. You may choose the download site for your system:

  • TeX Live: At http://tug.org/texlive/, you can find download information and installation instructions for the cross-platform TeX distribution that runs on Windows, Linux, Mac OS X, and other Unix systems. It is supported by the TeX Users Group (TUG).

  • MacTeX: This is based on TeX Live and has been significantly customized for Mac OS X. The basic information is available at http://www.tug.org/mactex/.

  • MiKTeX: The download and documentation of that Windows-specific distribution can be found at http://www.miktex.org/.

  • proTeXt: This is for Windows only, and it is derived from MiKTeX, but proTeXt is more user-friendly during installation. Its home page can be found at http://www.tug.org/protext/.

I recommend that you choose MacTeX if you have a Mac; otherwise, I recommend using TeX Live, since the support by the TUG is especially good.

Describing the setup is beyond the scope of this book. For TeX Live, you can find a step-by-step explanation with screenshots in the LaTeX Beginner's Guide by Packt Publishing. Generally, when you visit Internet addresses of the TeX distributions listed above, you can find detailed setup instructions.

Finally, on Linux, such as Ubuntu, Debian, Red Hat, Fedora, and SUSE versions, there's usually a TeX Live-based software package available via the operating system repositories. While it's usually not as up-to-date as an installation done via the TeX Live website or a TeX Live DVD, it's very easy to install using the Linux package manager, which you use to install any software usually.

LaTeX editors

There are many LaTeX editors, from small and quick to very feature-rich editors. The TeX distributions already provide the fine editor TeXworks, which I use. It can be set up together with TeX or with a package manager on Linux, and it can be downloaded from http://www.tug.org/texworks/.

I have a collection of the links to LaTeX editors and additional software on my blog, http://texblog.net/latex-link-archive/distribution-editor-viewer/, where you may look for alternative editors, which run on your operating system.

Additionally, there are pure online LaTeX editors, which run in a web browser, so you can use them even on tablets and smartphones. The most noticeable LaTeX editors are as follows:

  • https://www.overleaf.com, with real-time collaborative editing and a rich text modes which renders headings, equations and further formatting directly in the editor

  • https://www.sharelatex.com, also with real-time collaboration and revision history for tracking changes

If you need any help in setting up and using LaTeX or any other editor, you can visit a LaTeX web forum. In Chapter 12, Getting Support on the Internet, you can find links to these forums and see and how to use them. You can also find me on those forums.

If you would like to get help in learning LaTeX, you may take a look at LaTeX Beginner's Guide at https://www.packtpub.com/hardware-and-creative/latex-beginners-guide.

Once you have done the installation, you can launch the editor and start with a LaTeX recipe.