Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

floating TOC for prettydoc in Rmarkdown ask for theme

Tags:

r

r-markdown

I love floating TOCs in my Rmarkdown and prettydoc package but trying to use both seems impossible.

I just want to add a floating TOC to my HTML Pretty doc. This is my working yaml header

title: "testing TOCs"
author: "Joe"
output:
  prettydoc::html_pretty:
    theme: leonids
    highlight: github
    toc: true

Adding Floating TOC option issues an error message asking for Theme.

title: "Test floating TOC"
author: "joe"
output:
  prettydoc::html_pretty:
    theme: leonids
    highlight: github
    toc: true
    toc_float: true


Error in rmarkdown::html_document(fig_retina = fig_retina, css = NULL,  : 
  You must use a theme when specifying the 'toc_float' option
Calls: <Anonymous> ... do.call -> <Anonymous> -> <Anonymous> -> <Anonymous>
like image 564
Forge Avatar asked Jul 08 '19 15:07

Forge


People also ask

How to use prettydoc in R Markdown header?

Its usage is extremely easy: simply replace the rmarkdown::html_document or rmarkdown::html_vignette output engine by prettydoc::html_pretty in your R Markdown header, and use one of the built-in themes and syntax highlighters. For example

Is there a floating TOC in Rmarkdown?

Also note that you have a comment within in your rmarkdown file, which will be interpreted as a header: The answer doesn't seem to work for me: There is only a floating toc, no toc at the beginning of the html. Also you'd need to watch the indent in the yaml: toc_depth and number_sections needs to be indented.

Can We do both a lightweight yet nice-looking theme for R Markdown?

So can we do BOTH, a lightweight yet nice-looking theme for R Markdown? The answer is YES! (At least towards that direction) The prettydoc package provides an alternative engine, html_pretty , to knit your R Markdown document into pretty HTML pages.

What is the prettydoc package?

The prettydoc package provides an alternative engine, html_pretty , to knit your R Markdown document into pretty HTML pages.


1 Answers

Per GitHub documentation, toc_float does not work with prettydoc.

like image 136
Mario Huang Avatar answered Nov 14 '22 19:11

Mario Huang