I want to print some characters using the \char
command. The Unicode is 2b45. I have already tried the code \char"2b45
but it prints some illegal character and b45. Variations with braces also don't work. Does anyone have any idea about this? I have also tried other variations, but they also print the same thing.
[Tex/LaTex] Writing unicode characters in XeLaTeX using \char
unicodexetex
Best Answer
As Joseph Wright and others have said in the comments, you need uppercase letters with
\char
, so\char"2B45
.There are other options as well. The LaTeX command
\symbol{"2B45}
is essentially equivalent to\char
, and will always display the character at slot #x2B45 of the current font. The escape sequence^^^^2b45
(which breaks the pattern by taking lowercase letters) is equivalent to entering the Unicode character ⭅ (U+2B45). If that character is active, this form will trigger the code for it.Here is an extremely artificial example of how you might use both, to define a symbol that generates the math symbol in math mode, with correct operator spacing, or a symbol in text mode that matches the current text formatting.
Note that the first argument to
\newunicodechar
should be the Unicode character itself, and it should generate a command to select the correct font and display the symbol from it.