In this episode of Unlocking LaTeX Graphics, applied mathematician Tammy Kolda demonstrates how to draw a row of color-coded, filled text nodes in TikZ. The motivating example is LLM tokenization: she recreates the output of the Tokenizer Playground for the sentence "TikZ is a powerful tool for LaTeX graphics," including explicit space tokens. She builds a foreach loop with the TikZ positioning library to place each token node to the right of the previous one, cycling through five fill colors and zeroing out inner sep for tight boxes. The key challenge is that different letters have different ascenders and descenders, causing inconsistent node heights; she shows why minimum height alone fails and explains how the text height and text depth options, set in ex units so they scale with font size, produce uniform heights and aligned baselines. She also demonstrates eliminating inter-node gaps by setting line width to zero and adding a small inner xsep with a compensating xshift.
00:00 Welcome & Introduction
01:25 Document Preamble
01:56 Main Loop
04:38 Misalignment Problem
05:13 Minimum Height Doesn't Fix It
05:37 Text Height & Text Depth
07:41 Fixing the White Space Between Nodes
08:44 Thanks for Watching
Key terms: texlatex, tikz, text nodes, node alignment, text height, text depth, foreach loops, positioning library, tokenization
Other Episodes
TikZ positioning library: • Advanced Node and Coordinate Positioning w...
Node sizing: • Node Sizing in TikZ (Unlocking LaTeX Graph...
Foreach loops: • Mastering Loops in TikZ: A LaTeX Tutorial ...
Aligning text in TikZ nodes: • Aligning Text in TikZ Nodes (Mini 6 from E...
Today's Document on Overleaf: https://www.overleaf.com/read/cwbnfnj...
Unlocking LaTeX Graphics Book: https://latex-graphics.com
Purchase Book on Amazon: https://amzn.to/3z76nwb