stefano-meschiari / latex2exp

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

Assistance Needed with R and latex2exp for Latex Conversion #62

Open vardavas opened 1 year ago

vardavas commented 1 year ago

Dear Dr. Meschiari,

I apologize for any inconvenience with the following message regarding an issue I'm having with using latex2exp.

My name is Raffaele Vardavas, and I recently came across your insightful post that describes the utilization of your latex2exp package, particularly emphasizing the significance of employing raw strings. Your example, where "\Psi" was transformed into r"(\Psi)", greatly clarified this process.

Nonetheless, I am encountering challenges in handling the case when my string is a variable. For example, the following command works fine:

latex2exp::TeX(r'($\tilde{\alpha}_k$)')

but what if my input variable is "\tilde{\alpha}_k" such as in the following code:

x<-"\tilde{\alpha}_k" parsed_expr <- paste0("r'($",x,"$)'") latex2exp::TeX(x)

this does not give me the same output. I need to process a vector read from an excel spreadsheet, where each element x is a LaTeX expression and convert them to a vector or list that contains the elements latex2exp::TeX(x) as my outputs. The issue is very much linked to the single backslash, and all my attempts in getting a working solution by asking chatGPT end with frustrating failures.

Any guidance or insight you can provide regarding the conversion would be greatly appreciated.

Thanks! Raff