# TeX accents do not seem to work with fontspec and xe/lua/latex

I am using Minion Pro as mainfont and it does not have in its glyph table the character U+1E47 Latin small letter with dot below which I need only once in my document. Rather than change to another font, I thought that I would generate it using \d{n}.

I give below a minimal file illustrating the problem:

\documentclass{minimal}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro} % Comment out optionally
\begin{document}
U+1E47 Latin small letter with dot below: \d{n}

U+0101 Latin small letter a with macron: \={a}
\end{document}


I do not get the desired letter n with dot below although the a with macron exists in the font and is available. Commenting out \usepackage{fontspec} gives the desired output with CMR as default font.

The behaviour is the same with xelatex and lualatex although the former indicates the missing letter with a crossed box.

I believe that with the Ligatures=TeX setting, I should be able to get missing letters using TeX accents. I do not think I need to load the xunicode package as it is already loaded by fontspec.

Can someone tell me what a I am doing wrong, please?

Thank you.

-

The "standard way" would be to say

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}


in order to use the combining character instead of the missing character at U+1E47, but unfortunately Minion Pro has nothing in slot U+0323 (COMBINING DOT BELOW). We need to go the hard way: write the following in the preamble

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}
\makeatletter
\renewcommand{\d}[1]
{\hmode@bgroup
\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup}
\makeatother


so that you'll use the standard definition for \d. If other characters of that sort are needed, look in xunicode.sty for their definition; it starts with \DeclareUTFcomposite, it's sufficient to copy the line in your preamble and to change \Declare... into \Undeclare....

Let's look also at the "line below", which is again missing in Minion Pro. Here's a similar way to cope with the case, using the macron (U+00AF) for emulating the line below:

\documentclass{article}
\usepackage{fontspec,newunicodechar}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Minion Pro} % Comment out optionally

\UndeclareUTFcomposite[\UTFencname]{x1E47}{\d}{n}
\UndeclareUTFcomposite[\UTFencname]{x1E49}{\b}{n}
\makeatletter
\let\d\relax
\DeclareRobustCommand{\d}[1]
{\hmode@bgroup
\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-1ex}.\hidewidth}\egroup}
\let\b\relax
\DeclareRobustCommand{\b}[1]
{\hmode@bgroup\o@lign{\relax#1\crcr\hidewidth\ltx@sh@ft{-3ex}%
\vbox to.2ex{\hbox{\char"AF}\vss}\hidewidth}\egroup}
\makeatother
\newunicodechar{ṇ}{\d{n}}
\newunicodechar{ṉ}{\b{n}}

\begin{document}
U+1E47 Latin small letter n with dot below: \d{n}ṇ

U+1E49 Latin small letter n with line below: \b{n}ṉ

U+0101 Latin small letter a with macron: \={a}ā

\end{document}


It's perhaps better to declare \b and \d as robust commands. Moreover, with newunicodechar we can also input the characters directly.

-
Thank you for solving and also explaining so that I can cope with future cases as well. –  chandra Jun 15 '11 at 9:16
I am having a similar problem like @chandra. I am trying to get the letter "k" with a dot below with fontspec. It does not work, regardless of the font I choose. In LaTeX, I was able to do this with many fonts. Is there another simpler workaround to this? The solution proposed by @egreg is unfortunately beyond my level in LaTeX.This is my preamble: \usepackage{fontspec} \defaultfontfeatures{Mapping=tex-text} \usepackage{xunicode} \usepackage{xlxtra} –  mustail Aug 17 '11 at 23:16
@mustail With the code above, \d{k} should give a dot below the "k". –  egreg Aug 18 '11 at 8:51
@egreg Thanks a lot, the code worked flawlessly for me. I was not able to get \d{k} work with Latin Modern and many other fonts before, when using \fontenc. Now I get the dot below the letter. –  mustail Aug 18 '11 at 18:56
@egreg: A supplementary question if I may, please: The above workaround does not seem to work within a \textit{} argument i.e., for the italic version of Minion Pro, when I thought it should. Any help here is most appreciated. Thanks. –  chandra Oct 4 '11 at 7:39