[R-pkg-devel] LaTeX Error: Unicode character not set up for use with LaTeX

Steven Jenkins @jenk|n@ @end|ng |rom @tud|oj@u@
Sat Jan 18 17:37:27 CET 2025


Longtime R user, first-time packager. Devtools are great; it’s pretty easy.

I’m trying to submit a package (https://github.com/jsjuni/massProps) that calculates mass properties and uncertainties for assembly trees. Very standard mechanical engineering stuff. The data are represented in a data frame and a tree.

It is customary in this and other fields to name an uncertainty parameter with “σ” subscripted by the symbol of the parameter it characterizes. My code assumes a data frame with column names including σ_mass, σ_Cx, σ_Cy, σ_Ixx, etc. (If you can’t see it in your locale, it’s GREEK SMALL LETTER SIGMA, U+03C3.)

At least in my locale, these are valid names in R, so I used expressions like result$σ_mass and input[row, “σ_mass”] liberally. Everything works.

Unfortunately, CRAN doesn’t like that. check() complains about Unicode characters. Easy enough to fix. Putting escapes in the R names made the computation code ugly, so I replaced all the internals as, e.g., result$sigma_mass. Read and update operations on the data frame are isolated, so it was fairly straightforward to fix those as input[row, "\u03c3_mass”].

Again, all good. All unit tests pass, check() produces no errors, no warnings, no notes. Doxygen contents documenting the columns (which retain the Unicode character) render perfectly.

Then I get to check(manual = TRUE). LaTeX issues many complaints:

  ! LaTeX Error: Unicode character σ (U+03C3)
                 not set up for use with LaTeX.

After a good bit of searching, I can't find a fix. Bookdown suggests setting the LaTeX engine to “xelatex”, but I don’t know whether that’s applicable (or possible) here.

So, two questions: (1) Is it bad practice to name columns like this in external serialization? Obviously, I can just use “sigma_” everywhere, but I prefer it the way it is. (2) Is there some way to change either the Doxygen input or the LaTeX configuration to correct the problem? (Escaping the Doxygen input doesn’t work.)

Thanks in advance for your guidance.

Steve
	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list