# How do I apply boldface to multiple Khmer words in tabular environment?

I create documents that include both Latin and Khmer (Cambodian) characters. To type in Unicode, I use the fontspec package and typeset using XeLaTeX. To move between the two scripts I use the package ucharclasses.

My problem is this: when I put two or more Khmer words into a tabular environment, any text style that ought to target the entire string instead alters only the first word in the string. Here's a MWE:

\documentclass{article}
\usepackage{fontspec}
\setromanfont[Mapping=tex-text]{Times}
\usepackage[Khmer]{ucharclasses}
\setTransitionTo{Khmer}{\fontspec[Scale=0.8,Script=Khmer]{Khmer Mondulkiri}}
\setTransitionFrom{Khmer}{\normalfont}
\begin{document}
\begin{tabular}{l l}
ខុស​ហើយ & \quad not bolded\\
\textbf{នេះ ខុស ដែ} & \quad \textbf{three bolded words}\\
\bf នេះ ខុស ដែ & \quad \bf three bolded words\\
\end{tabular}
\end{document}


Once typeset, it looks like this:

Notice that neither \boldface nor \bf works for the Khmer – except the first word.

(To get the MWE example to work, you'll need a decent Khmer font: many pre-installed stock Khmer fonts don't have boldface at all. I've used Khmer Mondulkiri, an open font available from SIL.)

You are using \normalfont for the transition, and as obviously the space is a transition places this resets the series. Use only \rmfamily. It is also better to define a dedicated font family for khmer instead of loading it with fontspec::

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Times New Roman}
\newfontfamily\khmerfamily[Scale=0.8,Script=Khmer]{Khmer Mondulkiri}
\usepackage[Khmer]{ucharclasses}
\setTransitionTo{Khmer}{\khmerfamily}
\setTransitionFrom{Khmer}{\rmfamily}
\begin{document}
\begin{tabular}{l l}
ខុស​ហើយ & \quad not bolded\\
\textbf{នេះ ខុស ដែ} & \quad \textbf{three bolded words}\\
\bfseries នេះ ខុស ដែ & \quad \bfseries three bolded words\\
\end{tabular}
\end{document}


• Thanks, Ulrike. Worked perfectly. Honestly, I don't understand what \normalfont is (I copied the code from somewhere!), or why a transition would be different with \normalfont rather than \rmfamily. It seems as though a space is a transition either way. – viverechristus Mar 15 '17 at 12:47
• \normalfont is defined as \usefont\encodingdefault \familydefault\seriesdefault\shapedefault so it resets everything to "normal" and so e.g. instead of the bold series your get the normal mdseries. \rmfamily only changes the family. – Ulrike Fischer Mar 15 '17 at 12:56