# Write it on the walls! Vertical text in your LaTeX Beamer presentations

Ok, so probably you have heard about LaTeX before. Possibly you have used it for writing your neatly typeset, formula-crowded thesis. Eventually you may have heard about Beamer too, the LaTeX package for presentations.

I take it as a near-impossibility that you have actually used Beamer for creating a presentation, what with Office-like products being so easy and convenient, or Prezi being so astonishing and cool. But keep reading! For by the end of this article you will be wondering why you haven’t tried it yet.

Contrary to LaTeX, which is extremely well documented and easy to find help about, Beamer is much more obscure and can be at times thoroughly frustrating, since doing things that should be easy-peasy such as moving an image a teensy bit to the right can occasionally turn out an impossible hurdle.

Nonetheless, Beamer has two unparalleled strenghts. The first is, obviously, enabling you to leverage the terrific power of LaTeX for delivering neat, aesthetically pleasing presentations. The second strenght lies with a further TeX library, TikZ. TikZ/pgf is, strictly speaking, a graphic library, and therefore can be used for creating all sorts of complex scientific plots. Used inside Beamer, TikZ allows you to create all sorts of drawings, diagrams and graphics. Combine it with Beamer’s overlay feature – the possibility of piecewise uncovering text and other elements in the slide – and you have the possibility of creating completely custom animations for your slides. Furthermore, since you are writing the instructions for the graphic library directly inside the LaTeX source file, these are animations that you can code yourself. Cool, isn’t it?

But enough with the talk. I have prepared a short example to give you a taste of working with Beamer/TikZ and of the nice tricks you can figure out. Our problem will be to write words in an acronym. The acronym is written normally (horizontal, left-to-right), but we want to have the defining words written vertically, one letter below the other.
The acronym we will be using is the Agile mnemonic for the characteristics of a good User Story, INVEST (Independent, Negotiable, Valuable, Estimable, Small, Testable).

We start with a plain `.tex` file, all the dependencies we need are taken care of by specifying that the `documentclass` is `beamer`; we only need to explicitely include TikZ with `usepackage{tikz}`.
Inside the LaTeX `document` we create a `frame` which will host our `tikzpicture`, wrapped inside a `figure` for proper positioning.

Now we will write the acronym by putting each letter inside a TikZ `node`. We will exploit the possibility of referring to a node that has been already drawn using its identifier, and the possibility of positioning TikZ elements relative to one another using commands such as `right of` and `below of`. The resulting code is really pretty obvious:

``````
documentclass[xcolor=dvipsnames]{beamer}
usepackage{tikz}

begin{document}

begin{frame}{}
begin{figure}
begin{tikzpicture}[node distance=1em] %here we specify the distance between nodes for the whole picture
node [SeaGreen!80!black] (I) at (0,0) {Large{I}};
begin{scope}[node distance=3em] %here we define a sub-scope with a different value of the distance
foreach x [remember=x as lastx (initially I)] in {N,V,E,S,T}
node (x) [right of=lastx,SeaGreen!80!black] {Large{x}};
end{scope}
foreach x [remember=x as lastx (initially I)] in {n,d,e,p,e,n,d,e,n,t}
node (x) [below of=lastx] {x};
foreach x [remember=x as lastx (initially N)] in {e,g,o,t,i,a,b,l,e}
node (x) [below of=lastx] {x};
foreach x [remember=x as lastx (initially V)] in {a,l,u,a,b,l,e}
node (x) [below of=lastx] {x};
foreach x [remember=x as lastx (initially E)] in {s,t,i,m,a,b,l,e}
node (x) [below of=lastx] {x};
foreach x [remember=x as lastx (initially S)] in {m,a,l,l}
node (x) [below of=lastx] {x};
foreach x [remember=x as lastx (initially T)] in {e,s,t,a,b,l,e}
node (x) [below of=lastx] {x};
end{tikzpicture}
end{figure}
end{frame}

end{document}
``````

This produces our nice acronym with the definitions placed below vertically:

But what if we wanted to show the definitions one by one? That’s super-easy, since the Beamer `pause` command is recognized inside the `tikzpicture` environment! So we have:

``````
begin{tikzpicture}[node distance=1em]
node [SeaGreen!80!black] (I) at (0,0) {Large{I}};
begin{scope}[node distance=3em]
foreach x [remember=x as lastx (initially I)] in {N,V,E,S,T}
node (x) [right of=lastx,SeaGreen!80!black] {Large{x}};
end{scope}
pause %here we pause after writing the capital letters
foreach x [remember=x as lastx (initially I)] in {n,d,e,p,e,n,d,e,n,t}
node (x) [below of=lastx] {x};
pause %then we have a pause after each word
foreach x [remember=x as lastx (initially N)] in {e,g,o,t,i,a,b,l,e}
node (x) [below of=lastx] {x};
pause
foreach x [remember=x as lastx (initially V)] in {a,l,u,a,b,l,e}
node (x) [below of=lastx] {x};
pause
foreach x [remember=x as lastx (initially E)] in {s,t,i,m,a,b,l,e}
node (x) [below of=lastx] {x};
pause
foreach x [remember=x as lastx (initially S)] in {m,a,l,l}
node (x) [below of=lastx] {x};
pause
foreach x [remember=x as lastx (initially T)] in {e,s,t,a,b,l,e}
node (x) [below of=lastx] {x};
end{tikzpicture}
``````

which produces:

And what if we want to uncover single letters piecewise? That’s neatly obtained by wrapping the argument of the corresponding `foreach` statement inside curly braces, so we can add a pause after drawing each node:

``````foreach x [remember=x as lastx (initially I)] in {n,d,e,p,e,n,d,e,n,t}{
node (x) [below of=lastx] {x};
pause
}
``````

…though I cannot guarantee your audience will not have dozed off at this point.

That’s it, I hope you had fun and above all that you decided to give Beamer a try 😉