我希望使用以下方法在 PDF 文档中创建表格rmarkdown
, knitr
and pander
。我能够创建一个简单的项目符号列表 https://stackoverflow.com/questions/31011265/how-to-write-bullet-lists-in-a-table-using-rmarkdown-and-pandoc但现在需要该列表中的另一个级别。在下表中,我要求“好评如潮”项目符号成为“提供研讨会...”项目符号的子项目符号。
我遇到的问题与下面的代码行有关mytable
数据帧中Description
柱子。尽管我尝试使用以下命令创建子项目符号所需的 4 个空格\x20
[1],这些空格不会出现 - 因此没有子项目符号(尽管没有显示错误)。我也尝试了最明显的方法,简单地在代码中添加 4 个空格,但没有成功。还尝试设置我的R
包括的选项strip.white = FALSE
,但这也被证明没有帮助(见下文)。
---
title: "xxx"
author: "xxx"
output:
pdf_document:
fig_height: 4
fig_width: 10
highlight: tango
word_document: default
geometry: margin=3cm
---
```{r global_options, include=FALSE, echo=FALSE}
require(knitr)
opts_chunk$set(fig.width=8, fig.height=4, fig.path='figs/', dpi=500,
echo=FALSE, warning=FALSE, message=FALSE, results='hide', strip.white = FALSE)
```
```{r pandoc_options, include=FALSE, echo=FALSE}
require(pander)
panderOptions('digits', 3)
panderOptions('round', 3)
panderOptions('keep.trailing.zeros', TRUE)
panderOptions('keep.line.breaks', TRUE)
```
```{r concepts, echo=FALSE}
mytable = data.frame(
Concept = c("Decoded", "XXX"),
Description = c("* Founded in 2011\ \n* Offers workshops to take people from zero skills and knowledge in programming through to coding a multi-platform app using HTML, CSS and Javascript in a single day\ \n\x20\x20\x20\x20+ Rave reviews", "XXX"),
Website = c("http://decoded.com/uk/","XXX"))
```
``` {r concepts_descriptions, results = 'asis'}
pander::pander(mytable, keep.line.breaks = TRUE, style = 'grid', justify = 'left')
```
参考
[1] 我得到了\x20
暗示来自here https://r.789695.n4.nabble.com/blank-space-escape-sequence-in-R-td3473104.html,尝试后\\s
, \s
, \ \s
, \\\s
等无济于事(建议here https://stackoverflow.com/questions/5992082/how-to-remove-all-whitespace-from-a-string).