Skip to content

Unicode chars

5 messages · Jeff Newmiller, Enrico Schumann, Richard O'Keefe +1 more

#
Dear All


I was trying the supplementary file?GS_main.R from
https://esajournals.onlinelibrary.wiley.com/doi/abs/10.1002/ecy.3475

I have tried to prevent latex compilation from failing using Sweave 
after trying all the online fixes I could find including using Rterm?
I could fix it if it was in the input but not in the output?
I am using R version 4.2 on windows 11 with 64 GB memory


Sweave code

\begin{small}
<<r0>>=
library(emdbook) # version 1.3.12
library(bbmle) # version 1.0.23.1
library(pbmcapply) # version 1.5.0?
library(tidyverse) # version 1.3.0
library(ggpubr) # version 0.4.0
@ %%


<<r7>>=
summaryTable <-
tibble(model = m.names,
? ? ? ?dim = m.dims[model],? ? ? ? ? ? ? ? ?
? ? ? ?score = m.loo[model],? ? ? ? ? ? ? ??
? ? ? ?delScore = score - min(score),? ? ? ?
? ? ? ?se_ose = se_ose[model],? ? ? ? ? ? ??
? ? ? ?se_mod = se_mod[model]) %>% arrange(dim) %>%? mutate(index = 
1:length(dim))
summaryTable
@ %%


Output
\begin{Schunk}
\begin{Sinput}
? summaryTable <-
? tibble(model = m.names,
? ? ? ? ?dim = m.dims[model],? ? ? ? ? ? ? ? ?
? ? ? ? ?score = m.loo[model],? ? ? ? ? ? ? ??
? ? ? ? ?delScore = score - min(score),? ? ? ?
? ? ? ? ?se_ose = se_ose[model],? ? ? ? ? ? ??
? ? ? ? ?se_mod = se_mod[model]) %>% arrange(dim) %>%? mutate(index = 
1:length(dim))
? summaryTable
\end{Sinput}
\begin{Soutput}
# A tibble: 10 ? 7
? ?model? ?dim score delScore se_ose se_mod index
? ?<chr> <int> <dbl>? ? <dbl>? <dbl>? <dbl> <int>
?1 zero? ? ? 2? 908.? ? 5.84? ? 40.1? ?4.14? ? ?1
?2 d? ? ? ? ?3? 904.? ? 1.71? ? 40.6? ?2.52? ? ?2
?3 q? ? ? ? ?3? 907.? ? 4.92? ? 40.2? ?3.80? ? ?3
?4 qd? ? ? ? 4? 902.? ? 0? ? ? ?40.7? ?0? ? ? ? 4
?5 qdi? ? ? ?5? 903.? ? 0.632? ?40.5? ?1.60? ? ?5
?6 x? ? ? ? ?6? 908.? ? 5.58? ? 40.2? ?5.53? ? ?6
?7 xq? ? ? ? 7? 907.? ? 4.81? ? 40.3? ?5.36? ? ?7
?8 xd? ? ? ? 7? 905.? ? 2.96? ? 40.5? ?5.04? ? ?8
?9 xqd? ? ? ?8? 903.? ? 0.908? ?40.5? ?4.52? ? ?9
10 xqdi? ? ? 9? 904.? ? 1.89? ? 40.4? ?4.70? ? 10
\end{Soutput}
\end{Schunk}


The problem is the output from tibble?
# A tibble: 10 ? 7


the \times character is Unicode?U+00D7 or hex \xd7 and pdflatex lualatex 
etc fail where this occurs
Is there a way of adding "sanitizing" code in the output before 
compiling?
Or do I have to change it manually before compiling


I do not want to switch to knitr.?


Regards


Duncan Mackay
#
Are you aware that pdfLatex does not support Unicode? You need to use xeLatex. But I don't use Sweave, so I don't know how you go about making that choice.
On August 24, 2022 8:03:02 PM PDT, dulcalma dulcalma <dulcalma at bigpond.com> wrote:

  
    
#
On Thu, 25 Aug 2022, dulcalma dulcalma writes:
You could try to automatically clean the code, by using
?iconv, say. But the results by not be satisfactory,
depending on what characters were used.

Sweave itself does not compile the LaTeX code. If you
run (in R) 

    Sweave(<filename.Rnw>, encoding = "utf8")

then it will produce the TeX file, which you can then
compile via LuaLaTeX or XeLaTeX [see
e.g. https://www.ctan.org/pkg/lualatex-doc].

For instance, on the command line, just say

    lualatex <filename.tex>

or another programme (such as latexmk) that your TeX
distribution provides.


If this is a vignette, you can specify a Makefile, see
https://cran.r-project.org/doc/manuals/R-exts.html#Writing-package-vignettes

  
    
#
PDFLaTeX does support Latin-1, and this is a Latin-1
character.

On Thu, 25 Aug 2022 at 15:35, Jeff Newmiller <jdnewmil at dcn.davis.ca.us>
wrote:

  
  
#
Thank you for the reply I tried xeLatex at least once and possibly twice 
and it failed to compile

I now tried it again and found that I had missed the inputenc error when 
I tried before.
After removing the line it now compiles.

Thank you

Regards

Duncan


------ Original Message ------
From: "Jeff Newmiller" <jdnewmil at dcn.davis.ca.us>
To: r-help at r-project.org; "dulcalma dulcalma" <dulcalma at bigpond.com>; 
r-help at R-project.org
Sent: Thursday, 25 Aug, 2022 At 1:25 PM
Subject: Re: [R] Unicode chars

Are you aware that pdfLatex does not support Unicode? You need to use 
xeLatex. But I don't use Sweave, so I don't know how you go about making 
that choice.

On August 24, 2022 8:03:02 PM PDT, dulcalma dulcalma
<dulcalma at bigpond.com> wrote: