[Tex/LaTex] How to put a musical clef in a memoir-class document

errorsmemoirmusicunicode

I've got a lot of questions about preparing a book layout, but as I'm slowly going through the various books and other documents out there, I think most of the questions are being answered. However, the answer to the question How can I put musical clefs in the middle of text? doesn't work for my use-case, which is that I want to use a musical treble clef (𝄞) as a section separator. I first tried with XeTeX and the direct unicode input (as shown):

\documentclass[msmallroyalvopaper,12pt,openany]{memoir}
\usepackage{fontspec,xltxtra,xunicode}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{Baskerville}
\begin{document}
\part*{1980}
\chapter*{Chapter One}
\section*{𝄞}
\end{document}

This didn't work despite the Mac OS X Baskerville font having the treble clef in its Unicode range (I know as I have a Pages document that does this); all that shows up is the unknown character box (􏰀). So, I try the solution in the linked question:

\documentclass[msmallroyalvopaper,12pt,openany]{memoir}
\usepackage{fontspec,xltxtra,xunicode,musixtex}
\defaultfontfeatures{Mapping=tex-text}
\setromanfont{Baskerville}
\begin{document}
\part*{1980}
\chapter*{Chapter One}
\section*{\begin{music}\trebleclef\end{music}}
\end{document}

and this refuses to compile (I'm using TeXShop and forcing XeTeX), resulting in this message:

? musixtex/musixtex.tex:531: Class
memoir Error: Font command \rm is not supported.

See the memoir class documentation for explanation.

I have an SVG of a treble clef that I can use (I needed it for an earlier ebook book), but I'd rather just use normal font commands because I don't really want to have to worry about scaling this independently of the font size.

Does anyone know of a memoir-compatible solution for this? Or should I stop learning memoir-class and learn how to do what I need in ConTeXt or KOMA or is there something else that I should be doing?

Best Answer

The Baskerville font does not contain the clef symbol according to the Apple character viewer. However, the Apple Symbols font does contain the character, so you can do the following:

% !TEX TS-program = XeLaTeX

\documentclass[msmallroyalvopaper,12pt,openany]{memoir}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Baskerville}
\newfontfamily\symbolfont{Apple Symbols}
\DeclareTextFontCommand{\textsymbol}{\symbolfont}


\begin{document}
\part*{1980}
\chapter*{Chapter One}
\section*{\textsymbol{𝄞}}
\end{document}

The reason the musixtex solution doesn't work is that it is using very old font commands (\bf, \rm, \it, etc.). Memoir prevents you from using these by default, but you can override it by passing the oldfontcommands option to the class.