benwhalley / lifesavR

1 stars 1 forks source link

LaTeX math not rendered correctly in HTML #11

Closed paulsharpeY closed 2 years ago

paulsharpeY commented 3 years ago

For example, Session 5 currently produces this error:

/usr/lib/rstudio/bin/pandoc/pandoc +RTS -K512m -RTS session-5.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output session-5.html --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /home/paul/R/x86_64-pc-linux-gnu-library/4.0/rmarkdown/rmarkdown/lua/latex-div.lua --self-contained --variable 'html_clean:true' --variable 'gallery:false' --variable bs3=TRUE --standalone --section-divs --table-of-contents --toc-depth 2 --template /home/paul/R/x86_64-pc-linux-gnu-library/4.0/rmdformats/templates/template.html --highlight-style kate --variable theme=bootstrap --include-in-header /tmp/RtmpQtTgit/rmarkdown-str2e2651f4fa28.html --citeproc 
output file: session-5.knit.md

[WARNING] Could not convert TeX math '< \frac{1}{3}', rendering as TeX
[WARNING] Could not convert TeX math '> \frac{1}{3}', rendering as TeX

Output created: session-5.html
Warning messages:
1: `guides(<scale> = FALSE)` is deprecated. Please use `guides(<scale> = "none")` instead. 
2: MathJax doesn't work with self_contained when not using the rmarkdown "default" template. 

I think the problem is that webex::html_clean produces a stand-alone HTML document.

Suggested workaround is to use decimals rather than fractions (e.g. Bayes Factors).

The alternative is to figure out how to make a stand-alone HTML document render LaTeX maths markup. I looked at some SO posts and it looks fiddly. Might be possible with the right YAML voodoo to pass correct options to pandoc.

Background:

       --self-contained
              Produce a standalone HTML file with no external dependencies, using data: URIs to  in‐
              corporate  the  contents  of linked scripts, stylesheets, images, and videos.  Implies
              --standalone.  The resulting file should be "self-contained," in  the  sense  that  it
              needs no external files and no net access to be displayed properly by a browser.  This
              option works  only  with  HTML  output  formats,  including  html4,  html5,  html+lhs,
              html5+lhs,  s5,  slidy,  slideous,  dzslides,  and  revealjs.   Scripts,  images,  and
              stylesheets at absolute URLs will be downloaded; those at relative URLs will be sought
              relative  to  the working directory (if the first source file is local) or relative to
              the base URL (if the first source file is remote).  Elements with the attribute  data-
              external="1"  will  be left alone; the documents they link to will not be incorporated
              in the document.  Limitation: resources that are loaded dynamically through JavaScript
              cannot  be  incorporated;  as a result, --self-contained does not work with --mathjax,
              and some advanced features (e.g.  zoom or speaker notes) may not work  in  an  offline
              "self-contained" reveal.js slide show.
paulsharpeY commented 3 years ago

@benwhalley can't reproduce this, so looks like an issue on (my) Ubuntu, but not on OS X.

benwhalley commented 3 years ago

If still having issues, have you tried the _build.R script? Run it inside RStudio desktop.

paulsharpeY commented 3 years ago

I don't think that would help. I also have issues running _build.R which I've been working around.

benwhalley commented 2 years ago

closing this because I still can't reproduce and output seems fine