Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to incorporate some Unicode characters into my LaTeX files. All characters I added so far worked well, but when I use

\DeclareUnicodeCharacter{211D}{{\mathbb R}}

(211D is the Unicode character ℝ, i.e. what would be denoted \mathbb{R} in LaTeX), I get an error message

Undefined control sequence ℝ

The problem is dependent neither on what is "…" in \DeclareUnicodeCharacter{211D}{…}, nor on whether the character ℝ is used in math mode or not. For most other Unicode characters (even those with higher numbers), \DeclareUnicodeCharacter works as expected, but I get the same error also for other double stroke letters (e.g. ℂ). Do you have any idea why this is so and how to make it work?

share|improve this question

migrated from stackoverflow.com Sep 25 '11 at 10:55

This question came from our site for professional and enthusiast programmers.

    
Have you got \usepackage[utf8]{inputenc} in your preamble? –  N.N. Sep 25 '11 at 10:06
    
Of course, that's where the macro \DeclareUnicodeCharacter is defined. –  user963099 Sep 25 '11 at 11:10

1 Answer 1

up vote 7 down vote accepted

The following works for me:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\DeclareUnicodeCharacter{211D}{\mathbb{R}}

\begin{document}
$ℝ$
\end{document}

You probably forgot to load amssymb. By the way, there's a different way to define such symbols without looking in Unicode tables:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amssymb}
\usepackage{newunicodechar}
\newunicodechar{ℝ}{\mathbb{R}}

\begin{document}
$ℝ$
\end{document}

Notice also that the correct syntax is \mathbb{R} rather than {\mathbb R}.

share|improve this answer
    
Strange, it was indeed missing amssymb, but I was almost sure that I tested it also with simple 'test' instead of \mathbb{R} to make sure that \mathbb is not the problem. I was solving several issues at once and have probably mistaken it with some other character (I shouldn't ask such questions at 2 AM). Thank you for the solution. –  user963099 Sep 25 '11 at 12:37
    
As for the rest – I know about the newunicodechar, but I would like to make it possible to build my files everywhere and this package is not standardly included (at least not in my distribution). –  user963099 Sep 25 '11 at 12:41
    
And lastly – \mathbb R and \mathbb{R} is the same, I just wanted to make sure that there wouldn't be any problem with using this character as a parameter of a macro when not using {} (I like to write things like \frac12, \sqrt2 etc. and I have had some issues when the parameter was a macro whose content was not surrounded by {}, but this was all in XeLaTeX and it doesn't seem to be an issue here). –  user963099 Sep 25 '11 at 12:49
    
Of course \mathbb R and \mathbb{R} are the same. But definitely \mathbb{RX} and {\mathbb RX} aren't. Usually \mathbb isn't used like this, but \mathcal sometimes is. –  egreg Sep 25 '11 at 12:52

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.