stackinator
stackinator

Reputation: 5819

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

I am aware that *** is Pandoc's Markdown for a horizontal rule. This horizontal line looks good on HTML, but if I knit my Markdown into a pdf the horizontal rule only runs half the width of the pdf, and it is centered. This combination just makes the horizontal rule look plain ugly.

How do I properly put a horizontal rule in my R Markdown that can render properly to both HTML and pdf? Properly == full length/full width. And while I'm at it, can I format the horizontal rule (color, thickness, etc.) without getting into much CSS which I know nothing about.

Upvotes: 5

Views: 2594

Answers (1)

Stéphane Laurent
Stéphane Laurent

Reputation: 84529

Make a tex file, say header.tex, containing:

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

Then in your Rmd file:

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

Upvotes: 6

Related Questions