【发布时间】:2021-12-19 03:18:54
【问题描述】:
我有一个 R Markdown 文件(又名主文件)。我想通过仅在主文件的 YAML 中编写代码或在 YAML 中引用第二个文件来在页面顶部添加一个徽标(例如,“logo.html”是在主文件的 YAML)。我不想要块或正文中的任何解决方案。通过将代码放在标题中,徽标代码不能成为黑客解决方案。我更喜欢用 R、HTML 和 CSS 编码的解决方案。标志不能掩盖标题。徽标将在多个尺寸的显示器上查看,因此请避免位置:绝对。由于数据表中有大量列,可能会有很多横向滚动。假设所有文件都在 1 个文件夹工作目录中。
这是我迄今为止尝试过的。
第一次尝试:
Main file contains this YAML --
---
title: "test_knit"
output:
html_document:
includes:
before_body: logo.html
---
Second file named logo.html contains --
<img src="logo.png" style="position:relative;top:50%"/>
Third file is the logo in PNG format.
我的第二次尝试:
Main file contains this YAML --
---
title: "test_knit"
output:
html_document:
includes:
before_body: logo.html
---
Second file named logo.html is an html file that was converted from a PNG.
我的尝试渲染 R Markdown 文件并能够成功编织,但它们不显示徽标。我可以看到表格、cmets 和图表,但没有出现徽标。
【问题讨论】:
-
我看到你写的是
includes,而我写的是include。
标签: html css r r-markdown