I want to create a multi-language document using polyglossia
in which Khmer is set to be a main language and English as another language. I also have khmer-gloss.ldf
available so that Khmer font is a default font. All pseudo codes appears in boxes as in the picture below and even caption does not display either. I know it is the problem of font but I am pretty new to polyglossia
package. Anybody knows how to solve this problem? The below code is just an example.
\documentclass{article}
\usepackage{polyglossia}
\usepackage{amsthm}
\usepackage[linesnumbered,ruled]{algorithm2e}
\newfontfamily{\khmerfont}[Script=Khmer,BoldFont={Khmer OS Content},ItalicFont={Khmer OS Content},Scale=0.9]{Khmer OS Content}
\usepackage{fontspec}
\newfontfamily{\K}[Scale=0.90]{Khmer OS Content}
\newfontfamily{\T}[Scale=0.90]{Khmer OS Moul}
\setmainlanguage{khmer}
\setsansfont[Script=Khmer,Scale=0.95]{Khmer OS Content}
\setmonofont[Script=Khmer,Scale=0.95]{Khmer OS Content}
\setotherlanguage{english}
\begin{document}
អាល់កូរីតដើម្បីរកតួចែករួមធំបំផុត (\textenglish{PGCD})។
\begin{algorithm}
\begin{english}
\SetKwInOut{Input}{\textenglish{Input}}
\SetKwInOut{Output}{\textenglish{Output}}
\underline{function Euclid} $(a,b)$\;
\Input{Two non negative integers $a$ and $b$}
\Output{$\gcd(a,b)$}
\eIf{$b=0$}
{
return $a$\;
}
{
return Euclid$(b, a mod b)$\;
}
\caption{\textenglish{Euclid's algorithm for finding the greatest common divisor of two non negative integers}}
\end{english}
\end{algorithm}
\end{document}
Another problem that I encountered is that the command \mod is not recognised either. If I wrote this
\eIf{$b=0$}
{
return $a$\;
}
{
return Euclid$(b, a \mod b)$\;
}
I got error "Undefined control sequence return Eucli$(b, a \mod ..."
\mod
you needamsmath
. See Writing mod in congruence problems without leading space. – Werner Feb 14 '16 at 7:47