# Rendering italics and small-caps with diacritics, or manually composing diacritics

I'm trying to render an italicized small-caps u with macron, but the result is never in small-caps. The reason for this combination is that my headers are rendered in small-caps, and one of my chapter titles includes the name of a literary work in Japanese, which should be italicized.

Here's an example:

% !TEX encoding = UTF-8 Unicode
% !TEX program = xelatex
\documentclass{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Linux Libertine}
\begin{document}

\textsc{Test: \emph{Shōchū}}

\end{document}


The result is:

My guess is that my font lacks precomposed italicized small-caps characters with diacritics, and so falls back to the non-small-caps glyph, but no matter which font I try, the result is always the same, so I guess most fonts don't include this as a precomposed glyph.

Even trying to use the unicode combining macron (U+0304) over a regular u to manually compose the character doesn't resolve this.

Is there some way to force LaTeX (XeLaTeX) to manually compose this character so that it displays as intended, or any other way to achieve the desired effect?

• It's very likely that the accented glyphs you need don't exist; it's remarkable enough that italic small caps are available. I think the easiest way to approach this is to define a macro for the accented word, build the letter(s) + macron by hand, and then call the macro when needed. Not really pretty (and it won't copy-and-paste), but the simple approach you tried isn't going to work. Another possibility might be to build a virtual font, but I have no idea how to do that for an OpenType font. (The o + macron is also not small cap, but isn't as obvious.) – barbara beeton Jan 31 at 3:13
• Thanks for your suggestion. I'm not very familiar with LaTeX's inner workings, so would you be able to suggest how I might define a macro to build the letter + macron manually? – user184555 Jan 31 at 3:25
• I don't have access to Libertine, so what I might propose would still not be a specific solution. @UlrikeFischer's answer does identify the reason, and offers a way forward, so if that works, I'll hold off on experimenting. – barbara beeton Jan 31 at 15:52

Is there ... any other way to achieve the desired effect?

The Stix Two Text font features smallcap/italic/letter-with-macron glyphs. The next two lines are produced with Linux Libertine O and Stix Two Text, respectively, while taking care to assure that the x-heights of the two fonts are equal.

To be sure, Stix Two Text is a clone of Times Roman, which may or may not suit your font-related needs. However, you could confine the use of Stix Two Text to page-header lines, right?

% !TEX program = xelatex  %%% or !TEX program = lualatex
\documentclass{book}
\usepackage{fontspec,iftex}

\begin{document}

\setmainfont{Linux Libertine O}
\textsc{Lorem Ipsum: \textit{Shōchū}}

\ifxetex
\setmainfont{STIX2Text-Regular}%
[Path=/Users/mico/Library/Fonts/, % adjust this line as needed
Scale=MatchLowercase,
ItalicFont=STIX2Text-Italic]
\else\ifluatex
\setmainfont{Stix Two Text}%
[Scale=MatchLowercase]
\fi\fi
\textsc{Lorem Ipsum: \textit{Shōchū}}

\end{document}


With lualatex the combining accent more or less work (the placement is not perfect)

\documentclass{book}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{Linux Libertine O}

\begin{document}

\textsc{Test: \emph{Shōchū Sho^^^^0304chu^^^^0304}}

\end{document}


With xelatex (or harf mode) harfbuzz interferes and replaces the glyph. There you only have the choice to either define your own accent command that places a rule over the chars, or to switch to a font which has a small caps with macron. The default Latin Modern font e.g. works too (left is what you would get with xelatex):