stefano-meschiari / latex2exp

Use LaTeX in R graphics.
Other
185 stars 10 forks source link

Using "\left(" with "\right." - bgroup is not correctly constructed #24

Closed kathsel closed 2 years ago

kathsel commented 4 years ago

In LaTeX one can construct a large open parenthesis with \left(\frac{M}{L}\right.. Using this with TeX is possible and gives:

TeX("$\\left(\\frac{M}{L}\\right.$")
#> expression(`$\left(\frac{M}{L}\right.$` = 
#>            paste("", "", bgroup("(", paste("", frac(paste("M"), paste("", "L")), ""))))

It is not possible to use this as the bgroup is missing the "closing" dot. The correct code would be: expression(bgroup("(", frac("M", "L"), ".")) (I removed unneccessary paste and empty strings, for emphasis on the ".").

plot.new()
plot.window(c(0,3), c(0,1))
text(0, 0.5, latex2exp::TeX("$\\left(\\frac{M}{L}\\right)$")) # works
text(1, 0.5, latex2exp::TeX("$\\left(\\frac{M}{L}\\right.$")) 

Error in bgroup("(", paste("", frac(paste("M"), paste("", "L")), "")) : invalid group specification

text(2, 0.5, expression(bgroup("(", frac("M", "L"), "."))) # works

grafik

stefano-meschiari commented 2 years ago

This bug is now fixed in the latest release (v0.9.0).