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

Missing spaces when plotting from VSCode #56

Closed
colinbousige opened this issue Nov 23, 2022 · 2 comments
Closed

Missing spaces when plotting from VSCode #56

colinbousige opened this issue Nov 23, 2022 · 2 comments

Comments

@colinbousige
Copy link

Hello,

I'm not sure whether this is a VSCode, a radian, or a latex2exp problem. It's probably the former but the latex2exp community is here, so here it is:

Running the exact same code from different environments does not yield the same result. As an example, I run the following vignette example:

library(latex2exp)
plot(TeX(r'(A $\LaTeX$ formula: $\frac{2hc^2}{\lambda^5}\frac{1}{e^{\frac{hc}{\lambda k_B T}} - 1}$)'), 
     cex=2, main="")
  • Within RStudio: it works as expected
  • Within radian or "normal" R executable in the terminal: it works as expected
  • Within radian in VSCode: all spaces are trimmed, there are no spaces between words. See image below.
  • Within "normal" R executable in VSCode: it works as expected

image

Since I work in VSCode using radian, this is driving me nuts... I need to manually add them using \: or the likes.

Thanks in advance for your help!

r$> sessionInfo()

R version 4.2.2 (2022-10-31)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

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

loaded via a namespace (and not attached):
[1] compiler_4.2.2 cli_3.4.1     
[3] jsonlite_1.8.3 rlang_1.0.6   
@stefano-meschiari
Copy link
Owner

Unfortunately, it seems like this is a bug in the httpgd plot renderer (the "nicer" plot renderer in VSCode) -- if you uncheck the option "R > Plot > Use Httpgd" in VSCode settings, the issue is not present.

I can reproduce it even in a vanilla R terminal:

library(httpgd)
library(latex2exp)
hgd()
plot(TeX(r'($\alpha$ and also $\beta$)'))

gives me

image

i.e. it looks like the httpgd renderer is swallowing the spacing between the symbols and horizontally deforming the string "and also" to fit.

You should open an issue with the httpgd project, and in the meantime you can try switching to the PNG renderer in VSCode, although it won't be nearly as functional 😞

@colinbousige
Copy link
Author

Thanks for locating the source of the problem, I raised the issue with httpgd then

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