我正在编写一份报告,该报告以R Markdown输出到HTML。在此报告中,我添加了Excel表,其中一个具有带有列表的列。
这是示例
---
title: "Readme report"
author: "MM"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
number_sections: true
---
library(dplyr)
library(kableExtra)
df <- structure(list(id = c(1, 2, 3), justification = c(
"1. I want it too look like this \r\n 2. having numbers for each row \r\n 3. and well it still looks nice",
"1. here is where strangeness happens\r\n 2. what happens here \r\n 3. and here",
"1. but then I do this again and number one looks okay \r\n 2. but this looks like an outdented bullet \r\n - i put this indented bullet \r\n 3. and somehow end up like this when i get back to numbered"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-3L))
kable(df, format = "html")%>%
kable_styling(latex_options="scale_down")
我遇到的问题是表的这一部分在输出中存在很大的不一致性,第一行看起来不错,但是随后一切都破裂了。第一行总是很好,但是第二和第三次突破看起来像是一个过时的子弹。我的问题是如何制作此柱制服的格式。我已经阅读了 r Markdown的表节在这里找不到任何答案,并且已经阅读了其他类似的问题及其答案 there 这个示例与我的问题最相似,但是当他使用pander并试图导出到pdf和word时。
我尝试了各种格式,从删除数字和创建所有子弹点,但我仍然获得相同的凹痕格式。如果我删除了所有数字,并且在每行rmarkDown的开头不要放任何数字 - 或 *不一致地对待整列。当我进行 dput
时,我可以看到第一个1.是,但是在此之后,即使在使用 \ r \ n
时,它也会变得不一致,并且没有任何运气。
I am writing a report that outputs to html with R markdown. In this report I'm adding excel tables and one of them has a column with a list.
Here is the example
---
title: "Readme report"
author: "MM"
date: "`r Sys.Date()`"
output:
html_document:
toc: true
toc_float: true
number_sections: true
---
library(dplyr)
library(kableExtra)
df <- structure(list(id = c(1, 2, 3), justification = c(
"1. I want it too look like this \r\n 2. having numbers for each row \r\n 3. and well it still looks nice",
"1. here is where strangeness happens\r\n 2. what happens here \r\n 3. and here",
"1. but then I do this again and number one looks okay \r\n 2. but this looks like an outdented bullet \r\n - i put this indented bullet \r\n 3. and somehow end up like this when i get back to numbered"
)), class = c("tbl_df", "tbl", "data.frame"), row.names = c(NA,
-3L))
kable(df, format = "html")%>%
kable_styling(latex_options="scale_down")

The problem that I was having is that this part of the table there is great inconsistency in the output, the first row it looks fine, but everything breaks afterwards. the first line always turns out fine, but the second and third break looks like an outdented bullet. My question is how to make the format of this column uniform. I have read the tables section of R Markdown: The Definitive Guide and couldn't find any answers here, and have read other similar questions and their answers here this example is the most similar to my question, but as he is using pander and trying to export to pdf and word.
I have tried various formats, from removing the numbers and creating all bullet points and still I get the same indentation formatting. If I remove all numbers and don't put any - or * at the start of each line rmarkdown just treats like one whole column inconsistently. When I do a dput
I can see that the first 1.is but after that it gets inconsistent even when playing around with the \r\n
and haven't had any luck.
发布评论
评论(1)
当我来找出R Markdown中表中的列表时,即使非常相似的答案如何用pandoc编写pdf的子弹列表,但输出不同,不适用于我的问题。然后这个人问
多级项目符号列表问题是他们正在使用的输出IS是使用PANDOC的PDF,我正在输出到HTML。
我用
put
发现我的休息时间是\ r \ n
,而其他人则有\ \ n
,并且通过删除r <
/code>使用它并使用它,我看到的是,取决于。
之后的空间,您可以做出凹痕\ \ \ n1.Observation
在<<代码> \ \ n1。观察确实如此。希望这对某人有帮助,因为我花了整天的时间才能自己解决这个问题!如果有人有任何信息的工作方式,请告诉我!As I came to find out lists within tables in R markdown is not an intuitive business, even though the very similar answer how to write bullet lists for pdf with pandoc but the output is different and does not apply to my question. This person then asked
multi-level bullet lists problem is the output they are working on is for pdf with pandoc, and I'm outputting to HTML.
I found out with
put
that my breaks were with\r\n
while others had\ \n
and by removing ther
this worked and playing with it I saw that depending on the space after the.
that you can make indentations\ \n1.observation
does not give an indentation while\ \n1. observation
does. hope this helps someone as it took me a whole day to figure this out by myself! and if someone has any information how this works please let me know!