Dear Jean-François,
Thanks for the detailed and very helpful suggestions! I will have a go.
Regards,
Vinay
On Friday, 27 March 2020 23:08:36 UTC, jfbu wrote:
>
> Le 27/03/2020 à 16:44, 'Vinay Sajip' via sphinx-users a écrit :
> > I have some examples in my documentation of Unicode text characters
> \u2603 and \U0001F602. These appear fine in the HTML documentation, but I'm
> having trouble getting them to appear in PDF output generated using the
> latexpdf builder. I've set the utf8extra key in latex_elements to define
> the characters (using DeclareUnicodeCharacter) but nothing appears in the
> final PDF output for the characters.
> >
> > I'm using Sphinx 1.6.7 and the build completes with warnings but no
> errors (on Sphinx 2.x, the LateX build fails, but I haven't had time to
> shave that particular yak). The .tex file just contains the utf-8 encoded
> characters.
> >
> > What do I need to do to get arbitrary Unicode characters (in this case,
> they happen to be emojis) to appear in LaTeX/PDF output?
> >
>
> Hi, you need suitable font. If leaving latex_engine to its default
> "pdflatex", you typically will need your \DeclareUnicodeCharacter to do a
> suitable \selectfont and also select the correct slot among 255 in the
> font, and you probably need some font package loaded in the preamble which
> provides the suitable glyph.
>
> If using "xelatex" as latex_engine, the document font (by default GNU
> FreeFont) perhaps already has a glyph for that Unicode slot and you have
> nothing to do. Perhaps try with DejaVu as other font. Else a similar
> procedure can be done with \usepackage{newunicodechar}, using some
> \newfontfamily (fontspec documentation), and then \newunicodechar here also
> with some \selectfont.
>
> Notice that a recent LaTeX distribution will incorporate the noto-emoji
> font package.
> However if I understand correctly xetex does not support color emojis (I
> am not sure about this, finding fonts from xelatex/lualatex with fontspec
> always has quirks, and maybe something is wrong in my locale set-up), but
> luahbtex does.
>
> See
> https://stackoverflow.com/questions/190145/how-to-insert-emoticons-in-latex/57076064#57076064
>
>
> With soon available TeXLive2020, luatex will be luahbtex, i.e. use the
> HarfBuzz library.
>
> I tested this at home
>
> \documentclass{article}
> \usepackage{fontspec}
> \newfontfamily\NotoEmoji{NotoColorEmoji.ttf}[RawFeature={mode=harf}]
> \usepackage{newunicodechar}
> \newunicodechar{☃}{{\NotoEmoji ☃}}
> \begin{document}
> This ☃ that
> \end{document}
> % Local Variables:
> % TeX-engine: lualatex
> % End:
>
> and it works. (with pretest of TeXLive 2020).
>
> The whole point of the \newunicodechar, is that as far as I know, that is
> the only more or less simple way to let a Unicode codepoint like ☃ trigger
> usage of appropriate font.
>
> These are the additional elements to add to the latex preamble.
> i.e.
> \newfontfamily\NotoEmoji{NotoColorEmoji.ttf}[RawFeature={mode=harf}]
> \usepackage{newunicodechar}
> \newunicodechar{☃}{{\NotoEmoji ☃}}
>
> This method is a bit lying ahead in future. If you use a LaTeX
> distribution not from future but from very recent past, then you need
> luahblatex or lualatex-dev.
>
> See also
>
> https://www.ctan.org/pkg/coloremoji
>
> but this uses an image for each emoji, so they can't be copied-pasted as
> Unicode from PDF.
>
> good luck
> Jean-François
>
>
>
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sphinx-users/bdcd48e9-9537-44bf-9f83-04396b41e8c8%40googlegroups.com.