TransWikia.com

DeclareUnicodeCharacter not working at all

TeX - LaTeX Asked on September 5, 2021

The following code should be valid but doesn’t compile at all.

documentclass{article}
usepackage[utf8]{inputenc}

DeclareUnicodeCharacter{0052}{W}

begin{document}
RRRR
end{document}

and I get the following error message:

! Package inputenc Error: Cannot define non-active Unicode char value < 00A0.

See the inputenc package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.4 DeclareUnicodeCharacter{0052}{W}
                                     
? 

Does anyone know why this is happening?

I am using pdfLaTeX.

One Answer

No, the code is not valid. The command DeclareUnicodeCharacter will refuse to act on codes in the ASCII printable area, which is what the error message says.

There are very good reasons for this: if you make R active, you won't be able to use any command that contains R, except for R.

If you like to live on the razor edge, you can do

catcode`R=13 def R{W}

but don't hold weird error messages against me: I warned you not to do it. ??

Correct answer by egreg on September 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP