[Tex/LaTex] How to make LaTeX understand Unicode characters ↔︎ and ↕︎

charactersinput-encodingsnewunicodecharsymbolsunicode

I understand that LaTeX has horrible Unicode support, and if I want Unicode I should be using XeTeX. And I have read Entering Unicode characters in LaTeX but it doesn't seem to do what I want.

What I want to do is to just enter Unicode characters like ↔︎ and ↕︎ into my text. I'm not using Computer Modern Roman, I'm using modern fonts that have full Unicode support. So I want the output to be ↔︎ and ↕︎ in the chosen font.

I get this error message:

! Package ucs Error: Unknown Unicode character 65038 = U+FE0E,
(ucs)                possibly declared in uni-254.def.
(ucs)                Type H to see if it is available with options.

See the ucs package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.881 will call this the ↔︎
                                direction, or a 0º rotation.
?

And I include the packages like so:

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage{ucs}

What magic LaTeX incantations do I include?

Best Answer

Actually, LaTeX has a pretty good Unicode support (better yet since the October 2019 update). You just need to define the character you want to type:

\documentclass{article}
\DeclareUnicodeCharacter{2194}{\ensuremath{\leftrightarrow}}
\DeclareUnicodeCharacter{2195}{\ensuremath{\updownarrow}}
\begin{document}
How can I type ↔ and ↕ in \LaTeX?
\end{document}

Note that you have a (spurious, I think) caracter U+FE0E (VARIATION SELECTOR-15) after each ↔ and ↕ character.