Transforming images with TikZ in LaTeX

March 28, 2023

The two images below have the same information. How do you go from this:

before

To this?

after

Using tikz :)


What is TikZ?

TykZ is a LaTeX package used for creating professional-looking graphics in scientific documents. LaTeX is a typesetting language used for producing high-quality technical and scientific documents, and TykZ provides additional tools and features for producing graphics in these types of documents.

How to use TikZ?

TikZ is a package inside Latex. To use TikZ, you will need a machine with Latex installed and working.

One solution to get Latex working faster is Overleaf. Overleaf is a collaborative, cloud-based LaTeX editor and project management tool for creating, editing, and publishing scientific and academic documents.

If you want to learn TykZ, overleaf has a great 5 part tutorial: learn tykz.

You can use the following latex template to get started with TykZ.

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[margin=1in]{geometry}
\title{
My beautiful square
}
\author{George C. G. Barbosa}
\date{\today}
\usepackage{tikz}
\usetikzlibrary{
shapes,
arrows,
arrows.meta,
shapes.geometric,
calc,
positioning,
backgrounds,
decorations.pathreplacing,
matrix,
math
}
\begin{document}
\maketitle
\begin{figure}[h]
\centering
\resizebox{\columnwidth}{!}{
\begin{tikzpicture}[]
\draw (0,0) -- (4,0) -- (4,4) -- (0,4) -- (0,0);
\end{tikzpicture}
}
\caption{\footnotesize{El squaro}}\label{fig:tikz}
\end{figure}
\end{document}

The above source code will draw a square of 4x4 units.