6

I would like to get Alchemy symbols working in PdfLaTeX. I do not have access to XeTeX or LuaTex as I am using Tex Writer on the iPad. Here are two minimal examples.

The first one works.

    \documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage{textcomp}
    \usepackage[utf8x]{inputenc}

    \begin{document}
    \unichar{"00E4}
    \unichar{"20AC}
    \end{document}

This one does not compile:

    \documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage{textcomp}
    \usepackage[utf8x]{inputenc}

    \begin{document}
    \unichar{"00E4}
    \unichar{"1F701}
    \end{document}

Here is the error message:

l.9 \unichar{"1F701}

? 
! Emergency stop.
 ...                                              

l.9 \unichar{"1F701}

Unicode character 128769 = U+1F701:
ALCHEMICAL SYMBOL FOR AIR
Character is not defined in uni-*.def files.
Enter I! to define the glyph.

Here is how much of TeX's memory you used:
 1717 strings out of 493024
 24829 string characters out of 6124273
 70825 words of memory out of 5000000
 5308 multiletter control sequences out of 15000+600000
 4403 words of font info for 15 fonts, out of 8000000 for 9000
 1141 hyphenation exceptions out of 8191
 23i,0n,17p,304b,478s stack positions out of 5000i,500n,10000p,200000b,80000s
!  ==> Fatal error occurred, no output PDF file produced!
  • you would need to find an 8bit font with the appropriate symbols but far easier is to make small pdf of each symbol and just include them via \includegraphics{zzz} – David Carlisle Apr 22 '17 at 8:02
  • There is \Air in the starfont package. But even only a few OpenType fonts provide the alchemy block, on my machine only Symbola and Apple Symbols. – egreg Apr 22 '17 at 10:13
8

TeX is a typesetter: its job is to pick up glyphs (shapes) from a font, and decide where to place them on a page. So information about those shapes needs to be available to TeX.

For interpreting your input, by default TeX treats each byte individually. With \usepackage[utf8x]{inputenc} you can let TeX know that it should interpret sequences of bytes as Unicode characters, as specified by the UTF-8 encoding. For example, when you type into the file, it will understand you mean the Unicode character U+20AC (EURO SIGN), as the file will contain the bytes corresponding to the UTF-8 encoding of that character. This is equivalent to manually entering \unichar{"20AC}.

But understanding that you intended a particular Unicode character isn't enough: so what? TeX still needs to know what to do with it.

For example:

  • ä U+00E4 LATIN SMALL LETTER A WITH DIAERESIS is defined in texmf-dist/tex/latex/ucs/data/uni-0.def as \"a (which TeX knows how to do)
  • U+20AC EURO SIGN is defined in texmf-dist/tex/latex/ucs/data/uni-32.def as \ifx\euro\undefined\texteuro\else\euro\fi which in turn is made somehow via glyphs available in TeX

The character you want, U+1F701 ALCHEMICAL SYMBOL FOR AIR 🜁 has no such definition. This explains the error message you're seeing.


To solve this, you need to give TeX some instructions for how to produce the shape for that symbol, when given that character:

  1. The easiest would be to use XeTeX/LuaTeX and use a Unicode font (like Noto Sans Symbols) that contains a glyph for that character. (Then the instruction is to just pick that glyph and use it.)
  2. You could find a TeX-compatible font that contains the character, and define U+1F701 to use that glyph from that font. (E.g. there are some astrological symbols in packages wasysym, marvosym, starfont and horoscop, which have some overlap with alchemical symbols.)
  3. You could find images for the glyphs, and the instruction would be to include the corresponding images as graphics. (This would give you maximum freedom in the shape of the symbols.)
  4. You could draw the images from "inside TeX", with something like Metapost or TikZ.

The last one is a solution that seems to have been used by the author of an earlier question about alchemical symbols and by the author of an alchemy-latex repo on Github.

For the latter, see this PDF of all its symbols, and borrowing its definition from alchemy.sty, we can do:

\documentclass{article}
\usepackage[utf8x]{inputenc}
% \usepackage[T1]{fontenc}
\usepackage{tikz}

% From https://github.com/michaelplews/alchemy-latex/blob/9adf10c/alchemy.sty#L30,L42
\newcommand{\air}[1]{%
\begin{tikzpicture}[#1]%
    \draw (0, 0)
    -- ++ (-60:1.5ex)
    -- ++ (180:1.5ex)
    -- ++ (60:1.5ex)
    -- cycle;
    \draw (0, 0)
       ++ (270:0.5ex)
       ++ (0:0.75ex)
    -- ++ (180:1.5ex);
\end{tikzpicture}%
}

% \DeclareUnicodeCharacter{1F701}{\air{}}
\DeclareUnicodeCharacter{128769}{\air{}}

\begin{document}

\air{}

\unichar{"1F701}

🜁

\end{document}

giving

air air air

  • (Note: Using utf8x instead of utf8 causes \DeclareUnicodeCharacter to expect codepoints in decimal instead of hexadecimal: that's why I had to use 128769 instead of 1F701.) – ShreevatsaR Apr 23 '17 at 8:12
  • @ShreevatsaR utf8x does not force on user decimal notation, "1F701 would have worked. To the contrary, it is Core LaTeX utf8 which forces usage of hexadecimal notation (without the ") and makes impossible usage of decimal notation without an expandable dec to hex conversion !! – user4686 Mar 17 '18 at 10:43
  • @jfbu Yes good point; 128769 and "1F701 are both the same number to TeX. So the difference is that utf8 expects a hexadecimal string as tokens (1F701), while utf8x expects a number ("1F701 or 128769). As you said! – ShreevatsaR Mar 17 '18 at 16:51

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.