2014-11-17 2 views
4

아래의 문서는 다음과 같은 HTML 출력을 제공합니다에게 적응가 pandoc.table 열 너비

column widths with pandoc

첫 번째 열 방식 넓은 (HTML 만 필요), 그리고 Reduce cell width and font size of table using pandoc.table() 여기에 도움이되지 않습니다.

첫 번째 2 열을 더 적은 공간을 낭비하게하려면 어떻게해야합니까?

--- 
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) 
``` 

답변

8

pandoc.table 단순한 숫자 또는 벡터를 취할 수 split.cells 인수 통해 specifying the width of columns 지원 (상대) 번호/비율 빠른 데모 :이 변환 후 다음 HTML 결과

> 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에 위의 마크 다운은 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> 
+0

감사합니다. 좀 더주의 깊게 읽어야합니다 : split.cells "벡터로도 제공 될 수 있습니다" –