jimhester / knitrBootstrap

A framework to create bootstrap styled HTML reports from knitr Rmarkdown.
Other
274 stars 61 forks source link

Title in YAML header #173

Closed nachti closed 8 years ago

nachti commented 9 years ago

Trying to get a title using title in YAML (as described here) is not successful -- I can't find the title anywhere (rmarkdown::render('test.Rmd', 'knitrBootstrap::bootstrap_document')).


---
output:
  knitrBootstrap::bootstrap_document:
    title: "Test file"
    theme: amelia
    highlight: sunburst
    theme.chooser: TRUE
    highlight.chooser: TRUE

---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents.

If I use the following lines instead to knit a standard html document (rmarkdown::render('$(FILE).Rmd', 'html_document')), everything is fine:


---
title: "Test file"
author: "Gerhard Nachtmann"
date: '`r Sys.Date()`'
output:
  html_document:
    theme: united
    toc: yes
  pdf_document:
    toc: yes
  knitrBootstrap::bootstrap_document:
#    title: 'Test file' # does not work
    theme: 'readable' # boot_style
    highlight: 'google code' # code_style

---

This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents.

Do you know what's wrong there? ~g

humburg commented 9 years ago

It appears that the title is only added to the header but not the body. If you look at the generated HTML file you should be able to see a <title> tag with the specified title. Your browser will should display that as the title of the window/tab. It looks like that is the intended behaviour but it would indeed be nice to get this also included in the body of the page, maybe wrapped in a .page-header div.

nachti commented 9 years ago

It's not just the title - author and date are also missing in the body of the HTML document. Peter, the <title> is correct, but it shouldn't differ from the standard html_document. I generate my outputs (html_document and knitrBootstrap::bootstrap_document and pdf_document) from the same source using a Makefile. If I insert tille & co extra after the YAML header, it would be twice in the other documents ...

humburg commented 9 years ago

I completely agree, that information should be included in the body of the generated web page, just like with the other formats. Using the version of knitrBootstrap from #68 it seems that the title, author and date are added to the page but are hidden. Not sure what the reasoning behind this is.

humburg commented 9 years ago

This now works in #68 so this issue can probably be closed.

nachti commented 9 years ago

@humburg: After installing knitrBootstrap using devtools::install_github('jimhester/knitrBootstrap@rmarkdown_template') I get the following Error

rmarkdown::render('docu.Rmd', 'knitrBootstrap::bootstrap_document', output_file = 'docu_bt.html')
Error in match(x, table, nomatch = 0L) :
  argument "pandoc_args" is missing, with no default
Calls: <Anonymous> ... html_document_base -> check_pandoc_args -> %in% -> match
Execution halted
humburg commented 9 years ago

@nachti: Looks like a recent change I submitted broke that, apologies. It should now be fixed.

nachti commented 9 years ago

@humburg Thanks. Title etc. are working now using your branch, but the style is quite different to the original: Margins cut the text (particularly code blocks) and the dynamic TOC at the right side is missing.

humburg commented 9 years ago

@nachti It isn't really my branch. The way I understand it is basically the development branch for the next version of knitrBootstrap (and existed long before I started contributing to it). This now builds on top of _rmarkdown::htmldocument so some things have changed a bit (the discussion on #68 has some more details). The TOC is still there though. Are you including a toc option in your yaml front matter?

It is true that the code blocks are slightly wider than the text (15px each side, I think). The easiest fix for that would be to include some custom CSS adjust the styling to something you find more appealing.

nachti commented 9 years ago

I see. Thanks for the info. If I include the TOC in the YAML header explicitly, it's present in the output HTML, but on the left side overlaying the text. This was quite better in the master branch.

jimhester commented 9 years ago

Could you make a gist with an example Rmd file that exhibits the issues you are describing? I will figure out where the error is.

nachti commented 9 years ago

@jimhester I found out, that the problem is caused by a code block within an enumeration. https://gist.github.com/nachti/8b495f1d25b34335de8a If I insert a blank line before the code block (after Some code) it is working, but the block is still not indented correctly. Using html_document, everything is as expected.

Another thing: In my git repo I found a folder <filename>_files containing the pictures, styles etc., which is different to the master branch. Is there a possibility to include these stuff again (self_contained: true - which should be the default - did not work)

ivannp commented 8 years ago

Title still doesn't show up. All the examples use a title coming from the document itself, aka:

# Cars example #

Try using "title" in the YAML, and you will see, the title doesn't show up. With regular knitr, the following works:

---
title: "KnitrBootstrap Test"
author: Holly Molly
date: "January 31, 1016"
output: html_document
---

knitr-good

With knitrBootstrap, I can't find a variation that works. For example:

---
author: Holly Molly
date: "January 31, 1016"
output:
    knitrBootstrap::bootstrap_document:
    title: "KnitrBootstrap Test"
    theme: amelia
    highlight: sunburst
    theme.chooser: TRUE
    highlight.chooser: TRUE
---

Produces no title, no author nothing.

Tried the latest version as well as the CRAN version.

humburg commented 8 years ago

@ivannp, could you confirm whether you have tried this with the _rmarkdowntemplate branch? That's what I would consider the latest version but that isn't very obvious so you may have tried the current master? My impression is that this does work in _rmarkdowntemplate but I haven't looked at it in a while.

ivannp commented 8 years ago

Could you be more specific with the steps? I installed the _rmarkdowntemplate branch using:

install_github('jimhester/knitrBootstrap',ref='rmarkdown_template')

No change in the output. I am trying all these in RStudio, by calling the knitting via the GUI.

Btw the title is still in the head portion of the HTML and it's empty. So are the author and the date, but they are not empty. Looks messed up to me, but I am not an HTML expert.

humburg commented 8 years ago

That sounds fine. Doing exactly the same procedure to install and knit I get the desired output using a YAML block like this:

---
title: "Test file"
author: Tester
output:
  knitrBootstrap::bootstrap_document:
    toc: true
    theme: amelia
    highlight: sunburst
---

A complete file for testing is here: https://gist.github.com/humburg/098532001c6ada6466fb

Note that the title and author have to be at the top level not under output. This is consistent with the documentation of the _rmarkdowntemplate branch (but that is easy to overlook).

@jimhester, maybe it would make sense to make _rmarkdowntemplate the default branch until it is merged into master?

ivannp commented 8 years ago

Great, this worked on the latest version. Thanks!

jimhester commented 8 years ago

@humburg thank you for debugging this and providing a fix.

The reason I have not merged _rmarkdowntempate into master is there are still some features missing from the branch which I unfortunately do not have time to address. https://github.com/jimhester/knitrBootstrap/pull/68#issuecomment-93811297 lists the main sticking points in my opinion.

humburg commented 8 years ago

@jimhester I understand that _rmarkdowntemplate isn't really done yet and it seems very reasonable not to merge it into master until it is. However, in some respects it seems preferable to the latest release, even in its current state. Considering that it might be a while until it is ready for a release I thought it might be helpful to advertise it more prominently to new users. I know it took me a while to figure out that it is the _rmarkdowntemplate branch I want to use.