Adapt pandoc.table column width

The following document provides the following HTML output (HTML only required)

column widths with pandoc

The first columns are wide, and Reducing the width and font size of the table using pandoc.table () did not help here.

How to make the first 2 columns spend less space?

---
output: html_document
---

```{r,echo=FALSE, results="asis"}
library(pander)
mytab = data.frame(col1=1:2, col2=2001:2002, col3="This is a lengthy test that should wrap, and wrap again, and again and again and again")
pandoc.table(mytab)
```
+4
source share
1 answer

pandoc.tablesupports specifying column widths with an argument split.cellsthat can take a prime number or a vector (relative) number / percent. Quick demo:

> pandoc.table(mytab, split.cells = c(1,1,58))

----------------------------------------------------------------------
 col1   col2                            col3                          
------ ------ --------------------------------------------------------
  1     2001  This is a lengthy test that should wrap, and wrap again,
                           and again and again and again              

  2     2002  This is a lengthy test that should wrap, and wrap again,
                           and again and again and again              
----------------------------------------------------------------------

HTML HTML pandoc:

<table>
<col width="9%" />
<col width="9%" />
<col width="77%" />
<thead>
<tr class="header">
<th align="center">col1</th>
<th align="center">col2</th>
<th align="center">col3</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td align="center">1</td>
<td align="center">2001</td>
<td align="center">This is a lengthy test that should wrap, and wrap again, and again and again and again</td>
</tr>
<tr class="even">
<td align="center">2</td>
<td align="center">2002</td>
<td align="center">This is a lengthy test that should wrap, and wrap again, and again and again and again</td>
</tr>
</tbody>
</table>
+8

All Articles