Subscripts in Haskell Diagrams

Posted on March 31, 2014

Not sure what the official way of doing subscripts in Diagrams is, but surprisingly this tiny piece of code does the job:

subs :: String -> String -> Diagram B R2
subs x y = norm ||| strutX (0.05) ||| sub
  where
    norm = stroke $ textSVG x 1
    sub = stroke $ textSVG y 1 # translateY (-0.35) # scale 0.55

For example,

subs "Unicode: X₈ / Haskell: X" "8"

Why not just use the unicode subscripts? Simple: not all subscript characters are defined in the unicode.