-
Notifications
You must be signed in to change notification settings - Fork 2
Tutorial: Tikz ‐ Compiling figures to image files
TikZ is a nice LaTeX library to generate figures for articles and for presentations in a clean and professional way. A good tutorial about TikZ is available on the wiki.
Yet, LaTeX only compiles PDF files, which can be cumbersome when importing figures in a Powerpoint-like (Google Slides, Keynote, etc) presentation. If using beamer
to create presentations in LaTeX is an option, it can be better in certain contexts to compile LaTeX to image files (jpg, png, etc). This tutorial shows how to setup your computer (or Overleaf) to compile TikZ figures in images.
When LaTeX compiles TikZ pictures into image files, it actually compiles a PDF and then it convert this PDF into a JPG or a PNG using :
- Ghostscript to handle PDF files
- ImageMagick to create image files
These two softwares are generally installed by default on Ubuntu. Yet, it's a good practice to verify that we have both and the right versions :
gs --version # gs ≥ 9.24
convert --version # Must be ImageMagick 6+
GhostScript used to have a security vulnerability until GhostScript version 9.24. Since we have a version of GhostScript that is higher than 9.24, GhostScript is safe enough to disable all security policies that are added by default in its configuration.
To remove these security policies, we must edit /etc/ImageMagick-6/policy.xml
and remove the following lines from the file:
<!-- disable ghostscript format types -->
<policy domain="coder" rights="none" pattern="PS" />
<policy domain="coder" rights="none" pattern="PS2" />
<policy domain="coder" rights="none" pattern="PS3" />
<policy domain="coder" rights="none" pattern="EPS" />
<policy domain="coder" rights="none" pattern="PDF" />
<policy domain="coder" rights="none" pattern="XPS" />
Here is a minimal working example of a LaTeX document that would generate image files :
% !TEX program = pdflatex
% !TEX options = --shell-escape -synctex=1 -interaction=batchmode -halt-on-error -file-line-error "%DOC%"
\documentclass[preview, tikz, border=7pt, convert={density=600, png}]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,arrows.meta,backgrounds}
\tikzset{
white background/.style={
show background rectangle,
tight background,
background rectangle/.style={
fill=white
}
}
}
\begin{document}
\begin{tikzpicture}[white background]
\node [rectangle] (a_block) {This is a block};
\end{tikzpicture}
\begin{tikzpicture}[white background]
\node [rectangle] (another_block) {This is another block in a new page};
\end{tikzpicture}
\end{document}
Let's examine this example line by line :
- If you use a local compiler, the image files are directly inside your current working directory.
- If you use Overleaf, you can download the image files with the
Other logs and files
button at the bottom of the log pane :
- Warthog Teach and Repeat (ROS1)
- Warthog Teach and Repeat (ROS2)
- Time Synchronization (NTP)
- Time Synchronization (PTP)
- Deployment of Robotic Total Stations (RTS)
- Deployment of the backpack GPS
- Warthog Emlid GPS
- Atlans-C INS
- How to use a CB Radio when going in the forest
- IP forwarding
- Emlid Data Postprocessing (PPK)
- Setting up a reliable robot communication with Zenoh
- Zenoh rmw
- Lessons Learned
- Robots' 3D Models
- Order Management
- Fast track Master → PhD
- Intellectual Property
- Repository Guidelines
- TF Cheatsheet
- Montmorency Forest Wintertime Dataset
- RTS-GT Dataset 2023
- Deschenes2021 Dataset
- TIGS Dataset
- DRIVE Datasets
- BorealHDR
- TimberSeg 1.0
- DARPA Subterranean Challenge - Urban Dataset
- How to upload a dataset to VALERIA
- ROS1 Bridge
- Migrating a repository to ROS2 (Humble)
- ROS2 and rosbags
- MCAP rosbags
- DDS Configuration (work in progress)
- Using a USB Microphone with ROS2
- ROS2 in VSCode
- ROS2 Troubleshooting