也适用于 LaTeX pdf 的 R Markdown 水平规则?

R Markdown horizontal rule that will also work with LaTeX pdf?

我知道 *** 是 Pandoc 的 Markdown 水平线。这条水平线在 HTML 上看起来不错,但如果我将我的 Markdown 编织成 pdf,则水平线仅占 pdf 宽度的一半,并且居中。这种组合只会让水平线看起来很丑。

如何在我的 R Markdown 中正确放置一条水平线,使其能够正确呈现 HTML 和 pdf? Properly == full length/full width。当我在做的时候,我可以格式化水平规则(颜色、粗细等)而不涉及太多我一无所知的 CSS 吗?

创建一个 tex 文件,比如 header.tex,包含:

\let\oldrule=\rule
\renewcommand{\rule}[1]{\oldrule{\linewidth}}

然后在您的 Rmd 文件中:

---
title: "test"
author: "Stéphane Laurent"
date: "30 mars 2018"
output: 
  pdf_document:
    includes:
      in_header: header.tex
---