2

I have decided to shift to LyX for simpler use. I use following template. I encountered two problems while trying to customise LyX.

  1. The devnagari does not display properly on LyX.
  2. I did not understand how to specify two fonts for two languages to be used in the same document.

(link for the Sanskrit 2003 font < http://www.omkarananda-ashram.org/Sanskrit/sanskrit2003.zip>)

Here is the template

\documentclass{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\usepackage[Latin,Devanagari]{ucharclasses}

\setmainfont{Devanagari MT}

% Maybe Sanskrit 2003 doesn't need the following line;
% in this case change \devanagarifont in the \setTransitions
% commands to \normalfont
\newfontfamily{\devanagarifont}{Sanskrit 2003}

% choose the font for English
\newfontfamily{\englishfont}[Ligatures=TeX]{TeX Gyre Pagella}

\setmainlanguage{hindi}
\setotherlanguage{english}

\setTransitionsFor{Latin}
  {\hyphenrules{english}\englishfont}
  {\hyphenrules{hindi}\devanagarifont}
\setTransitionsFor{Devanagari}
  {\hyphenrules{hindi}\devanagarifont}
  {\hyphenrules{english}\englishfont}

\begin{document}

नई दिल्ली, भारत की राजधानी है। कुल ४२.७ वर्ग किमी क्षेत्रफल के साथ, नई दिल्ली दिल्ली महानगर 
के भीतर आता है और यहाँ पर भारत सरकार और दिल्ली सरकार के सभी प्रशासनिक भवन स्थित हैं।

New Delhi is the capital of India, and the seat of executive, legislative, and judiciary 
branches of the Government of India. It also serves as the centre of the Government of the 
National Capital Territory of Delhi. New Delhi is situated within the metropolis of Delhi 
and is one of the eleven districts of Delhi National Capital Territory.

नई दिल्ली, भारत की राजधानी है। कुल ४२.७ वर्ग किमी क्षेत्रफल के साथ, नई दिल्ली दिल्ली महानगर 
के भीतर आता है और यहाँ पर भारत सरकार और दिल्ली सरकार के सभी प्रशासनिक भवन स्थित हैं।

\end{document}
  • That is a technical question. The truth is I don't know. But it works without specifying the font everytime. – Vaibhav Sep 25 '14 at 13:57
  • 1
    In LyX you specify which language a certain chunk of text is by highlighting it, going to Edit > Languages. If that option is not there it's because no languages have been set up. Go to Edit > Text Style > Customized > and choose the language there (and from then on you can go as above to Edit > Languages). Please post a minimal example .lyx file (it is just a text file). – scottkosty Sep 25 '14 at 14:37
  • @scottkosty You are a hero. These simple instructions (in your 2014-09-25@14:37 comment) need to be added to the LyX Hebrew set up wiki page! I've spent ages looking for exactly this help. Thank you! – Dɑvïd Mar 2 '16 at 16:49
  • @Davïd glad it helped. You can make the wiki edit yourself actually. Just click on "Edit" at the bottom of the page and follow the instructions regarding the password. – scottkosty Mar 3 '16 at 1:17
  • @scottkosty - Done! You might want to check it (credit given in the "commit" message!). ;) – Dɑvïd Mar 3 '16 at 8:08
3

First, make sure you have selected "Use non-TeX fonts (via XeTeX/LuaTeX) in the Fonts settings panel.

In your preamble, you specify the fonts you want to use for specific languages using XeTeX syntax:

\newfontfamily\hebrewfont{FreeSans}
\newfontfamily{\devanagarifont}{Sanskrit 2003}

etc.

Then, in the lyx document, highlight the text in the foreign language, right click and select the 'language' option. You can choose the language first time by selecting "More Languages ...". After that, any used languages will appear in the submenu for ease of use.

The example below uses other languages and fonts, but you should get the idea.

#LyX 2.1 created this file. For more info see http://www.lyx.org/
\lyxformat 474
\begin_document
\begin_header
\textclass article
\begin_preamble
\newfontfamily\hebrewfont{FreeSans}
\end_preamble
\use_default_options false
\maintain_unincluded_children false
\language australian
\language_package default
\inputencoding auto
\fontencoding default
\font_roman Linux Libertine O
\font_sans default
\font_typewriter default
\font_math auto
\font_default_family default
\use_non_tex_fonts true
\font_sc false
\font_osf false
\font_sf_scale 100
\font_tt_scale 100
\graphics default
\default_output_format pdf4
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 0
\use_package cancel 0
\use_package esint 1
\use_package mathdots 0
\use_package mathtools 0
\use_package mhchem 0
\use_package stackrel 0
\use_package stmaryrd 0
\use_package undertilde 0
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date false
\justification true
\use_refstyle 0
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 3
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 1
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header

\begin_body

\begin_layout Standard
Genesis 1:1
\begin_inset space \hfill{}
\end_inset


\lang hebrew
בראשית ברא אלהים
\lang australian

\end_layout

\end_body
\end_document

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.