I am using latex2exp package to add math expression in a plot with R. I have an error when I use \\\left( to resize a parenthesis to encompass a fraction.
Can someone can help ? Thanks.
ttt <- TeX("$(\\\left(\\\frac{M}{L} = 0.08$")
I have the following error message when I use \\\\left(
Original string: $\left( \frac{M}{L} = 0.08$
Parsed expression: paste('','',bgroup('(', paste('','',frac(paste('M'), paste('','L')),'',phantom() == phantom(),'0','.','08','') )
Error in parse(text = str) : :2:0: unexpected end of input 1: paste('','',bgroup('(', paste('','',frac(paste('M'), paste('','L')),'',phantom() == phantom(),'0','.','08','') ) ^
Tex expects that for each \left you also write a \right. This is neccessary to calculate the height of the brackets, as e.g. \left(0.08 \right) = \frac{M}{L} produces brackets of a different height than \left(0.08 = \frac{M}{L}\right).
You example works with
TeX("$(\\left(\\frac{M}{L} = 0.08\\right)$")
Note that we have to add extra backslashes to the TeX code to make it work in R.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With