7

Why doesn't my Unicode chess knight symbol show up in the output when using TexShop and typesetting with the XeLaTex engine?

In TexShop I have

\documentclass[12pt]{article}
\begin{document}
1.  ♘ df5 
\end{document}

When I click the Typeset button with engine XeLaTeX I don't get any error message but the pdf file doesn't have the chess knight symbol, ♘, it just has "1. df5". I am using MacTex 2022.

4
  • 1
    texshop is just the editor, so not really involved here. You can change the missing character warning in to an error by setting \tracinglostchars=3 Mar 14 at 19:58
  • @DavidCarlisle. Thx! I added that and get "./ChessGameU.ltx:46: Missing character: There is no ♘ (U+2658) in font [lmroman 12-regular]:mapping=tex-text;." Since the font Menlo seems to have the knight character (it works in the Mac TextEdit App) I could use that font using the TexShop menu command Source -> Font and choose Menlo but that doesn't work so I am still stuck. Mar 14 at 20:44
  • You specify fonts as I show in my answer, selecting from an editor menu will just change the font the editor uses it will not affect xetex. I used Segoe UI Symbol which is a windows font but use whichever font your browser uses to show your question Mar 14 at 20:50
  • @DavidCarlisle Thx! Sorry, I missed your answer as I didn't check for one by refreshing the page. You solved my problem. Thanks for the very quick response. Mar 14 at 21:08

2 Answers 2

9

xelatex reports

Missing character: There is no ♘ (U+2658) in font [lmroman12-regular]:mapping=t
ex-text;!

As Latin Modern does not have this character.

 albatross U+2658

will list fonts you have insalled with the character

enter image description here

\documentclass[12pt]{article}
\usepackage{fontspec}
\setmainfont{Segoe UI Symbol}
\begin{document}
1.  ♘ df5 
\end{document}
6
5

You can use your preferred font, not necessarily one that has that character.

The character is present, for instance, in Menlo (a macOS font).

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}

\setmainfont{Libertinus Serif} % or whatever font you like

\newfontface{\chesspiecesfont}{Menlo}
\NewDocumentCommand{\chesspiece}{m}{{\chesspiecesfont#1}}

\newunicodechar{♔}{\chesspiece{♔}}
\newunicodechar{♕}{\chesspiece{♕}}
\newunicodechar{♖}{\chesspiece{♖}}
\newunicodechar{♗}{\chesspiece{♗}}
\newunicodechar{♘}{\chesspiece{♘}}
\newunicodechar{♙}{\chesspiece{♙}}
\newunicodechar{♚}{\chesspiece{♚}}
\newunicodechar{♛}{\chesspiece{♛}}
\newunicodechar{♜}{\chesspiece{♜}}
\newunicodechar{♝}{\chesspiece{♝}}
\newunicodechar{♞}{\chesspiece{♞}}
\newunicodechar{♟}{\chesspiece{♟}}

\begin{document}

1. ♘ df5

2. ♚ df5

♔♕♖♗♘♙♚♛♜♝♞♟

\end{document}

enter image description here

If you replace Menlo with Apple Symbols, you get

enter image description here

and you understand why I did the indirection. We would like to move the pieces to sit on the baseline, rather than below it and reducing the font size a bit.

Change the relevant lines into

\newfontface{\chesspiecesfont}{Apple Symbols}[Scale=0.9]
\NewDocumentCommand{\chesspiece}{m}{\raisebox{\depth}{\chesspiecesfont#1}}

and the output will be

enter image description here

3
  • I discovered that the Unicode chess symbols are in Menlo by pasting the symbol into the TextEdit app and noting that the font changed to Menlo when I saved the filed and then opened it again. Using Albatross I got the complete list of fonts that have the symbols. Of those I prefer Arial Unicode MS. In addition to the XeLaTex engine you can use the LuaLaTex engine. Using Unicode characters in Latex is harder than using then in most apps, e.g. TextEdit, Aquamacs, and the Google Browser where you can just copy and paste them into the app. Mar 15 at 13:00
  • @GeorgeColpitts Such programs have a “fallback” mechanism that one doesn't want when dealing with good typography. Characters that are missing in a font can be substituted for, but a good typographer will choose the better alternative, not some randomi one.
    – egreg
    Mar 15 at 16:16
  • Thx! That helps explain it. Mar 15 at 21:46

You must log in to answer this question.

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