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

Automating image positioning


When there's not enough free space on a page when you include an image, that image will go to the next page. This will leave white space at the end of the page. You could manually move some text to compensate. But imagine having a large document with many images; manually moving images to balance page breaks could cause a headache. Fortunately, LaTeX provides an automatism for us.

How to do it...

This is a very common way of including images as figures:

  1. Use a figure environment.

  2. Center the content, if desired.

  3. Include the image.

  4. Add a caption.

  5. Add a label for cross-referencing.

A typical command sequence is as follows:

\begin{figure}[htbp!]
  \centering
  \includegraphics{filename}
  \caption{Some text}
  \label{fig:name}
\end{figure}

In the document, you can refer to the figure number by using the \label{fig:name} command.

How it works...

The automatism is called floating, and it works for images; that means figures and tables. A figure environment lets its content float...