rlatexkable

Is a kable() col heading with side by side special symbols possible?


This is not a question about printing distinct kable() tables side by side.

Working in Markdown, PDF output. I have a column heading that is the Greek symbol delta. I want to add a column the heading of which is the Greek symbol delta side-by-side with the % symbol, but I cannot figure out how to achieve this.

Here's what I've got:

test_results <- dplyr::data_frame ('First Score'=c(42.35), 'Second Score'=c(90.4), '$\\Delta$'=c(48.05))

kable(test_results, align = "ccc", caption = "Test Results Data", format="latex", position = "h!", escape = FALSE) %>% row_spec(0,bold=TRUE) %>% 
kable_styling()

Thanks for any help!


Solution

  • Not really sure where you want the % sign, so assuming it is required after the delta, try this.

    ```{r }
    
    library(kableExtra)
    library(tibble)
    
    test_results <- tibble ('First Score'=c(42.35), 
                                   'Second Score'=c(90.4), 
                                   '$\\Delta$\\%'=c(48.05))
    
    kable(test_results, 
          align = "ccc",
          caption = "Test Results Data", 
          format="latex", 
          position = "h!", 
          escape = FALSE) |> 
      row_spec(0,bold=TRUE) |>  
      kable_styling()
    
    
    ```
    

    Which gives:

    enter image description here