2

I am trying to write an example of using unicode font in Latex Beamer. The resulting pdf does not show the Hindi characters, rather shows blank spaces in that place. However, when I use the same code in documentclass[article], it is producing correct results. Can anyone please help where the problem lies?

\documentclass[xetex]{beamer}

\usetheme{Warsaw} 


\usepackage{verbatim}
\usepackage{verbatimbox}
\usepackage{subfigure}
\usepackage{framed,color}
\definecolor{shadecolor}{rgb}{0.93,0.91,0.91}
\usepackage{graphicx} 
\usepackage{hyperref}

\usepackage{polyglossia}
\usepackage{fontspec}
\usepackage{xunicode} %Unicode extras!
\usepackage{xltxtra}  %Fixes

%\setmainfont{Bitstream Charter}
\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\hindifont[Script=Devanagari]{Lohit Hindi}

\begin{document}
\begin{frame}[fragile]
\frametitle{Writing unicode text: use of \textit{.ttf} files}

\begin{shaded}
\begin{verbatim}
\documentclass{article}
\usepackage{fontspec}

\begin{document}
\setmainfont{Lohit Hindi}
\texthindi{देवनागरी में लिखना बहुत आसान है |}

\end{document}
\end{verbatim}
\end{shaded}

This produces


\texthindi{देवनागरी में लिखना बहुत आसान है |}

\end{frame}
\end{document}
1

Beamer uses sans serif font by default. This means you have to define \hindifontsf instead of the \hindifont which worked for article class.

Alternatively you could instruct beamer to use serif fonts by using \usefonttheme{serif}.

% !TeX TS-program = xelatex
\documentclass[xetex]{beamer}

\usetheme{Warsaw} 

%\usefonttheme{serif}

\usepackage{polyglossia}
\usepackage{fontspec}

\setdefaultlanguage{english}
\setotherlanguage{hindi}
\newfontfamily\hindifontsf[Script=Devanagari]{Lohit Hindi}

\begin{document}
\begin{frame}

\texthindi{देवनागरी में लिखना बहुत आसान है |}

\end{frame}
\end{document}

enter image description here

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.