tex in Table headers?

How do I use tex in a table header?

When I do this:

data = [
  {model: 'model1', rSquared: 0.57},
  {model: 'model2', rSquared: 0.34},
]

and then this:

Inputs.table(data, {
  header: {
    rSquared: tex`R^2`
  }
})

the exponent in the resulting header is detached from the R:
https://observablehq.com/d/fc02eb0e7f17d1f5

1 Like

This is a bug in Observable Inputs. This style rule is matching the contents of the TeX element:

The rule should be made more specific, like .__ns__-table > table > thead > th > span.

1 Like

Alternatively, you could use MathJax:

Thank you to @mbostock for the explanation, @mcmcclur for the workaround, and @mootari for posting the bug to GitHub (Table styles affect table cell contents · Issue #241 · observablehq/inputs · GitHub).

1 Like