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

Cutting an image to get rounded corners


The previous recipe gave us an edged image. It can be nice to have rounded corners, so let us take a look at how to achieve that.

How to do it...

We will use a few features of the very capable tikz graphics package:

  1. Load the tikz package in your preamble:

    \usepackage{tikz}
  2. Declare a box for storing the image:

    \newsavebox{\picbox}
  3. Define a macro that allows us to use our recipe repeatedly:

    \newcommand{\cutpic}[3]{
      \savebox{\picbox}{\includegraphics[width=#2]{#3}}
      \tikz\node [draw, rounded corners=#1, line width=4pt,
        color=white, minimum width=\wd\picbox,
        minimum height=\ht\picbox, path picture={
          \node at (path picture bounding box.center) {
            \usebox{\picbox}};
        }] {};}
  4. Use the new macro within your document to include an image:

    \cutpic{1cm}{8cm}{filename}
  5. Compile the document to see the effect:

How it works...

After loading the tikz package, we created a box to store the image. We defined a macro; its first task is to store our image...