-
-
Notifications
You must be signed in to change notification settings - Fork 878
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
unicode \u2139 from dplyr causes spin output to fail with latex #2231
Comments
I actually saw a similar thing when running revdep checks on dplyr with the flexsurv package. It notably uses Rnw based vignettes, and when the dplyr warning is thrown when rendering the vignette it seems to use the unicode based My personal notes about this were:
Here is the check output from when I ran that awhile back
|
Apparently both MiKTeX and TeXLive includue the xetex engine whicih supports unicode. Don't know about tinytex. Is there some way to modify this R code to force the use of xetex?
|
@ggrothendieck yes using xelatex is required for Unicode characters support. You can pass argument to either using a complete format that would override any set in YAML field in document
or add some options to override or set options to default or in addition to any format specified in Rmd document rmarkdown::render("a.md", "pdf_document", output_options = list(latex_engine = "xelatex")) Also note that you don't need to call rmarkdown::render("a.R", "pdf_document", output_options = list(latex_engine = "xelatex"))
Did you observed that or do you think there could be a problem in the knitr function ? I re-read the code and we set the internal option for
I see this in your log. This seems to be the same issue reported in #2234 which I believe is cli still outputing some ANSI character in knitr output. Maybe related to r-lib/cli#581 Is there still issue with |
@cderv, Thanks! I tried it with TeXLive on Windows and it worked great. Also the tip about giving the .R file straight to |
@cderv I don't think I reproduced it locally, that was from the revdepcheck result. I imagine that you can probably reproduce it locally by forking it locally with: usethis::create_from_github("chjackson/flexsurv-dev", "~/Desktop/r/playground/packages/") and then running this git command to checkout the commit before the flexsurv author made the necessary changes to fix it
and then running a I tried but got other errors like That commit corresponds to chjackson/flexsurv@d369ce5 which was right before these 2 commits which look to be targeted at fixing the UTF-8 issues: |
Great thank you I'll have a look |
@ggrothendieck can you try with dev cli package as it could have solved this issue also ( maybe with r-lib/cli#581) ? Thank you ! |
@cderv, It is not clear to me what you are suggesting. How do I modify the code in my first post in this thread? |
@ggrothendieck you just need to install development version of cli ( Then dplyr should use this new version of cli in any context, including inside R Markdown document. No need to change anything to your code. |
|
@ggrothendieck Perhaps try |
The installation from r-universe worked but rendering the code did not.
As previously in this thread I am using TeXLive on Windows and the following does work.
|
Thanks I'll have a closer look about the difference with In current situation, dplyr shows Unicode in message which requires I need to understand what the tidyverse stack is already doing. Thanks |
So following what Davis shared also above, cli should not use unicode when
Unicode should not be used when LaTeX output is detected. This explains why this works rmarkdown::render("a.R", "pdf_document") because the output is indeed LaTeX when R code from But when this is run first knitr::spin("a.R") the output is So if you run
I don't think knitr can do much more than that. The |
@cderv, I guess something similar must happen when the flexsurv Rnw vignette is rendered? Like, it probably converts to some intermediate I do feel that since knitr seems to control that whole process of Rnw->md->LaTeX (assuming that is right), then knitr could still be in charge of ensuring that the intermediate result doesn't have unicode in it (since it knows it is going to be converted to LaTeX eventually) |
@DavisVaughan yes for Rnw to LaTeX I agree if this is indeed mixing. Different issue that this one here which I'll look into this. Thanks for the input ! |
So the issue is specific to flexsurv vignette In the setup chunk, they are using This has a side effect of modifying the Line 346 in db4eafb
which means Lines 373 to 375 in db4eafb
I don't know if @yihui should we add
I can confirm to you @DavisVaughan that knitting Lines 223 to 226 in db4eafb
So dplyr message should output ok in usual Rnw file |
Yes, and done. Thanks! |
Awesome ! Thanks @DavisVaughan and @ggrothendieck for the report about all this specific behavior |
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary. |
Suppose we have file a.R. If we paste it into R it does result in a dplyr warning saying to use
all_of(nms)
instead of justnms
but it runs and gives correct output.Now suppose we run:
This results in the following error
The problem is that the a.R source code shown above causes dplyr to issue a warning and that warning message contains unicode \u2139 . MiKTeX, tinytex and texlive all gave the error shown above on Windows 10. The bottom line is that one cannot spin dplyr code that has such warnings and I think all dplyr warnings contain that character.
Note that there was no \u2139 in the a.R source code so this was pretty mysterious until I realized what was going on.
The text was updated successfully, but these errors were encountered: