1

I am using the pander::pander function to make some tables in a knitted latex document. I want the rows to be left justified and the column names to be centered.

library(pander)
library(dplyr)

tibble(`column name` = c("long text string", "* hi")) %>% 
    pander(
      keep.line.breaks = TRUE, 
      style = 'grid', 
      missing = '', 
      split.table = Inf,
      justify = 'left'
      )

left justified pander output

Does the pander function have an argument to center column names? I am having trouble finding it in the documentation or anywhere else online.

John-Henry
  • 1,556
  • 8
  • 20

1 Answers1

1

You can try using pandoc.table :

tibble(`column name` = "long text string") %>% 
  pandoc.table()

#------------------
#   column name    
#------------------
# long text string 
#------------------
Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
  • hmm I have a bullet point in my table, which isn't parsing correctly when I use this method -- I'll update the question to reflect that – John-Henry Dec 28 '20 at 15:46
  • 1
    How do you get the output to be shown as you have in your question? For me the output is just printed in the console. Do you write it in markdown and then knit the file? – Ronak Shah Dec 29 '20 at 04:20
  • yes, i've been knitting. Are you able to reproduce this example? – John-Henry Dec 29 '20 at 05:16
  • 1
    Yes, after going though the documents I couldn't find a way to have different alignment for column names and value. – Ronak Shah Dec 29 '20 at 05:24