首页 > 解决方案 > 不同的 HTML 和 PDF 输出格式

问题描述

我正在尝试在 rmarkdown 中创建报告,但我想要的输出形状仅在 HTML 文件中是正确的。当我导出为 PDF 时,格式是不同的。标题在页面中间,作者 1 和 2 之间没有空格,日期在页面中间,等等……你知道为什么会这样吗?我能做些什么来克服这个问题?

---
title: "açoifjwçoifjwçaofijwaçfijo"
author: '1: lululukuku <br> 2: eeeeeeeeeeeee'
date: "`r format(Sys.time(), '%d, %B, %Y')`"
output:
  html_notebook: default
  pdf_document: default
---



<style type="text/css">

h1.title {
  font-size: 38px;
  color: DarkBlack;
  text-align: left;
}
h4.date {
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlack;
  float: right;
}

h4.author {
  font-size: 18px;
  font-family: "Times New Roman", Times, serif;
  color: DarkBlack;
  float: left;
}

div#header {
  overflow: auto;
}

</style>

---

用于渲染的代码:

rmarkdown::render('aaa.Rmd', 'html_document', 'teste.html')
rmarkdown::render('aaa.Rmd', 'pdf_document', 'teste.pdf')

和输出:

HTML:

HTML 图像

PDF:

PDF 图片

标签: rr-markdownknitr

解决方案


推荐阅读