MangoTheCat / rmdshower

R Markdown template for shower
http://mangothecat.github.io/rmdshower/skeleton.html
Other
147 stars 42 forks source link

Specifying text at fixed position on a slide. #27

Open sje30 opened 8 years ago

sje30 commented 8 years ago

Hello, is there a preferred way to position text/image at a fixed point on a slide? I normally write citations or other footnotes in bottom right corner. Thanks to this page:

https://www.uvm.edu/rsenr/vtcfwru/R/fledglings/14_Slideshows.html

I can do the following on a slide

## absolute positioning

<div style="font-size: 60%; position: absolute; right: 10%;   width: fit-content; height: fit-content; border:3px solid blue; top:90%; z-index:10">
Text goes here
</div>

but that's a lot of markup to repeat each time. I thought I could create my own div.absolute in a .css file, but this doesn't seem to put the text in the bottom right hand corner. What's missing?

## Version 2

<style>
div.myabsolute {
    font-size: 60%
    position: fixed;
    top: 90%;
    right: 10%;
    width: fit-content;
    height: fit-content;
    border: 1px solid #73AD21;
}
</style>

<div class="myabsolute">Wassle et al (1981)</div>

Thanks!

sje30 commented 8 years ago

Flexibility of R to the rescue... this is an R-based solution that seems to work for me:

By defining an R function thus:

pbr = function(text) {
  x = '<div style="font-size: 60%; position: absolute; right: 5%;   width: fit-content; height: fit-content; border:3px solid blue; top:90%; z-index:10">'
  sprintf("%s%s</div>", x, text)
}

(pbr = position bottom right)

then I can do the following:

## version 4

and this is all the weather

`r pbr("citation goes here")`