stefano-meschiari / latex2exp

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

itliac for the entire expression? #34

Closed bishun945 closed 2 years ago

bishun945 commented 2 years ago

Dear Stefano,

I had an issue when using Tex to create an expression which only requires variables to be italic.

For instance, latex2exp::TeX("$a$ is a variable", italic = TRUE) would return all characters, including "is a variable", as italic.

My tricky solution is by using

latex2exp::TeX("$a$ is a variable", output = "character") %>% 
    gsub("'a'", "italic(a)", .) %>% 
    parse(text = .)

Is there any better solution to make only $a$ italic?

Regards, Shun

bishun945 commented 2 years ago

Hi all,

My bad. The solution is to use \\textit:

latex2exp::TeX("$\\textit{a} is a variable$")