'How do I type accented characters in ASCII-encoded Rd files?

Can LaTeX escapes for accents be used in Rd files? I tried the standard \'e and many variants (\'{e}, {\'e}, \\'e, \\'{e}, {\\'e}, etc.), but none is rendered as an accented character in the PDF or HTML output.

I want my References section (i.e. \references{}) to be rendered with accented characters, but I do not want to type non-ASCII characters in my Rd files. Is there good/recommended practice? Should I simply replace non-ASCII characters with their ASCII equivalents (é → e, ø → o)?

To be clear, I know it is possible to type accented characters (e.g., é) directly in UTF-8-encoded files, but I would prefer to keep ASCII-encoded files.

This question is not about

or variants.

Minimal test package

Package structure

test
test/man
test/man/one.Rd
test/R
test/R/one.R
test/DESCRIPTION

test/man/one.Rd

\name{one}
\alias{one}
\title{Get One}
\description{Accents are not rendered: \'e \'{e} {\'e} \\'e \\'{e} {\\'e}}
\usage{
one()
}

test/R/one.R

one <- function() 1

test/DESCRIPTION

Package: test
Version: 0.1
Title: Test
Author: Nobody
Maintainer: Nobody <[email protected]>
Description: Test.
License: GPL-3

Build, check, and install with:

$ R CMD build test
$ R CMD check test_0.1.tar.gz
$ R CMD INSTALL test_0.1.tar.gz


Solution 1:[1]

Using math mode it works. Not sure 100% if this is what you are looking for.

Here are some examples:

  \'{e} {\'e} \\'e \\'{e} {\\'e}

$\acute{e}$

$\grave{e}$

$\tilde{e}$

PDF output:

’{e} {’e} \‘e \’{e} {\’e}
é
è
?

Update:

\newcommand\latexcode[1]{#1}

\latexcode{\'{a}}

Thoma\latexcode{\'{s}}

That works Thomas !

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1