我不知道如何單獨使用markdown來做到這一點,它可能涉及創建某種模板。我從來沒有追求過這樣的解決方案,所以我不能確定它是否可行。我已經推行了其他解決方案,可以爲我生成必要的LaTeX代碼HTML。下面的代碼是一個工作的RMD,它將針對PDF和HTML文件。
---
title: "Untitled"
output:
pdf_document: null
html_document: null
header-includes:
- \usepackage{amssymb}
- \usepackage{arydshln}
- \usepackage{caption}
- \usepackage{graphicx}
- \usepackage{hhline}
- \usepackage{longtable}
- \usepackage{multirow}
- \usepackage[dvipsnames,table]{xcolor}
---
```{r}
library(pixiedust)
options(pixie_float = FALSE)
DF <- data.frame(table_header = c("Table Cell", "Cell 3"),
second_header = c("Cell 2", "Cell 4"),
stringsAsFactors = FALSE)
Base <-
dust(DF) %>%
medley_bw() %>% mimics the default bordering of standard markdown table
sprinkle_colnames("Table Header", "Second Header") %>%
sprinkle_table(pad = 3) # padding for HTML tables
# print the table with vertical line between columns
Base %>%
sprinkle_table(cols = 1,
border = "right")
# print the table with horizontal line between rows
Base %>%
sprinkle(rows = 1,
border = "bottom")
```
產生的表具有以下外觀
這是偉大的!謝謝! – asosnovsky