Reader small image

You're reading from  LaTeX Graphics with TikZ

Product typeBook
Published inJun 2023
PublisherPackt
ISBN-139781804618233
Edition1st Edition
Tools
Right arrow
Author (1)
Stefan Kottwitz
Stefan Kottwitz
author image
Stefan Kottwitz

Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation. For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX and goLaTeX and the Q&A sites TeXwelt and TeXnique. He runs the TeX graphics gallery sites TeXample, TikZ, and PGFplots, the TeXlive online compiler, the TeXdoc service, and the CTAN software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet. He publishes ideas and news from the TeX world on his blogs LaTeX and TeX. Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.
Read more about Stefan Kottwitz

Right arrow

Preface

LaTeX Graphics with TikZ is a practical introduction to producing graphics in LaTeX. It features TikZ, a powerful modern computer graphics package. This book will help you write mathematical, scientific, or technical papers with graphics. The book guides you through the initial challenges and provides a rapid learning process. Even though using an external graphics editor may seem like a more accessible option at first sight, it will turn out that learning TikZ is more than worth the effort.

This book starts with essential topics such as installing TikZ and learning the fundamental syntax. It offers step-by-step examples that begin with understanding coordinate systems, drawing geometric shapes, and working with nodes, anchors, edges, and arrows. You will also learn to utilize styles to produce consistent graphics easily while saving typing work.

Furthermore, this book covers clipping, filling, shading, and adding decorations. You will learn about calculations with coordinates and transformations of coordinates and canvas.

This book will help you create professional-looking diagrams and plots in two and three dimensions for visualizing your ideas and data.

With LaTeX Graphics with TikZ to hand, you can quickly start with TikZ and enjoy its many benefits.

Who this book is for

If you’re a LaTeX user in school, academia, or industry, and you are looking to add figures such as diagrams, plots, and graphics in general to your thesis, articles, or any document, this book offers a practical and fast-paced introduction to producing such figures. Whether you’re a student, teacher, or engineer, this book is highly beneficial. Once you have experience in LaTeX or have read any LaTeX beginner’s book or tutorial, you can successfully work with this book.

What this book covers

Chapter 1, Getting Started with TikZ, introduces TikZ. It discusses alternative graphics packages and emphasizes TikZ’s benefits. You’ll thoroughly understand what TikZ is all about and its unique philosophy. You’ll receive guidance on installing TikZ, and you will walk through creating a small drawing. Additionally, you will get helpful tips for accessing TikZ’s and other packages’ documentation.

Chapter 2, Creating the First TikZ Images, walks you through creating a LaTeX document with a drawing from scratch. You will gain a solid understanding of the TikZ syntax and learn about cartesian and polar coordinates in two and three dimensions. Additionally, you’ll learn how to create basic geometric shapes and incorporate color into your designs.

Chapter 3, Drawing and Positioning Nodes, introduces the fundamental concept of nodes. You’ll learn how to draw nodes in various shapes, position and align them, and add text, images, and labels.

Chapter 4, Drawing Edges and Arrows, shows how to connect nodes by edges, straight and curvy lines, and arrows. You’ll see how to add text labels on the edges and adjust alignment, position, and orientation. You’ll learn to use line styles and customized arrow tips in one or both directions.

Chapter 5, Using Styles and Pics, teaches you how to define and apply global and local styles for TikZ elements. You will learn how to use styles on nodes and edges and apply them to entire pictures or selected parts of a picture using scopes. Additionally, you will learn about using mini TikZ pictures as building blocks.

Chapter 6, Drawing Trees and Graphs, guides you through creating tree structures to depict parent-child relationships hierarchically. It shows how to draw mind maps to visualize ideas and introduces a concise syntax for generating graphs. Additionally, this chapter offers a practical technique for arranging objects in a matrix format similar to LaTeX’s tabular environment.

Chapter 7, Filling, Clipping, and Shading, starts with more advanced techniques. You’ll learn how to fill complex paths, clip pictures to specific areas, and add shading that transitions smoothly from one color to another.

Chapter 8, Decorating Paths, introduces techniques for adding creative effects to lines and curves, such as making them wavy, zigzag, or bumpy. You’ll also learn how to print text along a curved path and apply multiple actions on a single path.

Chapter 9, Using Layers, Overlays, and Transparency, demonstrates how to create drawings on different layers, allowing you to place objects behind text or images. You will learn how to use transparency to improve this effect. Additionally, you will discover how to superimpose TikZ annotations on top of regular LaTeX text and add background images to document pages, similar to watermarks.

Chapter 10, Calculating with Coordinates and Paths, shows the efficient way of letting TikZ calculate coordinate values. This chapter covers coordinate calculation, distance and projection calculation, and calculating intersections of paths. You’ll also discover how to save time and streamline your code by using loops to repeat commands.

Chapter 11, Transforming Coordinates and Canvas, focuses on shifting, rotating, and scaling nodes and coordinates using transformations. You’ll learn skills that enable you to make precise adjustments and repositioning, whether you need to make minor tweaks or complex changes to your drawings.

Chapter 12, Drawing Smooth Curves, explores different methods to draw easy curves smoothly with gentle slopes, smooth transitions, and without sharp corners or spikes, similar to freehand-like drawings.

Chapter 13, Plotting in 2D and 3D, deals with visualizing data in a coordinate system. It covers customizing Cartesian and polar axes and adding legends, plotting explicit and parametric functions in 2D and 3D, calculating plot intersections, and filling between plots.

Chapter 14, Drawing Diagrams, shows how to create flowcharts, relationship diagrams, descriptive diagrams, and quantitative diagrams. The emphasis is on using packages to generate whole diagrams in a more automated way.

Chapter 15, Having Fun with TikZ, showcases examples of how skilled TikZ users enjoyed programming add-on packages and sharing them with the TikZ community. You’ll see how to draw cute animals, human shapes, nation flags, and game pieces.

To get the most out of this book

For using TikZ, a TeX installation, such as TeX Live, MiKTeX, or MacTeX, is required on your computer. TikZ and LaTeX are compatible with most operating systems, including Windows, Linux, macOS, and other Unix operating systems. All code examples in this book have been tested with TeX Live 2023 on Debian Linux and with MacTeX 2023 on macOS Ventura. For those who do not wish to install LaTeX, code examples are available on https://tikz.org, which includes an online compiler that makes the code accessible also for smartphone and tablet users. Alternatively, you can register on https://overleaf.com to compile the examples obtained from GitHub or TikZ.org.

TikZ version 3.1.9.a has been used to develop and test the code examples in this book. All references to sections in the manual refer to that version. A future version may have a different section numbering.

If you are using the digital version of this book, we advise you to type the code yourself or access the code from the book’s GitHub repository (a link is available in the next section). Doing so will help you avoid any potential errors related to the copying and pasting of code.

Download the example code files

Throughout the book, concise code snippets are used to explain concepts without repetitive LaTeX document body and preambles. The entire code is available online for reference and further exploration.

All examples use the standalone class. You can use the example codes and TikZ in general in any LaTeX document class.

You can download the example code files for this book from GitHub at https://github.com/PacktPublishing/LaTeX-graphics-with-TikZ. If there’s an update to the code, it will be updated in the GitHub repository.

You can open the entire code bundle as a single project on Overleaf using the following link: https://www.overleaf.com/docs?snip_uri=https://tikz.org/code.zip.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots and diagrams used in this book. You can download it here: https://packt.link/7hkX1

Conventions used

There are a number of text conventions used throughout this book.

Code in text: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: “Write \draw [blue] circle (1cm); to get a blue circle.”

A block of code is set as follows:

\begin{tikzpicture}
  \draw (-0.5,0) to ["text"] (0.5,0);
\end{tikzpicture}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

\begin{axis}[axis lines=center]
  \addplot {x^3/5 - x};
\end{axis}

Any command-line input or output is written as follows:

$ texdoc tikz

Bold: Indicates a new term, an important word, or words that you see onscreen. For instance, words in menus or dialog boxes appear in bold. Here is an example: “On the right-hand side, we see the so-called Transpose of the matrix.”

Tips or important notes

Appear like this.

Get in touch

Feedback from our readers is always welcome.

TikZ and LaTeX questions: If you have any questions about TikZ, LaTeX, or this book, you can post them at the author’s forum at https://latex.org

General feedback: If you have questions about any aspect of this book, email us at customercare@packtpub.com and mention the book title in the subject of your message.

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata and fill in the form.

Piracy: If you come across any illegal copies of our works in any form on the internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Share your thoughts

Once you’ve read LATEX Graphics with TikZ, we’d love to hear your thoughts! Please click here to go straight to the Amazon review page for this book and share your feedback.

Your review is important to us and the tech community and will help us make sure we’re delivering excellent quality content.

Download a free PDF copy of this book

Thanks for purchasing this book!

Do you like to read on the go but are unable to carry your print books everywhere?

Is your eBook purchase not compatible with the device of your choice?

Don’t worry, now with every Packt book you get a DRM-free PDF version of that book at no cost.

Read anywhere, any place, on any device. Search, copy, and paste code from your favorite technical books directly into your application.

The perks don’t stop there, you can get exclusive access to discounts, newsletters, and great free content in your inbox daily

Follow these simple steps to get the benefits:

  1. Scan the QR code or visit the link below

https://packt.link/free-ebook/9781804618233

  1. Submit your proof of purchase
  2. That’s it! We’ll send your free PDF and other benefits to your email directly
lock icon
The rest of the chapter is locked
You have been reading a chapter from
LaTeX Graphics with TikZ
Published in: Jun 2023Publisher: PacktISBN-13: 9781804618233
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €14.99/month. Cancel anytime

Author (1)

author image
Stefan Kottwitz

Stefan Kottwitz studied mathematics in Jena and Hamburg. He works as a network and IT security engineer both for Lufthansa Industry Solutions and for Eurowings Aviation. For many years, he has been providing LaTeX support on online forums. He maintains the web forums LaTeX and goLaTeX and the Q&A sites TeXwelt and TeXnique. He runs the TeX graphics gallery sites TeXample, TikZ, and PGFplots, the TeXlive online compiler, the TeXdoc service, and the CTAN software mirror. He is a moderator of the TeX Stack Exchange site and matheplanet. He publishes ideas and news from the TeX world on his blogs LaTeX and TeX. Before this book, he authored the first edition of LaTeX Beginner's Guide in 2011, and LaTeX Cookbook in 2015, both published by Packt.
Read more about Stefan Kottwitz