The pgfplots package for plotting functions and the standalone package for displaying the graph in a single document need to be installed manually as they are not currently present in the Ubuntu repositories:

Shell

1

2

3

4

5

6

7

8

9

10

11

12

13

14

# navigate to your local texmf folder (could also be ~/texmf or ~/.texmf)

Fractals are mathematical sets showing a repeating pattern at every scale. Fractal patterns are fascinating and are commonly found in nature, for example in cauliflowers, broccoli, lungs, or trees.

LaTeX can generate complex fractals with few lines of code but needs some packages to do that. So let’s prepare the LaTeX environment from scratch by installing all the necessary packages (and prepare a cup of coffee in the meantime):

The first fractal I am going to draw is the Mandelbrot set. Here is the LaTeX code using the tikz package:

mandelbrot.tex

TeX

1

2

3

4

5

6

\documentclass{article}

\usepackage{tikz}

\usetikzlibrary{shadings}

\begin{document}

\tikz\shade[shading=Mandelbrotset](0,0)rectangle(15,15);

\end{document}

To compile the tex file from the command line you can use the latexmk utility previously installed. I noticed that evince and okular don’t show this fractal in high definition so it’s better to open it with Adobe Reader.