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

試著忘記壹切 提交于 2019-12-07 12:36:52

问题


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.


回答1:


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
---


来源:https://stackoverflow.com/questions/49575945/r-markdown-horizontal-rule-that-will-also-work-with-latex-pdf

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