Reputation: 72838
HTML is working fine in the rownames as well as in the caption and in the footer. Contrary to intuition in the colnames it's not working. How could I achieve equivalent formatting within the colnames?
mx <- matrix(1:9, nrow = 3,
dimnames = list(c("<i>α<sub>i</sub></i>",
"<i>β<sub>i</sub></i>",
"<i>γ<sub>i</sub></i>"),
c("<i>Φ<sub>i</sub></i>",
"<i>Σ<sub>i</sub></i>",
"<i>Τ<sub>i</sub></i>")))
library(tableHTML)
tableHTML(mx
, widths = rep(20, 4)
, border = 0
, rownames = TRUE
, caption = "<b>Table 1: <i>Φ<sub>i</sub></i> and their <i>Σ<sub>i</sub></i> and <i>Τ<sub>i</sub></i></b>"
, footer = "<i>Note: </i><i>Φ<sub>i</sub></i>. Do re mi fa so la."
, collapse = "separate"
, spacing = "5px"
, theme = 'scientific'
)
Upvotes: 2
Views: 97
Reputation: 37879
tableHTML
will escape >
and <
by default (HTML tags open and close where they shouldn't if they are contained within the data). So, you can just turn escaping off using the escape
argument:
library(tableHTML)
tableHTML(mx
, widths = rep(50, 4)
, border = 0
, rownames = TRUE
, caption = "<b>Table 1: <i>Φ<sub>i</sub></i> and their <i>Σ<sub>i</sub></i> and <i>Τ<sub>i</sub></i></b>"
, footer = "<i>Note: </i><i>Φ<sub>i</sub></i>. Do re mi fa so la."
, collapse = "separate"
, spacing = "5px"
, escape = FALSE
, theme = 'scientific'
)
Upvotes: 2