I thought I would add the following to this thread as I have not found
other places in the support list which answered my questions on
inserting unicode.
My goal was to do something very simple like include a locked padlock
symbol in a URL to indicate it was password restricted. Now this
starts out very easily.
In the .ptx document, simply add the hex version of the unicode:
🔒
This renders correctly in the web version, and it renders correctly in
the print-latex version, but since the character is not in the default
font, it does not render in the print version.
As a workaround, I was going to put an inline image in the ptx file,
but pretext does not seem to want to do that right now.
Instead, I modified some advice I found on the web in
https://github.com/mreq/xelatex-emoji/blob/master/README.mdExtracting from that site, we first install a utility:
# For Mac OS X:
$ brew install librsvg
# For Linux:
$ sudo apt-get install librsvg2-bin
Then run the command
$ rsvg-convert -f pdf -o <emoji-UTF-code>.pdf <emoji-UTF-code>.svg
Now for this to work, you must start with the svg code for the unicode
character; say from
https://commons.wikimedia.org/wiki/File:Emoji_u1f512.svgOnce you have created a file called emoji-1f512.pdf, place it in the
assets folder at the top level of your project.
The author of the previous site points to
https://github.com/mreq/xelatex-emoji/blob/master/xelatexemoji.sty,
but for just a couple of characters, less is needed. Based upon it, I
did the following:
In meta_docinfo.ptx, just before the </latex-image-preamble>, I added
\usepackage{newunicodechar}
\newcommand{\xelatexemoji}[1]{%
\raisebox{-0.15em}{%
\includegraphics[height=1em]{external/#1}%
}%
}
\newunicodechar{🔒}{\xelatexemoji{emoji-1f512.pdf}}
Note that the "external" directory referenced is the one in
output/web/ which gets created with the first 'pretext build -g web'.
Now when you try 'pretext build print', it pulls in the pdf as an
inline graphic.
It's not particularly elegant, but I find fonts a bit challenging in TeX.
There probably is a fontspec solution as well, but I have not looked
into it.