以下文档提供以下HTML输出(仅需要HTML)
第一列是广泛的,Reduce cell width and font size of table using pandoc.table()在这里没有帮助。
如何强制前两列浪费更少的空间?
---
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)
```
答案 0 :(得分:11)
pandoc.table
通过split.cells
参数支持specifying the width of columns,该参数可以采用简单的数字或(相对)数字/百分比的向量,快速演示:
> 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
----------------------------------------------------------------------
使用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>