### Supporters and Partners

Sponsored by DANTE e.V.: The German speaking TeX Users Group

 Efficient Seamless Tiled Backgrounds
(15 votes, average: 4.53 out of 5)
LaTeX - Graphics, Figures & Tables
Written by Lim Lian Tze
Sunday, 17 June 2012 20:45

I’m fairly sure everyone has, at least on one occassion, toyed with the idea of using tiled patterns as the background on a Beamer presentation or a report. (Whether this is good taste is another issue.)

In this article, we will speak about an efficient technique for creating tiling backgrounds based on few patterns but resulting in a visual effect of a non-repeating pattern.

- A contribution to the LaTeX and Graphics contest -

Strictly speaking, this isn’t about graphics in LaTeX per se, but I had a lot of fun when I read about the underlying principle, so here goes.

There are many free, high-quality tile patterns out there: try subtlepatterns.com, DinPattern and COLOURlovers.com. And while there are more than one way to get tiled-pattern backgrounds in LaTeX, I usually ‘cheat’ a little by using the wallpaper package, which provides a \TileWallPaper{«width»}{«height»}{«filename»} command. The package provides commands for specifying a single graphics file at the corners or center of the paper as well; see the package manual or this post for more information. It’s included in both MikTeX and TeXLive. Here I’m using \TileWallPaper in my background canvas template of a Beamer presentation:

\documentclass{beamer}
\usepackage{eso-pic}
\usepackage{wallpaper}
\usepackage{graphicx}

% I usually give the proportion measurements of the tile by
% referring to the dimensions (in pixels) of the original
% graphics, while keeping an eye on the resolution
\setbeamertemplate{background canvas}{
\TileWallPaper{51.5pt}{11.5pt}{arches}
}

\begin{document}
\begin{frame}
\frametitle{Tiled-Pattern Backgrounds}
\begin{itemize}\item Maths is cool.
\item And so are \TeX\ \& friends.\item They make powerful designs.
\end{itemize}\end{frame}
\end{document}

Simple, regular patterns usually work well when tiled, as is the arches pattern above. However, if your pattern is something more textured, the resultant look is very often too regular and artificial:

You could, of course, source for full-page textures for more natural-looking textures, e.g. on DeviantArt. But this usually means a much larger graphics file: easily 1 or 2 MB for a good resolution file. This will certainly increase the file size of your output PDF: not usually a desirable consequence.

Alex Walker wrote about what he called the Cicada Principle, a technique for “creating efficient tiling backgrounds that don’t appear to repeat”. Essentially, this involves creating a set of semi-transparent pattern tiles of different sizes, whose dimensions correspond to a scaled sequence of prime numbers. As a result, when these tiled patterns are layered on top of each other, you get a visual effect of a non-repeating pattern; i.e. not until after some really big interval. (Think about the lowest common denominator of prime numbers.) And yet the total file size of the graphics used remains small, in comparison to a full-screen texture graphics file.

Multiple \TileWallPaper commands accummulate, i.e. the graphics will be stacked on top of one another. So let’s use these two other tile patterns in our Beamer presentation:

Let’s try adding curtain2.png in our beamer background canvas definition:

\setbeamertemplate{background canvas}{
\TileWallPaper{32.7pt}{275.1pt}{curtain1}
\TileWallPaper{90pt}{275.1pt}{curtain2}
}

Hmmm, at this point, the monotiny starts to break down: a great improvement over the first attempt. And when we add the third pattern:

\setbeamertemplate{background canvas}{
\TileWallPaper{32.7pt}{275.1pt}{curtain1}
\TileWallPaper{90pt}{275.1pt}{curtain2}
\TileWallPaper{210.9pt}{275.1pt}{curtain3}
}

That actually looks quite nice, as if a full-sized background graphics was used. And the output PDF file (with just this one slide) is a mere 113 KB, using only 52.21 KB of graphics files.

You can do this similarly for, say, a magazine-style report, or any document, for that matter. Here’s an example with the Parchment tiles from the Cicada Project:

\documentclass[14pt]{scrartcl}
\usepackage{wallpaper}
\usepackage{graphicx}
\usepackage{lipsum}

\TileWallPaper{150pt}{150pt}{texture_01}
\TileWallPaper{530pt}{700pt}{texture_02}
\TileWallPaper{410pt}{900pt}{texture_04}
\begin{document}
...
\end{document}

The The Cicada Project Gallery contains many pattern submissions that you can experiment with, but you can certainly design your own patterns (and submit them) too. Alex listed a few tips for designing ‘Cicada’ tiles in his post:

• Design the stacking order and size of your tiles like an upside-down pyramid.
• The bottom layer can be quite small and repetitive.
• The upper-most layer should have the largest dimension, and also the sparsest imagery.
• Avoid highly distinctive, eye-catching details in the upper most layer.
• Trial and error!

And I just cannot resist ending this by posting some more examples, using tiles from the Cicada Project gallery. And an additional benefit of this little exercise: the next time your kid (or anyone) complains “maths is no fun”, you have one more example to show him or her how maths is really cool!

P/S: I quite realise some patterns are just too distractive and quite unusable as presentation backgrounds. Like the final example. But like I said, I couldn’t resist. :) I hope you enjoyed it as much as I did!

About the Author: Lian Tze is an LaTeX enthusiast and a freelance LaTeX trainer and consultant. She loves discovering new uses of LaTeX in different scenarios and enjoys sharing her experience, including contributing regularly to the Malaysian LaTeX User Group blog. Lian Tze is now working towards a PhD on natural language processing and multilingual lexicons for under-resourced languages, as well as being a good mom to her 4-year-old daughter.

### Latest Forum Posts

﻿

Re: Problem with table location when margins has been modifi
28/09/2016 01:35, etp94

Re: Problem with table location when margins has been modifi
27/09/2016 20:06, cgnieder

Problem with table location when margins has been modified
27/09/2016 18:58, etp94

sort references alphabetically

Problem on using -tabout- command in Stata for creating publ
27/09/2016 09:12, Thong Nguyen

Re: Changing the default build directory
27/09/2016 06:01, erwann

Re-starting
27/09/2016 06:00, dwjones1

Re: Problems compiling, math already defined
26/09/2016 15:57, onmikkelsen

Re: Problems compiling, math already defined
26/09/2016 15:12, onmikkelsen

Re: Page numbering location and headers
24/09/2016 17:59, etp94