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

Drawing molecules


In the previous recipe, we already encountered formulae for molecules. Now let's see how to draw them. This means drawing a group of atoms and connecting them by lines of various kinds.

How to do it...

This rather complex seeming task becomes manageable using the chemfig package. It provides a compact syntax for drawing molecules. Let's draw some:

  1. Start with any document class:

    \documentclass{article}
  2. Load the chemfig package:

    \usepackage{chemfig}
  3. Let's write molecules in a table. For this, we stretch the rows a bit and start a tabular environment with a right-aligned column and a left-aligned one.

    \renewcommand{\arraystretch}{1.5}
    \begin{tabular}{rl}
  4. For molecules, use the \chemfig command. Write atoms as letters and a single bond using a dash:

      Hydrogen: & \chemfig{H-H} \\
  5. Write a double bond using an equal-to sign:

      Oxygen:   & \chemfig{O=O} \\
  6. For a triple bond, use a tilde:

      Ethyne:   & \chemfig{H-C~C-H}
  7. End the table, and leave some space:

    \end{tabular}
    \qquad
  8. Enclose...