1

I'd like to have certain weird accents appear in my document's headings. I don't have that issue when using common fonts, like Arial in the example below: I simply write the accent as I want it to appear, and it works.

When I try to use less common fonts, however, the accent doesn't pop up and I get a glitch.

How may I deal with this issue?

Thank you.

\documentclass[oneside,centered,twocolumn]{book}

\usepackage{titlesec}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{fontspec}

\newfontfamily\partfont[]{Goudy Sans Black BT}
\newfontfamily\secfont[]{Arial}

\titleformat{\chapter}%
{\partfont\bfseries\Huge}{\thechapter.}{10pt}{}

\titleformat*{\section}{\LARGE\partfont}
\titleformat*{\subsection}{\Large\secfont}

\begin{document}

\chapter{ǘ} % <---- FAILS

\section{ü} % <---- WORKS

\section{ú} % <---- WORKS

\section{ǘ} % <---- FAILS

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do 
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
enim ad minim veniam, quis nostrud exercitation ullamco laboris...

\subsection{ǘ}

\end{document}

enter image description here

3
  • 2
    I think you might be stuck with using a different font. As far as I know the font file has to include glyphs for the Unicode character for it to work. If the glyph does not exist in the definition of available glyphs in the font file it won't print.
    – Plergux
    Nov 6, 2020 at 17:30
  • 2
    If you add \tracinglostchars=2 to your preamble, TeX will warn you that the font you’re using doesn’t have a character. It’s unlikely that your font has a circumflex accent glyph if it doesn’t even cover Latin-1, but if it does, you would be able to fake the character with \accent.
    – Davislor
    Nov 6, 2020 at 18:42
  • Thank you. If I add '\chapter{ü}' or '\chapter{ú}' to my document, the accent appears properly. It's when I combine accents that I get a failure (see the edited code above). No possibility of combining the two accents, since, individually, they appear perfectly? Nov 6, 2020 at 19:55

3 Answers 3

2

It's much better if you use fonts that cover the necessary glyphs.

For a handful of missing glyphs, you can do like the following.

For text in Goudy Sans Black, \' becomes different and fakes the acute. No problem if you use ú, that's already a single Unicode character, so the accent will not be faked.

Note \newfontface instead of \newfontfamily, as you are using the font in a single instance and it's not needed to do \bfseries when you call it (it just spawns a warning anyway).

\documentclass[oneside,twocolumn]{book}

\usepackage{titlesec}
\usepackage{titling}
\usepackage{fancyhdr}
\usepackage{fontspec}
\usepackage{newunicodechar}

\makeatletter
\newunicodechar{ǘ}{\ifnum\strcmp{\f@encoding}{goudy}=0 \'{ü}\else ǘ\fi}
\DeclareUnicodeEncoding{goudy}{
  \input{tuenc.def}
  \DeclareTextCommand{\'}{goudy}[1]{\goudy@fakeacute{#1}}
}
\newcommand{\goudy@fakeacute}[1]{%
  \leavevmode
  \vbox{%
    \ialign{%
      ##\cr
      \hidewidth\hskip0.05em\char"B4\hidewidth\cr
      \noalign{\nointerlineskip\vskip-1.1ex}
      #1\cr
    }%
  }%
}
\makeatother

\newfontface\partfont{Goudy Sans Black BT}[NFSSEncoding=goudy]
\newfontfamily\secfont{Arial}

\titleformat{\chapter}{\partfont\Huge}{\thechapter.}{10pt}{}
\titleformat*{\section}{\LARGE\partfont}
\titleformat*{\subsection}{\Large\secfont}

\begin{document}

\chapter{\'{ü} or ǘ}
\section{ü}
\section{ú}
\section{\'{ü} or ǘ}

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do 
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut 
enim ad minim veniam, quis nostrud exercitation ullamco laboris...

\subsection{ǘ}

\end{document}

enter image description here

1
  • I tried so hard to find this solution because I knew it was possible to make it happen. And here it is. Thank you. Thankfully, I only have to do this for three headings in the entire document. Nov 25, 2020 at 6:51
2

I was going to suggest old-school \'ü, but Goudy Sans Black BT does not have separate accent characters (acute or umlaut).

An embarrassing answer that works somewhat for appearance, but not for textual honesty or searching, is

\section{{\protect\boldmath$\acute{\mbox{ü}}$} Math Acute}

enter image description here

1

Since you're using fontspec, and, hence, have access to unicode fonts, you could use a font that covers the "Combining Diacritical Marks" unicode block, and pile things up to your heart's content, in a jolly "Cat-in-the-Hat"-style.

Best not to overdo it, though. Unless writing for infants, perhaps. Combinatorics has artistic merit for them.

CITH style

MWE

\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\newfontface\fbtext{Noto Serif Black}[Colour=red]
\begin{document}

{\fbtext
u^^^^0308^^^^0301
}

c^^^^0330^^^^0332^^^^030e^^^^030f
a^^^^0324^^^^0325^^^^0328^^^^0300^^^^0301^^^^0302^^^^0303
t^^^^0310^^^^032b^^^^034c^^^^0325^^^^032a

\end{document}

You must log in to answer this question.

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