Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using TeX and Glue for title expression in base plots

How can I use TeX and glue at the same time for a title expression? For example, I want to be able to use mathematical notations, but I also want to include the value of a dynamic variable with glue.

An example plot:

library(latex2exp)
library(glue)
v = "some dynamic text"
plot(5, 2, main=glue("{TeX('$I^2 +$')}{v}"))

The latex expression is not used. Essentially, I need to use greek letters and subscripts and then glue a dynamic text at the end. Is there a way to include both mathematical expression and the glue function?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You can simply use paste0() like this:

v = "some dynamic text"
plot(5, 2, main=TeX(paste0('$I^2 +$',v)))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading