Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latex2exp not rendering comma separated number correctly #60

Open
biogberg opened this issue Jan 3, 2023 · 0 comments
Open

latex2exp not rendering comma separated number correctly #60

biogberg opened this issue Jan 3, 2023 · 0 comments
Assignees

Comments

@biogberg
Copy link

biogberg commented Jan 3, 2023

I use latex2exp to render a simple expression in an R figure in the legend text. I want to use "," as the decimal separator. When I do so, the next digit is not rendered, so "0,05" becomes "0,5" in the figure -- both as displayed in R Studio and in exported PDF.

A minimal working example is:

library(latex2exp)
plot(TeX("$h^2=0,05$")) # <--- this does not render correctly

SessionInfo() is:

> sessionInfo()
R version 4.2.2 (2022-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default

locale:
[1] LC_COLLATE=Danish_Denmark.utf8  LC_CTYPE=Danish_Denmark.utf8    LC_MONETARY=Danish_Denmark.utf8 LC_NUMERIC=C                   
[5] LC_TIME=Danish_Denmark.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] latex2exp_0.9.6 mvtnorm_1.1-3  

loaded via a namespace (and not attached):
 [1] compiler_4.2.2  magrittr_2.0.3  cli_3.5.0       tools_4.2.2     glue_1.6.2      rstudioapi_0.14 vctrs_0.5.1     stringi_1.7.8  
 [9] stringr_1.5.0   lifecycle_1.0.3 rlang_1.0.6     fortunes_1.5-4 

R is running under R-Studio 2022.12.0 Build 353.

Expected behavior
I expected to see a rendering of "h-squared=0,05"

Actual behavior
What I see on screen and in exported PDF is:
h2equal005

Workaround
Changing the code to

library(latex2exp)
plot(TeX("$h^2$=0,05")) # <--- this renders correctly

produces the expected output. Thus the problem easy to work around, but I think the behavior of the "TeX" function is not desirable.

Best wishes

@stefano-meschiari stefano-meschiari self-assigned this Jan 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants