The Hitch-Hiker’s Guide to LaTeX3

2012-05-23 by Andrew Stacey. 1 comments


As with the original Hitch-Hiker’s Guide, this blog post won’t actually be all that useful to someone wanting to truly explore LaTeX3. It’s more of a “What I did on my holidays” kind of guide. I’ve recently had my first go at doing some coding with LaTeX3 and I thought it might be interesting to record my experiences.

The main site has certainly made me more aware of the LaTeX3 project. Familiarity, in this case, has not bred contempt but rather it has meant that LaTeX3 has seeped into my consciousness so that I’ve become vaguely familiar with it without ever actually having to think about it. Before this current experience then I had had a bit of exposure to LaTeX3 through making a few adaptations to the (most excellent) unicode-math package, but that was very definitely a case of “Monkey see, Monkey not really have a clue what he’s doing so it’s a million to one chance but it might just work.”. To really get to grips with something new, I need a problem to work on. Finally, along came a problem that I wanted to solve in TeX but which was very definitely a regular programming problem. So the prospect of doing it in ordinary TeX was too daunting to contemplate. For this problem, learning LaTeX3 seemed the lesser of two evils.

more »

KOMAscript: new English manual

2012-05-19 by keksdose. 0 comments

Markus Kohm, maintainer of KOMAscript has published a new version (3.11) of the KOMAscript bundle. There is one extraordinary issue: The new version includes a new manual in English. Markus said on his webpage:

»A new English user manual with the same structure and completely translated content of the German user manual is provided. There are still several issues with the translation, nevertheless, it’s much better than the previous English manual.«

As far as I can see, all the features of KOMAscript 3 are documented, the same as in the German version.

As TeXLive 2011 is frozen right now , you probably need to download the new version yourself from Berlios; follow the links on Markus’ website. Users of MiKTeX will probably get it soon.


Using sprite sheets with LaTeX

2012-05-04 by Paulo Cereda. 3 comments

Sprite sheet is the name of a big image containing several smaller images or icons. It’s a technique usually employed by webdesigners to reduce the number of requests the browser makes to the server – reducing the number of HTTP requests can make a Web page load much faster. It’s also used a lot in animation engines.

I was wondering if I could use a sprite sheet in a LaTeX document, so I got a sample image from the Tango Desktop Project and mapped it:

All icons are placed in a big image, like a matrix, and the size is fixed at 24px × 24px per icon. How can I select one of the icons from a LaTeX document? Thanks to our friend and moderator Martin Scharrer, including sprite sheets is a breeze with adjustbox!

This amazing package, amongst other features, allows us to adjust images with \adjustimage. We can also use \includegraphics with the clip option which we can use for mapping our sprite sheet. For instance, let’s include the warning sign in our document. We need to collect some data first:

We have all the parameters for including the warning sign. It’s now a simple call to \includegraphics[clip,trim=48px 96px 120px 48px]{sampletango.png} or \adjustimage{Clip=48px 96px 120px 48px}{sampletango.png} and the correct icon is included! The parameters to the trim/Clip option are:

  • 2 icons from left to right: 2 × 24px = 48px
  • 4 icons from bottom to top: 4 × 24 = 96px
  • 5 icons from right to left: 5 × 24 = 120px
  • 2 icons from top to bottom: 2 × 24px = 48px

The full code is as follows:


\usepackage{graphicx} \usepackage{adjustbox}


\begin{figure} \centering % using includegraphics % \includegraphics[clip,trim=48px 96px 120px 48px]{sampletango.png} % using adjustimage \adjustimage{Clip=48px 96px 120px 48px}{sampletango.png} \caption{A warning sign.} \end{figure}


The output:

There we go, sprite sheets with LaTeX. :)

Generating LaTeX code with a template engine

2012-03-15 by Paulo Cereda. 7 comments

Sometimes, you get stuck with repetitive tasks, like generating the very same document over and over with a few changes in the content. I’m the coordinator of a small choir in a parish, and twice a month I have to print songsheets for the community. I usually try to automate as many tasks as I can, but LaTeX output is quite tricky. Here’s my attempt to write a program that spits out a .tex file.

more »

The cake is a lie

2012-01-30 by Paulo Cereda. 6 comments

It all started a few days ago, when we had a question on about using TeX for (nearly) any kind of document. In one of the answers, our friend Andrew Stacey mentioned that he even does his kids birthday invitations in TeX; in the comments, Stefan Kottwitz asked for seeing this TikZ birthday cake, so Andrew updated his answer with a picture of the cake:

Yummy! An epic TikZ cake.

We all got very excited by this elegant cake, so our friend N.N. posted a follow-up question on how can I draw a cake using TikZ; Andrew then posted his code, to the joy of the community!

We all love cake.

I know only a few things about TikZ, as I only use the automata library. But  I was tempted to draw another cake. And if you play games like I do, by the title of this blog post, you already know what kind of cake I’m talking about.

more »

Non-Standard Code – A Workaround

2011-12-11 by droratariah. 5 comments


After answering the question about macro for \left( and \right) I realized that there’s a discussion worth considering behind the scene here. In particular, one can consider a beautiful solution, like the one of Herbert’s. This kind of answer, by all means, addresses the question posed. However, alongside, it also introduces several issues which might suggest that a better course of action is to be taken. Non standard code examples, like these which can be found in the question mention, as well as in many other threads in TeX.SE, have one prominent drawback, namely, they turn the code into a non standard one. I believe that for simple standard tasks (like the one dealt with in the question I started this post with) a more standard solution, in terms of TeX should be used. Let it either be code reuse or collaboration, non standard code serves as a problem. On the other hand, typing the full and standard TeX code can be sometimes be lengthy and tedious. Just like one won’t change the syntax of a for loop in any programming language, although it is being extensively used, one should not change, in my mind, the essence of TeX code. The alternative’s, which I would like to introduce and account my way of using, goal is to enable efficient typesetting process on the one hand, and maintain the resulting source code as standard as possible. It is called code snippets. more »

Building documents with rubber

2011-12-04 by Paulo Cereda. 12 comments

It’s common to compile our documents a couple of times to ensure, amongst other things, correct cross-referencing and indices. Sometimes, we also rely on a Makefile in order to make things easier. Now enters rubber, a powerful tool to help us on our building adventures.

more »

I TeX therefore iPad

2011-10-25 by Andrew Stacey. 14 comments


I have a new toy. It’s an iPad. Naturally the first thing that I tried to do was install TeXLive 2011 on it. When that didn’t work, I tried to take it back. When Apple disagreed with my reason (“Not able to run the best typesetting software”), I figured I’d just have to make the best of a bad job.

Actually, that’s a complete load of rubbish. The reason why it is rubbish is quite important to what I plan on writing here, so I’ll explain more below the fold. Above the fold, let me just explain what this article is. It is an account of my early days with the iPad with particular emphasis on anything vaguely relevant to my TeX addiction. If that interests you, read on.

more »

The TQFT Package

2011-10-10 by Andrew Stacey. 2 comments


I’ve now uploaded the second of the TeX-SX packages to CTAN. This is the TQFT package and is a TikZ/PGF package for drawing TQFT diagrams. The original question was Topological Quantum Field Theory diagrams with pstricks or tikz.

more »

Overkill is a good thing

2011-10-03 by Seamus Bradley. 3 comments

Recently, a question was asked about how to get enumeration with non-sequential, random-ish numbers. (I say random-ish because the point of the question was not to generate random numbers, but to take a given list of random looking numbers and enumerate with them. The obvious answer is just to use the optional argument of \item to do it manually. Tobi’s answer suggests exactly this. This is, I think, The Right Answer in this case.

So why did I suggest my own answer which, by my own admission, was an insane way of achieving the same thing? Given that the right answer had been given, why did I offer a much more complicated solution to the problem? Isn’t this a waste of everybody’s time?

No! The reason that my answer wasn’t a waste of time relates to something that you occasionally see mentioned on the StackOverflow blog. To quote from that linked post:

[W]e shouldn’t care about the questioner – the goal is to create a useful piece of information that makes the internet better. We’re here to serve the 15 million people who get answers from the site without ever typing a word.

What’s overkill for the question as it is asked might not be overkill for someone later stumbling across the question while browsing questions about enumeration on For example, imagine that our hypothetical TeXer Alice is wondering “How could I make my own list type, with an arbitrary set of symbols?” In this case, while Tobi’s answer works, the automated and general solution that seemed so over the top for the original case, now becomes a good solution to that problem.

So I would encourage you to offer really over the top super general solutions to questions with obvious simple answers. This encouragement is qualified however: if the simple answer hasn’t yet been given, give that first!

When I am writing LaTeX, I often indulge in over the top solutions to my simple problems. Why? Because as a PhD student, procrastination is an important part of staying sane. But also because it gives me a chance to learn more about TeX and this may save me time in the future, when I come back to something and I need the generality of what originally seemed an over the top solution.

I will leave you with a comment exchange between me and Herbert that illustrates this side of my liking for over the top solutions. I wanted to draw a brace across several lines of text. I commented on one of Herbert’s answers that I would prefer a TikZ answer to his PStricks answer. Why would I do that? Because I wanted to learn about TikZ. Of course, TikZ was overkill for this simple problem, but I’ve since used TikZ for much more complex drawings, and without those “overkill” baby steps, I wouldn’t have known how to do that. Herbert put it nicely: “I see, you like to shoot with canon balls on sparrows … ” I responded “as a way of learning how to use canons, it’s good practice.”