MathJax script issue after customizing rstudio.markdownToHTML() - r

With knit2html() from the knitr package, I can generate html pages that contain latex equations and R code. But on my system equations are not rendered when using RStudio's "knit html" button.
It is because I have modified the way the "knit html" button works. To include a table of content on my html pages, I followed the Rstudio advice on Customize Markdown Rendering. And created an .Rprofile file at the root of the project directory that overrides default markdown rendering options. My .Rprofile only contains a function that replaces the rstudio.markdownToHTML() function as such:
options(rstudio.markdownToHTML =
function(inputFile, outputFile) {
require(markdown)
htmlOptions <- markdownHTMLOptions(defaults=TRUE)
htmlOptions <- c(htmlOptions, "toc")
markdownToHTML(inputFile, outputFile, options = htmlOptions)
}
)
With this .Rprofile, I'm happy to have an automatic table of content generated on all my .RmD documents. But equations are not rendered any more! Equations appear as plain text.
If I delete .Rprofile, reload R and click the "knit HTML" button in R Studio. Equations are rendered correctly but I don't have a table of content.
If I run :
knit2html("file.Rmd", "file.html",
options = c(markdownHTMLOptions(defaults=TRUE), "toc")))
Equations are rendered correctly and I have a table of content too.
Can you help me fix rstudio.markdownToHTML() so that it renders equations?
Edit 03 April 2014: Equations are visible if I open the html page in a web browser. They are not rendered in RStudio preview HTML pane. This might be an issue with the mathjax script not taken into account anymore by the Rstudio viewer?

Dason suggested me to post this as an answer.
Equations are visible if I open the html page in a web browser.
Equations are not rendered in RStudio preview HTML pane. This might be an issue with the Rstudio viewer?

Related

How to knit single files in a bookdown project without serving the whole book. Is there an equivalent to `options(blogdown.knit.serve_site=FALSE)`?

For reasons similar to those in blogdown issue 572, I would like the Rstudio knit button to behave as it does when I am not in a bookdown project folder, rendering a file that happens to be in a bookdown project folder according to the file's YAML, not the bookdown output YAML. I think this means that I would like the knit button to call rmarkdown::render rather than rmarkdown::render_site.
As noted by Yihui in blogdown issue 572, there is now such an option to change the default behavior of the knit button in a blogdown project: options(blogdown.knit.serve_site = FALSE).
The bookdown docs show how to customize the knit button:
knit: (function(input, ...) {rmarkdown::render(input)})
This works, but I'd rather change the global options for the Knit button, if possible (because we have a "Build Book" button in the Build pane. Thanks!

Linking to other pages on Simple R markdown website

I'm developing a Simple R Markdown Website, and want to include a few links to other .Rmd generated HTML pages on the home page.
Simply, I want to open up "detailed-desc.html" which is rendered from "detailed-desc.Rmd", on clicking a text element on the "index.Rmd" file. I'm not sure how this can be done.
If all your .Rmd files and their rendered HTML results are in the same directory, then you can use the regular markdown syntax and reference the HTML files for links.
[Detailed Description](detailed-desc.html)
Detailed Description
With a more complicated site folder structure, it is just
[Detailed Description](./path/to/your/folder/detailed-desc.html)
Detailed Description

In RStudio display Images inline in Rmarkdown files?

I am new in R and getting output(images/ interactive plots) displayed by some packages in viewer pane. I would rather like them to be displayed in the ramrkdown notebook.
Here is an example, using magick::image_read() which displays image in viewer pane and not inline:
Reference link where a knitted document has produced images within the notebook using same package as I have used: https://cran.r-project.org/web/packages/magick/vignettes/intro.html
Below are the settings I am using:
Have asked similar question on keras package earlier How to make plots appear in Rmarkdown file instead of viewer pane when working with keras in Rstudio?
This is happening with some of the packages, how do I make these images/plots appear inline ?

custom ppt templated changes doesn't render rmarkdown

I am attempting to render a powerpoint presentation from rmarkdown.
I downloaded this powerpoint template and associated files from sol-eng and am able to generate the powerpoint as is.
However, if I open the template and do
view -> slide master
and adjust any of the slide master (i.e. change the background color)
close slide master -> save
I get the error "The file may be damaged or it may have been created in a pre-release version of PowerPoint." when I attempt to render the powerpoint.
I am unclear why using the template as is vs changing the background would generate an error in making the powerpoint presentation.
Any suggestions would be helpful:)
it might be that R writes binary differently than Powerpoint. Is it possible to create a ioslide or beamer slide file with the original powerpoint file instead? If you do IOSlides or beamer, the view with only need a web browser and could be a more flexible file for presentation
I used a different computer/version of powerpoint; adjusted the master slide and now it works - still unsure why I couldn't adjust with my version of powerpoint so I am guessing some versioning issue.

Hyperlink that can lead to a pdf in Jupyter notebook

I'm working with Jupyter notebook and have a question in mind:
If I want to markdown an HTML file or any website, I can just simply do
[name-of-the-website](address-here)
and it will create a link to the page that I want to reference
My question is
Are there any markdown code for PDF reference
IS the code the same with HTML reference (whenver I click into the markdown link, It will create a new tab which can download the file to the computer)
P/s: I'm not talking about coverting the notebook into PDF file
I have found out an answer:
Go to the file PDF that you want to download, for example I want to download this PDF file
Ideas:
Because there should be a HTML link to download the document, if one can find this link, then can proceed to normal markdown HTML file in Jupyter Notebook
Steps:
On the browser, right-click that PDF download link, and then choose Inspect Element (Q) (on Firefox or any browser in use)
It is then open the console that will shown the download HTML file like shown:
href="http://www.montefiore.ulg.ac.be/services/stochastic/pubs/2009/DMWG09/dumont-visapp09-shortpaper.pdf"
One can proceed with normal markdown in Jupyter Notebook
This works for me:
ref.
This is a relative path to the file.

Resources