Can an R vignette title include an image?

Viewed 54

I would like to add my package's hex logo to the title line of its package vignette.

I am mostly clueless about CSS but I thought this could work:


---
title: "x"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{x}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{css}
h1::after {
   content: "";
   height: 3063px;
   width: 3550px;
   float: right;
   background-image: url("logo.png");
   background-size: contain;
   background-position: center center;
   background-repeat: no-repeat;
 }

It leaves a space but the logo does not show up.

Can anybody spot what I am doing wrong or does anybody have a snippet for adding a graphic to the title line of a vignette?

1 Answers

I don't know how flexible it is about placement, but just adding a Markdown image link to the title entry worked for me. That is, set your YAML to something like this:

---
title: "Vignette Title ![alt text](../man/figures/logo.png)"

The path to the image assumes that the image is in the package man/figures directory, and that the vignette is being produced in the inst/doc directory and installed into doc.

Possibly you could put the figure in inst/doc, and refer to it without any path specified, but I didn't try that.

Related