encoded_utf_to_latex: Encode UTF-8 text to LaTeX

View source: R/encoded-utf-to-latex.R

encoded_utf_to_latexR Documentation

Encode UTF-8 text to LaTeX

Description

Transform a UTF-8 string into LaTeX special characters.

Usage

encoded_utf_to_latex(x)

Arguments

x

A string, possibly encoded in UTF-8.

Details

This is a variation of tools::encoded_text_to_latex() with some additional replacements for better compatibility.

Value

A string with the corresponding transformations.

See Also

tools::encoded_text_to_latex().

Work with BibTeX metadata: as_bibentry(), cff_read(), cff_read_bib_text(), cff_write_bib()

Examples

# Full range of supported characters in R.
library(tools)

range <- 1:511

ascii_table <- data.frame(
  dec = range,
  utf8 = intToUtf8(range, multiple = TRUE)
)

# Add LaTeX using the base approach.
ascii_table$latex_base <- encoded_text_to_latex(ascii_table$utf8,
  encoding = "UTF-8"
)

# With the package-specific approach.
ascii_table$latex_cffr <- encoded_utf_to_latex(ascii_table$utf8)

ascii_table

cffr documentation built on Aug. 24, 2026, 5:11 p.m.