2

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?

1
  • 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 Dec 14, 2016 at 0:47

1 Answer 1

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).

2
  • 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, 2016 at 4:04
  • 1
    Thank you! I did not realize that I could compile in XeLaTeX Dec 14, 2016 at 4:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .