## Creating sparklines with LaTeX

Sparklines, invented by Edward Tufte (check out his awesome books!), are an interesting way of visualizing information inside the text. For more information on the theoretical background check Prof. Tufte’s page https://www.edwardtufte.com/bboard/q-and-a-fetch-msg?msg_id=0001OR.

For LaTeX users there are a few ways of using them inside LaTeX which we will briefly introduce in this article.

1. Using the sparklines package.

Examples taken from the package documentation.

\documentclass[12pt]{article}   \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{sparklines}   \begin{document}   Hello, I am a \begin{sparkline}{10} \sparkrectangle 0.0 1.1 \sparkdot 0.25 0.62 blue \sparkdot 1 0.2 red \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 / \end{sparkline} sparkline in a document.   You can also \begin{sparkline}{5} \sparkspike .083 .18 \sparkspike .25 .55 \sparkspike .417 1 \sparkspike .583 .62 \sparkspike .75 .42 \sparkspike .917 .5 \end{sparkline} use sparkbars.   Both types can \begin{sparkline}{5} \sparkspike .083 .18 \sparkspike .25 .55 \sparkspike .417 1 \sparkspike .583 .62 \sparkspike .75 .42 \sparkspike .917 .5 \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 / \sparkdot 1 0.2 blue \end{sparkline} also be combined.   \end{document}

2. Using the AfterTheFlood OTF font with the spark-OTF package by Herbert Voß

A few days ago I found information about a sparklines OTF font on Twitter which I then shared with the German TeX community. Herbert Voß created a few commands to use these fonts inside documents and packaged them.

When you update your TeX Live 2017 you should automatically get this package. In addition you need to install the fonts from After the Flood which are available from github.

Remark: as of 2017-09-24 the spark-otf package seems to have issues when compiled with xeLaTeX (at least with Windows). Use luaLaTeX to compile this. Update: With version 0.04 of the package xelatex is working fine.

\documentclass[12pt]{article}   \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage{sparklines}   \begin{document}   Hello, I am a \begin{sparkline}{10} \sparkrectangle 0.0 1.1 \sparkdot 0.25 0.62 blue \sparkdot 1 0.2 red \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 / \end{sparkline} sparkline in a document.   You can also \begin{sparkline}{5} \sparkspike .083 .18 \sparkspike .25 .55 \sparkspike .417 1 \sparkspike .583 .62 \sparkspike .75 .42 \sparkspike .917 .5 \end{sparkline} use sparkbars.     Both types can \begin{sparkline}{5} \sparkspike .083 .18 \sparkspike .25 .55 \sparkspike .417 1 \sparkspike .583 .62 \sparkspike .75 .42 \sparkspike .917 .5 \spark 0.1 0.95 0.2 0.8 0.3 0.3 0.4 0.52 0.5 0.62 0.6 0.7 0.7 0.5 0.8 0.4 0.9 0.25 1 0.2 / \sparkdot 1 0.2 blue \end{sparkline} also be combined.   \end{document}

### Uwe

Uwe Ziegenhagen mag LaTeX und Python, auch gern in Kombination. Hat Dir dieser Beitrag geholfen und möchtest Du Dich dafür bedanken? Dann unterstütze doch vielleicht die Dingfabrik Köln e.V. mit einem kleinen Beitrag. Details zur Bezahlung findest Du unter Spenden für die Dingfabrik.