# [R-pkg-devel] [FORGED] Math symbols in .Rd files

Rolf Turner r@turner @end|ng |rom @uck|@nd@@c@nz
Thu Apr 23 04:17:24 CEST 2020

On 23/04/20 11:03 am, Bert Gunter wrote:

> OS: Mac OSX Catalina
> R Version 3.6.3
> UTF-8 declared as Encoding in DESCRIPTION file
>
> First, apologies: I'm nearly certain that this has been asked (many
> times) before, and I think I know the answer. But I need to verify.
>
> \eqn{...} allows me to insert a few math symbols in .Rd files, but
> does not seem to work for symbols equivalent to unicode U+00B0 (degree
> sign) and U+00B1 (plus minus sign). That is \eqn{\pm } is not rendered
> properly, and there is no degree sign for Latex without adding
> packages.  I can enter these as Mac symbols (presumably using UTF-8
> encoding)  and they render properly on my machine in the installed
> package documentation. But CRAN's winbuilder doesn't like them with
> error message:
>
> LaTeX errors found:
> ! Package inputenc Error: Unicode char ≤ (U+2264)
> (inputenc)                not set up for use with LaTeX.
>
> Are there any fixes/workarounds other than a fallback to plain text?
>
> Thanks. Again, my apologies for asking this again, but I just wanted
> to be sure my understanding is correct -- or find out where I'm
> confused.

My understanding is that \eqn{...} doesn't really work with html, only
with LaTeX.  You need to do something like:

\eqn{\hat{\theta} \pm 1.96 \times SE}{theta.hat +/- 1.96*SE}

which (for me at least) gives a nicely rendered result in LaTeX -> pdf
and the kludgy workaround in html.

As for the degree sign I find that \eqn{42^\circ} gives acceptable
results in LaTeX, but of course doesn't work in html.

My understanding is that if you enclose things like "±" or "°" in
\enc{...} and have

\encoding{UTF-8}

as the very first line of your *.Rd file, then CRAN won't complain about
the presence of these symbols.  But this doesn't work inside \eqn{...};
there the "\enc{...}" gets rendered literally.

So for html I think you are stuck with the kludgy fallback to plain text.

cheers,

Rolf

--
Honorary Research Fellow
Department of Statistics
University of Auckland
Phone: +64-9-373-7599 ext. 88276



More information about the R-package-devel mailing list