如何修复Rmarkdown手册表中的渐进式缩进?

时间:2019-07-18 17:50:27

标签: r r-markdown kable kableextra

我正在向Rmarkdown文档添加多个手册表。当我编织成HTML时,第一个之后的每个后续表都会缩进,逐渐增加。我a)不明白为什么会这样,并且b)非常希望它不会发生。

我尝试使用Pandoc的管道框架将表作为纯Rmarkdown文本输入。我尝试将管道框架Pandoc表放入R块中。目前,我正在使用tidyverse软件包中的tribble函数,并通过kablekable_styling进行格式化。

---
title: "2.2 EICRP Codebook"
date: "`r Sys.Date()`"
output:
  html_notebook: default
  word_document: default
---
knitr::opts_chunk$set(echo = FALSE)

if (!require(pacman)) {
     install.packages("pacman", repos = "http://cran.us.r-project.org")
     require(pacman)
}

p_load(here, 
       knitr, 
       kableExtra,
       tidyverse)

rm(list = ls())
A.1。您如何以1到5的比例来描述您的环境行为和行为?

一些文本。

tribble(
  ~"QA01", ~"Value", ~"Label", 
  "01", "1", "Very Unsustainable", 
  "02", "2", "Unsustainable", 
  "03", "3", "Neither Sustainable nor Unsustainable", 
  "04", "4", "Sustainable", 
  "05", "5", "Very Sustainable"
) %>%
  kable() %>%
  kable_styling()

A2。在过去的两年中,您是否参加了以下活动(请勾选所有适用项)

一些文本。

tribble(
  ~"QA02_01", ~"Value", ~"Label", 
  "01", "0", "No", 
  "02", "1", "Any Environmentally Sustainable Action"
) %>%
  kable() %>%
  kable_styling()

tribble(
  ~"QA02_02", ~"Value", ~"Label", 
  "01", "0", "No", 
  "02", "1", "Environmental Activism"
) %>%
  kable() %>%
  kable_styling()

tribble(
  ~"QA02_03", ~"Value", ~"Label", 
  "01", "0", "No", 
  "02", "1", "Neither"
) %>%
  kable() %>%
  kable_styling()

Apparently I'm not allowed to add images yet, but if you click here you'll see what I mean

第二个代码块中的表带有附加的缩进格式。


更新:

我已经使用column_spec函数实现了变通方法,但是我仍然想知道为什么会这样。

0 个答案:

没有答案