4

Latin Modern Roman has bad output for certain unicode combinations, including ā́ (small Latin 'a' with macron and acute accent). This can be remedied by using the TIPA package for these combinations, thus:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\usepackage{tipa}
\begin{document}

\begin{tabular}{ll}
  native Latin Modern Roman `a with acute stacked on top of macron': & ā́\\
  TIPA's `a with acute stacked on top of macron': & \textipa{\'=a}\\
\end{tabular}
\end{document}

compiles in XeLaTeX as:

'native' Latin Modern Roman `a with acute stacked on top of macron' vs TIPA's version of same

This a decent solution in many ways, but one issue is that the PDF-internal representation of the TIPA version is non-ideal. The (ugly) 'native' version copies-and-pastes out of the PDF document properly as ā́, but the TIPA version as ́ā.

Is there any way to associate a 'Unicode' representation on top of the TIPA version (e.g. like an OCR layer of a scanned PDF)?

Edit 1 (responding to @Davislor):

I am using fontspec, but wanted to use Latin Modern Unicode and still be able to use certain special characters I need in my document.

Try using ucharclasses

This partially works, but creates other issues. For comparison, here are 'straight' Latin Modern and CMU samples:

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle,Contextuals=Alternate}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\newfontfamily{\cmuserif}{CMU Serif}
\newfontfamily{\cmusans}{CMU Sans Serif}
\newfontfamily{\cmutypewriter}{CMU Typewriter Text}
\begin{document}
\noindent \textbf{Latin Modern Roman}:\\  ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\
{\sffamily\noindent \textbf{Latin Modern Sans}:\\ ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\}
\texttt{\textbf{Latin Modern Typewriter}:\\
 ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}}\\

{\cmuserif\noindent\textbf{CMU Serif}:\\  ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\
{\cmusans\noindent \textbf{CMU Sans Serif}:\\ ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\}
{\cmutypewriter\noindent{\textbf{CMU Typewriter}:\\
ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}}\\}
\end{document}

various diacritics and symbols in Latin Modern and CMU

Latin Modern has significant issues for ā́, ȭ, ī̀, ī́, R̥, r̥ (omitting the diacritic mark or mangling two diacritics together to indistinguishability) and poor typesetting for (where the overdot is misaligned). CMU generally gets these right (or at least results in readability), excepting the typewriter face. (Latin Modern has generally better-looking setting of accents and diaeresis/umlaut: éè üë ; and noticeably different type-setting of the Eszett ß.)

With ucharclasses we can fix some but not all of the Latin Modern issues, at the cost of losing access to sans serif and typewriter faces:

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX,Numbers=OldStyle,Contextuals=Alternate}
\setmainfont{Latin Modern Roman}
\setsansfont{Latin Modern Sans}
\newfontfamily{\defaultfont}{Latin Modern Roman}[SmallCapsFont={Latin Modern Roman Caps}]
\newfontfamily{\lmroman}{Latin Modern Roman}[SmallCapsFont={Latin Modern Roman Caps}]
\newfontfamily{\lmsans}{Latin Modern Sans}
\newfontfamily{\cmuserif}{CMU Serif}
\newfontfamily{\cmusans}{CMU Sans Serif}

\usepackage[Latin,LatinExtendedA]{ucharclasses}
\setDefaultTransitions{\defaultfont}{}
\setTransitionsForLatin{\defaultfont}{}
\setTransitionTo{LatinExtendedA}{\cmuserif}{} % fixes macron+acute, e.g. ā́
\setTransitionTo{LatinExtendedB}{\cmuserif}{}
\setTransitionTo{LatinExtendedC}{\cmuserif}{}
\setTransitionTo{LatinExtendedD}{\cmuserif}{}
\setTransitionTo{LatinExtendedE}{\cmuserif}{}
\setTransitionTo{LatinExtendedAdditional}{\cmuserif}{} % fixes overdot, e.g. ṁ
%\setTransitionTo{LatinSupplement}{\cmuserif}{} % essets, ß etc.
\setTransitionTo{CombiningDiacriticalMarks}{\cmuserif}{} % should contain ring below (U+0325), but doesn't fix R̥ r̥ (!)
\setTransitionTo{CombiningDiacriticalMarksExtended}{\cmuserif}{}
\setTransitionTo{CombiningDiacriticalMarksForSymbols}{\cmuserif}{}
\setTransitionTo{CombiningDiacriticalMarksSupplement}{\cmuserif}{}
\setTransitionTo{CombiningHalfMarks}{\cmuserif}{}

\begin{document}
\noindent \textbf{Latin Modern Roman with CMU Serif `fixes' with \texttt{ucharclasses}}:\\  ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\
{\sffamily\noindent \textbf{Latin Modern Sans with CMU Serif `fixes' with \texttt{ucharclasses}}:\\ ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}\\}
\texttt{\textbf{Latin Modern Typewriter with CMU Serif `fixes' with \texttt{ucharclasses}}:\\
 ā́ ȭ R̥r̥ éè ā üë ì í ī ī̀ ī́ è ṁṭ ß \textit{ß R̥r̥ ā́ ȭ}}
\end{document}

Latin Modern with some charclasses replaced by CMU characters

ā́, ī̀, ī́, ṁ are fixed, but ȭ, R̥, r̥ remain garbled or missing diacritics. And the ability to use sans and typewriter faces disappears.

Try using catcode

In the spirit of using newunicodechar, I tried the following:

\def\awithmacronacute{\textipa{\'=a}}
% or \def\awithmacronacute{\cmuserif{ā́}}
\catcode`\ā́=\active
\defā́{\awithmacronacute}

Unfortunately, \catcode doesn't work with characters which are combinations of combining unicode characters:

! Improper alphabetic constant.
<to be read again> 
                   \ā́ 
l.17 \catcode`\ā́
                 =\active
? 

Try with \ifpdfstringunicode

I tried the following:

\def\awithacuteandmacron{%
  \texorpdfstring{\textipa{\'=a}}%
  {\ifpdfstringunicode{ā́}}} 

While then calling \awithacuteandmacron typesets a ā́, it remains ' ā when I try to copy it out of the PDF.

I think just using CMU fonts in place of Latin Modern is ultimately the best of a number of imperfect solutions, since CMU seems to have better glyph coverage and handles combining unicode much better than Latin Modern.

  • 1
    My advice is: if possible, switch to fontspec. If you want to use a main font that doesn’t support IPA symbols, you can change the default font for that symbol with ucharclasses or newunicodechar. – Davislor Jun 9 at 4:54
  • 1
    Would \ifpdfstringunicode from hyperref work for you? – Davislor Jun 9 at 5:01
  • @Davislor: See edited question above. – emacsomancer Jun 9 at 22:13
  • 2
    Have you tried accsupp ? – ShreevatsaR Jun 10 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.