0

I am trying to import ᚊ (U+168A) and 🕙(U+1F55A) into a Latex document I have tried using

\DeclareUnicodeCharacter{}{}

to no avail, I have to use ShareLatex as it is the only why all of the members of this project can work on this report at the same time.

In my preamble I have put

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

Is there any way for me to use these characters in the document?

  • 2
    T1 fontenc says that you are using fonts with at most 256 characters matching the latin alphabet, to use emoji system fonnts you want to delete fontenc and inputenc and use fontspec with xelatex or luatex not pdftex – David Carlisle Dec 14 '16 at 0:47
1

[the answer for pdflatex – below, first the answer IMHO best in the long run]

As I see in the first result of "g sharelatex", it's an online LaTeX editor. But what is the TeX engine it uses? Is XeTeX/XeLaTeX available in it?

That's worth clarifying, because if so, then the best solution would be to use XeLaTeX and just type the desired characters as they are, probably switching to a font that contains them. In such a case, the [relevant piece of] preamble would look like:

\documentclass{article}

\usepackage{xltxtra}
\newfontface\emojiFont {Some-Font-with-emoji-etc}

% if the main font doesn't contain those characters, add:
\catcode `\ᚊ=\active
\protected\def ᚊ{\leavevmode{\emojiFont ᚊ}}
\catcode `\🕚=\active
\protected\def 🕚{\leavevmode{\emojiFont 🕚}}


\begin{document}

ᚊ

🕚

\end{document}

However, if there's only some ancient pre-Unicode TeX engine available, and you really really really do not want to, or really really really cannot switch to XeTeX/XeLaTeX or LuaTeX/LuaLaTeX and avoid further Unicode-related troubles in the future, then: [the pdflatex answer]

\documentclass{article}

\usepackage[utf8]{inputenc}


\DeclareUnicodeCharacter {168A} {\combUp}
\DeclareUnicodeCharacter {1F55A} {\clockTen}

\protected\def \combUp {<<Comb-UP, U+168A>>}
\protected\def \clockTen {<<Clock Ten, U+1F55A>>}


\begin{document}

ᚊ

🕚

\end{document}

Of course, you should define those \combUp and \clockTen to typeset respective char from a font that contains it. The definitions have to be robust, be it via the \protected primitive, or via LaTeX \DeclareRobustCommand (the latter is more tricky and robust only in the “robusted” LaTeX contexts).

  • Welcome to TeX.SE! In ShareLaTeX, if you click the Menu button you can choose which TeX engine use among: pdfLaTeX, LaTeX, XeLaTeX and LuaLaTeX. – CarLaTeX Dec 14 '16 at 4:04
  • 1
    Thank you! I did not realize that I could compile in XeLaTeX – Jeansburger Dec 14 '16 at 4:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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