When creating a slide with a formula that opens [ without closing it (e.g. $[0, \infty)$) the .pull-left thingy stops working (appears written in the slide as if it was regular text).
I was able to workaround this by adding an HTML comment with a closing ], as in <!-- ] -->. See the example below:
title: "Bug"
subtitle: ""
author: "Sergio Oller"
date: "2018/02/26"
output:
xaringan::moon_reader:
lib_dir: libs
---
.pull-left[
- An open left bracket in a Mathjax expression breaks pull-left: $[$
]
---
.pull-left[
- An invisible HTML comment can work around it: $[$ <!-- ] -->
]
This was tested using the master branch from today: https://github.com/yihui/xaringan/commit/f3c87c020dfa6a8aacf2631662e02a10fc567140
Apologies for opening the issue without a patch, but regex and javascript combined are hard for me... As there is a workaround, at least this is now documented here :sweat_smile:
Thanks for letting us know!
However, why are you opening a bracket in a math expression without closing it?
To me its also surprising that the workaround works as the formatting as a comment should trigger the ] to have no effect.
But I'm not an html expert :smile:
I don't think this classifies as a bug as it actually is a failure in the math expression which is then populated to the html output.
This is probably a remarkjs-level issue as any unclosed square bracket will break the parsing of .pull-left[], not just a bracket in a math expression. So this also affects unmatched left brackets in inline code as well.
@zeehio Another workable option for your use case is to use latex expressions, i.e. use \lbrack in place of [.
If an open left bracket is needed in general text, you can replace it with the HTML character [ to avoid breaking the .foo-class[] parsing in remarkjs.
@pat-s It's not a bug in my math expression: For instance, I wanted to specify a half-open interval https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals [0,\infty)
@gadenbuie Thanks! I did not know about \lbrack. The rendering is not exactly the same in my computer, but they look similar enough and it is more robust than the HTML comment trick :smile:
@pat-s It's not a bug in my math expression: For instance, I wanted to specify a half-open interval https://en.wikipedia.org/wiki/Interval_(mathematics)#Notations_for_intervals [0,infty)
Ah alright! I would have closed it anyways but I am not a mathematician :smile:
As there is a workaround and the information is stored in this issue, I'll close here :duck:
Complementing the comment by @gadenbuie for those of you that need tables with your own bins:
tab <- as.data.frame(table(cut(runif(100), breaks = c(0,0.20, 0.30, 0.40, 0.60))))
tab$CumFreq <- cumsum(tab$Freq)
tab$relFreq <- tab$Freq/sum(tab$Freq)
tab$CumrelFreq <- cumsum(tab$Freq/sum(tab$Freq))
tab$Var1 <- stringr::str_replace_all(tab$Var1, "]", "]")
colnames(tab_concen) <- c("\\[x_i\\]", "\\[n_i\\]", "\\[N_i\\]", "\\[f_i\\]", "\\[F_i\\]")
knitr::kable(tab_concen, format = 'html', escape = FALSE, digits = 4, padding = 2)
I came across this issue thread today when I was creating a Bibliography slide. One of my bibliography entries had a %20 in it (in the URL field) and this caused any type of formatting (e.g. .center[]) to not render.
I adjusted the URL to point to a different page and everything worked fine.
I'm posting this here in case anyone else has the same experience.
Most helpful comment
This is probably a remarkjs-level issue as any unclosed square bracket will break the parsing of
.pull-left[], not just a bracket in a math expression. So this also affects unmatched left brackets in inline code as well.@zeehio Another workable option for your use case is to use latex expressions, i.e. use
\lbrackin place of[.If an open left bracket is needed in general text, you can replace it with the HTML character
[to avoid breaking the.foo-class[]parsing in remarkjs.