【问题标题】:Indent without adding a bullet point or number in RMarkdown缩进而不在 RMarkdown 中添加项目符号或数字
【发布时间】:2017-11-03 02:25:56
【问题描述】:

我想制作一个缩进列表,但我不希望它有项目符号或数字。我在 RStudio 中使用 Rmarkdown,并编织到 html。

#### bla bla bla  

* Example indented line with bullet point  
    * Another indent with another bullet point  
* Yea this is good except for the stupid bullets!  

1. Example indented line with numbers  
    * sure and an indent with a bullet too  
2. But there's these stupid numbers now!  

  two spaces doesn't indent at all  
    or nest indent with 4  
  yea still no indent with 2.  

    four spaces ALSO doesn't indent  
      just makes some stupid code
    why do you hate indents rmd??

【问题讨论】:

  • "你为什么讨厌缩进 rmd?"因为 Markdown 是关于语义,而不是表示。你的缩进是什么意思?根据您想要的语义适当地标记它们,然后使用 CSS 为它们设置样式,如下所示。

标签: r html-lists markdown knitr r-markdown


【解决方案1】:

这可以使用 R Markdown 语法内置的Line Blocks 来实现。如果你想让缩进得到尊重,你可以用|开始一行。

这种方法适用于多种输出格式,不需要任何额外的 CSS 样式:

---
output:
  html_document: default
  pdf_document: default
---

Here is some text with no indentation

|    A list
|         A sublist
|         Sublist Item 2
|         Sublist Item 3

【讨论】:

  • 到目前为止,最简单的解决方案。
  • 在 stackexchange 上格式化时这似乎不起作用。有什么办法让它在这里工作?
  • @Ben 这种格式化实际上是通过 Pandoc 完成的,如链接中所述:“Pandoc 理解 John Gruber 的 Markdown 语法的扩展和略微修改的版本。”。它在呈现 Markdown 之前处理数据。所以不能在 SE 上使用它
【解决方案2】:

如果您想更改列表的外观并输出到 HTML,请使用 css:

---
title: "ListTest"
output: html_document
---

<style>
.nobullet li {
  list-style-type: none;
}
</style>

<div class="nobullet">
* This list
* Doesn't have bullets
</div>

* This list 
* Is normal

这不适用于其他输出格式。

【讨论】:

    猜你喜欢
    • 2018-04-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-12
    • 2014-12-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多