3

I am encountering an odd problem. I want to create composite characters such as ǎ using the newunicodechar package. However, it only yields a result in combination with the xeCJK package.

This code produces missing characters:

\documentclass[a4paper,12pt,article,oneside]{memoir}
\usepackage{fontspec}
\usepackage{xunicode}

\usepackage[british]{babel}

\setmainfont[Ligatures=TeX]{Minion Pro}

\usepackage{newunicodechar}
\newunicodechar{ǚ}{\v{ü}}
\newunicodechar{Ǚ}{\v{Ü}}
\newunicodechar{ǎ}{\v{a}}
\newunicodechar{Ǎ}{\v{A}}
\newunicodechar{ǒ}{\v{o}}
\newunicodechar{Ǒ}{\v{O}}


\begin{document}

ǚ Ǚ ǎ


\end{document}

If I load the xeCJK package then the characters render just fine. Why is that? And how to generate composite characters without the named package?

Note:

  • this is reproducible with other fonts that do not contain the unicode characters (e.g. Adobe Garamond Pro)
  • Minion Pro does contain a caron character (unicode 02C7, index 136)
6

The default setup doesn't use unicode U+02C7, but the combining accent U+030C which is missing in your font. xecjk contains some code to use U+02C7 instead, but seems to use this code only if xunicode is loaded too - which is a bit of a pain, as normally one shouldn't use it anymore.

You can clone the xeCJK code by using \add@accent. If more fonts are involved where some have the combining accent, some additional checks for glyph existence are probably needed.

\documentclass[a4paper,12pt,article,oneside]{memoir}

\usepackage{fontspec}
\usepackage[british]{babel}

\setmainfont[Ligatures=TeX]{MinionPro-Regular.otf}

\usepackage{newunicodechar}
\makeatletter

\newunicodechar{ǚ}{\add@accent{`^^^^02c7}{ü}}
\newunicodechar{Ǚ}{\add@accent{`^^^^02c7}{Ü}}
\newunicodechar{ǎ}{\add@accent{`^^^^02c7}{a}}
\makeatother
%\newunicodechar{Ǎ}{\v{A}}
%\newunicodechar{ǒ}{\v{o}}
%\newunicodechar{Ǒ}{\v{O}}
%
\begin{document}
abc 

ǚ Ǚ ǎ

\end{document}

enter image description here

  • Thanks! As always you're answering my questions :) Could this be a potential feature request for newunicodechar: Substitute combining characters automatically? – Paul Feb 25 '19 at 11:06
  • No, newunicodechar doesn't care about the code you use, you could also input a picture. But you make a feature request for latex, the kernel could perhaps add a fall back to 02c7 to the definition of \v. – Ulrike Fischer Feb 25 '19 at 11:11
  • Are you sure I can just submit it to the Latex2e github? – Paul Feb 25 '19 at 11:34
3

Based on a trick by Egreg, this uses the \accent primitive. I chose to simply redefine \v.

\documentclass{standalone}
\usepackage{fontspec, newunicodechar}

\usepackage[british]{babel}

\setmainfont[Ligatures=TeX]{Cardo}

\renewcommand\v[1]{\accent\string"02C7 #1}

\newunicodechar{ǚ}{\v{ü}}
\newunicodechar{Ǚ}{\v{Ü}}
\newunicodechar{ǎ}{\v{a}}
\newunicodechar{Ǎ}{\v{A}}
\newunicodechar{ǒ}{\v{o}}
\newunicodechar{Ǒ}{\v{O}}

\begin{document}

ǚ Ǚ ǎ Ǎ ǒ Ǒ

\end{document}

ǚ Ǚ ǎ Ǎ ǒ Ǒ

I picked Cardo as a common font that contains the caron accent, but not the precomposed ǚ.

  • I can reproduce the MWE of this solution with Minion Pro. However, for some reason it doesn't work in my actual main file. There is some clash with another package, and I cannot identify (yet) which one it is. – Paul Feb 25 '19 at 11:23
  • You might to change the \documentclass back, if you didn’t. I switched to standalone for the convenience of creating a cropped image. Anyway, just adding the line \renewcommand\v[1]{\accent\string"02C7 #1} ought to work. – Davislor Feb 25 '19 at 11:32
  • I already checked and your solution definitely works with \documentclass[a4paper,12pt,article,oneside]{memoir} Must be something else... – Paul Feb 25 '19 at 11:34
  • I also removed xunicode? Or maybe it’s related to \setmainfont versus \babelfont? – Davislor Feb 25 '19 at 11:42
  • I identified the conflicting package: it's hyperref But I have no idea what causes it – Paul Feb 25 '19 at 12:27

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.