rstudio / rmarkdown

Dynamic Documents for R
https://rmarkdown.rstudio.com
GNU General Public License v3.0
2.88k stars 974 forks source link

ioslides_presentation ignores the template option #460

Closed ignacio82 closed 7 years ago

ignacio82 commented 9 years ago

I have a presentation with a personalized template

output: 
    ioslides_presentation:
       template: ./templates/mytemplate.html

But rmarkdown is ignoring that option and using the default template

/usr/lib/rstudio-server/bin/pandoc/pandoc /tmp/RtmpP2Yo3D/EdCenter.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/RtmpP2Yo3D/file6f62a7095b9.html --smart --email-obfuscation none --variable widescreen --variable transition=0 --css styles/MPR_Ioslides_Styles.css --template /usr/local/lib/R/site-library/rmarkdown/rmd/ioslides/default.html --mathjax --variable ioslides-url=file6f62a7095b9_files/ioslides-13.5.1 
/usr/lib/rstudio-server/bin/pandoc/pandoc /tmp/RtmpP2Yo3D/EdCenter.utf8.md --to ioslides_presentation.lua --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/RtmpP2Yo3D/ioslides-output6f66dbcb94b.html 

Is this a bug or am I doing something wrong?

Thanks a lot!

jjallaire commented 9 years ago

It's because the template is a property of the ioslides_presentation format (and therefore needs to be indented below it rather than at the same level).

On Sat, Jun 27, 2015 at 2:53 AM, ignacio82 notifications@github.com wrote:

I have a presentation with a personalized template

output: ioslides_presentation: template: ./templates/mytemplate.html

But rmarkdown is ignoring that option and using the default template

/usr/lib/rstudio-server/bin/pandoc/pandoc /tmp/RtmpP2Yo3D/EdCenter.utf8.md --to html --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/RtmpP2Yo3D/file6f62a7095b9.html --smart --email-obfuscation none --variable widescreen --variable transition=0 --css styles/MPR_Ioslides_Styles.css --template /usr/local/lib/R/site-library/rmarkdown/rmd/ioslides/default.html --mathjax --variable ioslides-url=file6f62a7095b9_files/ioslides-13.5.1 /usr/lib/rstudio-server/bin/pandoc/pandoc /tmp/RtmpP2Yo3D/EdCenter.utf8.md --to ioslides_presentation.lua --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/RtmpP2Yo3D/ioslides-output6f66dbcb94b.html

Is this a bug or am I doing something wrong?

Thanks a lot!

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460.

ignacio82 commented 9 years ago

@jjallaire it is indented, makes no difference

Imgur

jjallaire commented 9 years ago

Okay, sorry about the mixup there.

ioslides_presentation doesn't actually support custom templates (it doesn't have a template argument). This is mostly because ioslides is not a format natively supported by pandoc so the built in template has a lot of special sauce.

All of that said, you could workaround this by creating a new format that just calls ioslides_presentation and then modifies the pandoc args to point to your template.

On Sat, Jun 27, 2015 at 11:14 AM, ignacio82 notifications@github.com wrote:

@jjallaire https://github.com/jjallaire it is indented, makes no difference

Imgur http://i.imgur.com/b7qeTgW.png

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-115991270.

ignacio82 commented 9 years ago

@jjallaire I think http://rmarkdown.rstudio.com/ioslides_presentation_format.html says that ioslide supports template: "You can also replace the underlying pandoc template using the template option:"

If that is incorrect, can you point me in the right direction to create a new format? If I go that route, will I be able to upload the presentation to shinyapps.io ??

Right now what I'm doing is replacing /usr/local/lib/R/site-library/rmarkdown/rmd/ioslides/default.html in my computer with my file. But, that workaround does not work with shinyapps.io nor is very convinient for most users

Thanks!

jjallaire commented 9 years ago

Unfortunately the docs are wrong there (I'll update them).

Here are the docs on creating a custom format: http://rmarkdown.rstudio.com/developer_custom_formats.html

Hopefully you can sort out what you need from there (the resulting template should indeed work on shinyapps.io).

On Sat, Jun 27, 2015 at 11:34 AM, ignacio82 notifications@github.com wrote:

@jjallaire https://github.com/jjallaire I think http://rmarkdown.rstudio.com/ioslides_presentation_format.html says that ioslide supports template: "You can also replace the underlying pandoc template using the template option:"

If that is incorrect, can you point me in the right direction to create a new format? If I go that route, will I be able to upload the presentation to shinyapps.io ??

Right now what I'm doing is replacing /usr/local/lib/R/site-library/rmarkdown/rmd/ioslides/default.html in my computer with my file. But, that workaround does not work with shinyapps.io nor is very convinient for most users

Thanks!

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-115999060.

ignacio82 commented 9 years ago

one more question. Can you point me to the ioslide format file? It will probably make sense to use it as my starting point.

Thanks a lot!

ignacio82 commented 9 years ago

I was able to use this repository as my starting point and modify ioslides_presentation.R to change the theme. Right now I'm using an absolute path instead of a relative path. That is:

 args <- c(args,
            "--template",
            pandoc_path_arg("/home/ignacio/MySlides/inst/rmd/ioslides/template.html"))

Where MySlides is the package that I created based on this one. Can you tell me how to change that to a relative path?

Thanks a lot!

jjallaire commented 9 years ago

You can use the system.file function as a way of creating a relative path:

system.file("rmd/ioslides/template.html", package="MySlides")

On Sat, Jun 27, 2015 at 10:34 PM, ignacio82 notifications@github.com wrote:

I was able to use this repository as my starting point and modify ioslides_presentation.R to change the theme. Right now I'm using an absolute path instead of a relative path. That is:

args <- c(args, "--template", pandoc_path_arg("/home/ignacio/MySlides/inst/rmd/ioslides/template.html"))

Where MySlides is the package that I created based on this one. Can you tell me how to change that to a relative path?

Thanks a lot!

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-116137021.

ignacio82 commented 9 years ago

@jjallaire Inside 'skeleton' I have a folder 'images' and inside that folder 'partner.png'. So when I create a rmarkdown using my template that folder and file are automatically created. is there a way of using relative path to that file?

Basically, I'm trying to modify this part of the default.html:

$if(logo)$
    slides > slide:not(.nobackground):before {
      font-size: 12pt;
      content: "";
      position: absolute;
      bottom: 20px;
      left: 60px;
      background: url($logo$) no-repeat 0 50%;
      -webkit-background-size: 30px 30px;
      -moz-background-size: 30px 30px;
      -o-background-size: 30px 30px;
      background-size: 30px 30px;
      padding-left: 40px;
      height: 30px;
      line-height: 1.9;
    }
$endif$

My goal is to have partnet.png in the bottom right corner and $logo$ in the bottom left.

Thanks a lot!

jjallaire commented 9 years ago

Yes, just set the URL to images/partner.png rather than $logo$

On Wed, Jul 1, 2015 at 4:28 AM, ignacio82 notifications@github.com wrote:

@jjallaire https://github.com/jjallaire Inside 'skeleton' I have a folder 'images' and inside that folder 'partner.png'. So when I create a rmarkdown using my template that folder and file are automatically created. is there a way of using relative path to that file?

Basically, I'm trying to modify this part of the default.html:

$if(logo)$ slides > slide:not(.nobackground):before { font-size: 12pt; content: ""; position: absolute; bottom: 20px; left: 60px; background: url($logo$) no-repeat 0 50%; -webkit-background-size: 30px 30px; -moz-background-size: 30px 30px; -o-background-size: 30px 30px; background-size: 30px 30px; padding-left: 40px; height: 30px; line-height: 1.9; } $endif$

My goal is to have partnet.png in the bottom right corner and $logo$ in the bottom left.

Thanks a lot!

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-117403893.

ignacio82 commented 9 years ago

It doesn' t work. Can you recommend me a way to debug this? Sorry to be a pain, this is very new to me.

If I do url("$ioslides-url$/images/other.png") for example, the logo changes to other.png but that file is inside the library instead of the project folder, and therefore an user cannot change it by just replacing a file.

jjallaire commented 9 years ago

Sorry I don't have time to debug this right now :-\

On Wed, Jul 1, 2015 at 12:14 PM, ignacio82 notifications@github.com wrote:

It doesn' t work. Can you recommend me a way to debug this? Sorry to be a pain, this is very new to me

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-117581268.

ignacio82 commented 9 years ago

I understand, thanks for all the help!

jgellar commented 8 years ago

@jjallaire sorry to revive an old thread, i am having the same issue where I would like to set my own template for ioslides_presentation. In your second reply above, you seem to indicate that you can choose a new template by setting the pandoc_args, i.e.,

  temp <- rmarkdown::pandoc_path_arg(system.file("rmd/ioslides/default.html",
                                                 package="mypackage"))
  rmarkdown::ioslides_presentation(pandoc_args = c("--template", temp), ...)

However, the problem is that ioslides_presentation adds its own "--template" to the pandoc call, so now two "--template" options are specified. Is there a way to avoid this without re-writing a new ioslides_presentation?

btw, it would be convenient and simple to modify ioslides_presentation() to allow for a template argument.

jjallaire commented 8 years ago

No, you can't create your own template for ioslides_presentation because that is a custom format written with Lua (it's not a built-in pandoc format).

On Fri, Nov 13, 2015 at 8:39 AM, jgellar notifications@github.com wrote:

@jjallaire https://github.com/jjallaire sorry to revive an old thread, i am having the same issue. In your second reply above, you seem to indicate that you can choose a new template by setting the pandoc_args, i.e.,

temp <- rmarkdown::pandoc_path_arg(system.file("rmd/ioslides/default.html", package="mypackage")) rmarkdown::ioslides_presentation(pandoc_args = c("--template", temp), ...)

However, the problem is that ioslides_presentation adds its own "--template" to the pandoc call, so now two "--template" options are specified. Is there a way to avoid this without re-writing a new ioslides_presentation?

— Reply to this email directly or view it on GitHub https://github.com/rstudio/rmarkdown/issues/460#issuecomment-156433313.

yihui commented 7 years ago

Closing since the original issue seems to have been resolved. There are a couple of of more issues, but I guess they are unlikely to be addressed in the future. You may try some other packages such as xaringan and revealjs and see if you like them. More info: https://github.com/rstudio/rmarkdown/pull/404#issuecomment-326354500

github-actions[bot] commented 4 years ago

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.