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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As described in the answers to this question, the accsupp package can be used to have symbols paste as arbitrary Unicode codepoints. For example you might want to write something like the following, to have blackboard-bold symbols denoting natural numbers, booleans, and strings paste with the Unicode codepoints denoting the corresponding blackboard bold symbols β„•, 𝔹, π•Š (U+2115, U+1D539, U+1D54A) as opposed to just as "N, B, S":


\(\setNat, \setBool, \setStr\)

However the latter two symbols paste incorrectly as α΅“, α΅” (U+1D53 and U+1D54). This problem arises whenever Unicode codepoints larger than hexadecimal U+FFFF are used. How can one fix this?

The same issue arises with \pdfglyphtounicode lines (with glyphtounicode.tex); see the above-linked-to question for examples involving ordinary BMP-characters. So I would also like to ask: How can one fix it there?

share|improve this question
@HeikoOberdiek Just drawing your attention to this - might be useful to add this to the accsupp documentation. (Maybe all this is obvious to an expert already, but it wasn't to me, even though I know Unicode very well.) :-) – Lover of Structure Oct 3 '12 at 6:34
The @-notation does only work, if the user has participated in the thread. I have now have seen the comment by accident because of the recent editing. – Heiko Oberdiek Nov 18 '12 at 3:56
The new version of accsupp (currently here, installation hints inside until the next release of my bundle) adds a new method unichar, where the text can be given as comma separated list of Unicode code point numbers. Numbers outside the BMP are automatically converted to surrogate pairs. – Heiko Oberdiek Nov 18 '12 at 3:59
up vote 5 down vote accepted

The accsupp package requires "16-bit" Unicode strings. That is for any character outside of the basic multilingual plane (= BMP = plane 0), i.e. a character with a Unicode codepoint larger than hexadecimal U+FFFF, you need to convert its raw Unicode codepoint to its UTF-16 representation. It so happens that for Unicode codepoints of the form U+HHHH any codepoint is identical to its UTF-16 representation. Higher codepoints though need to be converted into so-called surrogate pair form to get to their UTF-16 representation. For example, FileFormat.info lets you look up such values directly.

The codepoints U+1D539 (𝔹) and U+1D54A (π•Š) are D835 DD39 and D835 DD4A (respectively) in UTF-16, so the following code will work:

  \newcommand*{\setBool}{\BeginAccSupp{method=hex,unicode,ActualText=D835 DD39}\mathbb{B}\EndAccSupp{}}
  \newcommand*{\setStr}{\BeginAccSupp{method=hex,unicode,ActualText=D835 DD4A}\mathbb{S}\EndAccSupp{}}

\(\setNat, \setBool, \setStr,\)

glyphtounicode.tex's \pdfglyphtounicode behaves the same: it requires UTF-16. That is, one needs to write \pdfglyphtounicode{somename}{D835 DD39} instead of \pdfglyphtounicode{somename}{1D539}.

Note that of course both accsupp (with method=hex,unicode) and \pdfglyphtounicode accept an arbitrarily long sequence of UTF-16 values.

share|improve this answer

Your Answer


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.