Reduce cell width and font size of table using pandoc.table()

前端 未结 2 791
心在旅途
心在旅途 2021-02-02 12:35

I\'m using knitr and pander to make a table in a markdown file. I\'m converting the markdown file to a PDF using Pandoc from within R.

This cod

2条回答
  •  名媛妹妹
    2021-02-02 13:11

    If you do not want to split the table into multiple parts based on its width, you can specify that directly in split.tables parameter with pandoc.table or more generally in table.split.table in panderOptions. E.g.:

    > pandoc.table(head(iris), split.table = Inf)
    
    -------------------------------------------------------------------
     Sepal.Length   Sepal.Width   Petal.Length   Petal.Width   Species 
    -------------- ------------- -------------- ------------- ---------
         5.1            3.5           1.4            0.2       setosa  
    
         4.9             3            1.4            0.2       setosa  
    
         4.7            3.2           1.3            0.2       setosa  
    
         4.6            3.1           1.5            0.2       setosa  
    
          5             3.6           1.4            0.2       setosa  
    
         5.4            3.9           1.7            0.4       setosa  
    -------------------------------------------------------------------
    
    > panderOptions('table.split.table', 300)
    > pander(head(iris))
    
    -------------------------------------------------------------------
     Sepal.Length   Sepal.Width   Petal.Length   Petal.Width   Species 
    -------------- ------------- -------------- ------------- ---------
         5.1            3.5           1.4            0.2       setosa  
    
         4.9             3            1.4            0.2       setosa  
    
         4.7            3.2           1.3            0.2       setosa  
    
         4.6            3.1           1.5            0.2       setosa  
    
          5             3.6           1.4            0.2       setosa  
    
         5.4            3.9           1.7            0.4       setosa  
    -------------------------------------------------------------------
    

    About fontsize: Pandoc's markdown do not have any special syntax for that, so you might use LaTeX markup for your pdf. E.g. just issue a \footnotesize directive before your table. See possible font sizes for more details: http://en.wikibooks.org/wiki/LaTeX/Fonts#Sizing_text

提交回复
热议问题