Guillermo Perez
Guillermo Perez

Reputation: 123

How do I have a floating image in Rmarkdown html output?

I have a rmarkdown file that has a html output. I need to have my companies logo floating at the top. How would I do it? Same as the floating table of contents that rmarkdown has.

Upvotes: 1

Views: 1469

Answers (2)

Alexandre Lima
Alexandre Lima

Reputation: 145

You can use this css script

`<script> $(document).ready(function() {
 $head = $('#header');
 $head.prepend('<img src=\"logo.jpg\" style=\"float: right;width: 200px;\"/>')}) </script>`

Upvotes: 0

neilfws
neilfws

Reputation: 33772

You can put HTML into RMarkdown files. So you can just wrap your image in a div with the appropriate style CSS. Something like:

<div style="position: fixed; top: 0; right: 0;">
  ![](mylogo.png)
</div>

to have float at top-right. You may also need to position other elements so as the logo does not obscure them.

Upvotes: 2

Related Questions