First-line paragraph indenting in PDFs using R Markdown

我只是一个虾纸丫 提交于 2019-12-04 21:45:25

问题


I'm hoping this is a question with a simple answer. I am using Rmarkdown/knitr to author a PDF document (in RStudio). Many LaTeX classes (like article) automatically indent the first line of a paragraph of text, but Rmarkdown does not, nor can I figure out a way to do so.

Here's a simple example:

---
title: "minimal"
author: "prison rodeo"
output: pdf_document  
---

This is an R Markdown document. 

I would like this paragraph to be first-line indented, but it is not.

Using > indents the entire paragraph, which is not what I'm looking for. I've tried spaces/tabs at the beginning of each paragraph, and using \indent; neither seems to work. Any ideas?


回答1:


The default Pandoc template includes an indent argument. If set to true, paragraphs start with an indentation.

----
title: "Title"
author: "Me"
output: pdf_document
indent: true
----



回答2:


I believe the following in your YAML header will work the same and has the advantage of still compiling should you decide to knit your document to an HTML file (though, I haven't tested this).

----
title: "Title"
author: "Me"
header-includes:
   - \setlength\parindent{24pt}
output:
    pdf_document
----



回答3:


If what you're after happens to be the default settings in other regards as well, you might also be interested in setting the \parskip option to its default setting, since it is otherwise set to {6pt plus 2pt minus 1pt}

header-includes:
   - \setlength\parindent{24pt}\setlength{\parskip}{0.0pt plus 1.0pt}


来源:https://stackoverflow.com/questions/29460112/first-line-paragraph-indenting-in-pdfs-using-r-markdown

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!