Search code examples
rgtable

How to put exponents (power symbol) in tables made using the gtable package?


tab_header(
    title = expression(Ni^"2+" ~ Remediation),
    subtitle = "Trials 1- 4",
    )

2+ is not shown as a power

I would like to know how to get the 2+ to come as a power.

Here, I tried the expression function, but it does not work.


Solution

  • If it's enough for the "2+" to show up in superscript, you could use the <sup> tag in HTML.

    gt(df) %>%
      tab_header(
        title = html("Ni<sup>2+</sup> ~ Remediation"),
        subtitle = "Trials 1- 4"
      )