1

No problem. Thank you. I use the Malayalam package, type in Latin script , save as *.mm file, raun it through the mal preprocessor to generate a tex file. Using polyglossia to type in Malayalam is difficult as I haven't got a good keyboard. The available ones that know of are extremely poor and type in the terrible new script. Solution: is there a possibility to generate the numbers using a style file? I don't know how to write one.

Srinath
  • 63
  • 4

1 Answers1

3

The babel and polyglossia packages both support Malayalam. You will need to compile your documents with either XeLaTeX or a version of LuaLaTeX from 2020 or later.

As a nice bonus, you can type in the Malayalam script the same way you normally do, and use any fonts you could use in your word processor. You will also get hyphenation patterns for your language.

Updated Answer

Based on your comments, you wanted to use the Rachana font and Malayalam numbering. Although the localized string for “Contents” appears to be set correctly by default, at least so far as I can tell, I demonstrate how to set it with \renewcommand\malayalamcontentsname.

\tracinglostchars = 2 % Print a warning to the console if a glyph is missing.
\documentclass{article}
\usepackage[paperwidth=10cm]{geometry} % To format a MWE on TeX.SX
\usepackage[english, bidi=default, layout=sectioning.counters]{babel}
\usepackage{fontspec}

\babelprovide[import,maparabic,main]{malayalam}

\defaultfontfeatures{Scale=MatchLowercase} \babelfont{rm} [Scale=1.0, Ligatures={Common,Rare,TeX}]{Linux Libertine O} \babelfont{sf} [Ligatures={Common, Rare, TeX}]{Linux Biolinum O} \babelfont[malayalam]{rm} {Rachana}

\newcommand\textmalayalam[1]{\foreignlanguage{malayalam}{#1}} \newenvironment{malayalam}% {\begin{otherlanguage}{malayalam}}% {\end{otherlanguage}} \newcommand\textenglish[1]{\foreignlanguage{english}{#1}} \newenvironment{english}% {\begin{otherlanguage}{english}}% {\end{otherlanguage}}

\renewcommand\malayalamcontentsname{ഉള്ളടക്കം}

\begin{document} \tableofcontents

\section{മലയാളം} \begin{english} This text is Romanized. \end{english}

\end{document}

Rachana Font Sample

Thia works with LuaLaTeX from TeX Live 2020 or XeLaTeX from TeX Live 2019 (and might work with luahbtex from 2019), but as of June 2020, there’s a bug in TeX Live 2020 that breaks this MWE with XeLaTeX. Javier Bezos suggested the following workaround for now: \babelprovide[import,maparabic,main,typography/prehyphenchar=]{malayalam}

As a quick patch without using babel or polyglossia, you could define a Malayalam font and replace “Contents” with:

\usepackage{fontspec}
\newfontfamily\malayalamfont{Rachana}[Scale=MatchLowercase, Script=Malayalam]
\renewcommand\contentsname{{\malayalamfont ഉള്ളടക്കം}}

Original Answer

\tracinglostchars = 2 % Print a warning to the console if a glyph is missing.
\documentclass{article}
\usepackage[paperwidth=10cm]{geometry} % To format a MWE on TeX.SX
\usepackage{babel}
\usepackage{fontspec}

\babelprovide[import,main]{malayalam}

\defaultfontfeatures{Scale=MatchLowercase} \babelfont{rm} {Noto Serif} \babelfont{sf} {Noto Sans} \babelfont{tt} {Noto Sans Mono} \babelfont[malayalam]{rm} {Noto Serif Malayalam} \babelfont[malayalam]{sf} {Noto Sans Malayalam}

\begin{document} \tableofcontents

\section{മലയാളം} \end{document}

Noto font sample

In the current version of babel, \babeltags{malayalam = malayalam} ought to define the \textmalayalam command and malayalam environment more simply.

I apologize for any errors in the document, since I don’t speak Malayalam.

If you prefer, polyglossia has supported Malayalam since version 1.2. You can add compatibility with the most common polyglossia commands in babel using:

\newcommand\textmalayalam[1]{\foreignlanguage{malayalam}{#1}}
\newenvironment{malayalam}{\begin{otherlanguage}{malayalam}}{\end{otherlanguage}}
Davislor
  • 44,045
  • Thank you. Unfortunately this does not help. Typing in Malayalam is unfortunately not so good, as the script used is the terrible modern one, which is not only ugly but also extremely difficult to read.

    The question would be is there any other solution such as redefining the command

    – Srinath May 28 '20 at 20:04
  • @Srinath As requested, I have updated my answer to use the Rachana font and Malayalam page/section numbering. – Davislor May 28 '20 at 22:49
  • Thanks. I shall try this tonight. It looks really promissing – Srinath May 29 '20 at 06:13
  • Excellent! A million Thanks. the "Contents" was changed to the form I wished (old script). The number remained unchanged. Is there a way to get the numbers to be in Malayalam as well? That would make the document completely in Malayalam. (The appendix should be in Malayalam numbers as well. Not sure, if I wish to add an appendix. But if the numbers could be done in Malayalam, I shall have the complete document in Malayalam) – Srinath May 30 '20 at 20:28
  • @Srinath The code at the top of my answer ought to change every counter that uses \arabic. You can also use, e.g., \malayalamdigits{42} or \malayalamcounter{page}. – Davislor May 31 '20 at 17:42
  • Do you mean these – Srinath May 31 '20 at 19:14
  • @Srinath I think you might have meant to post a link, but it didn’t paste correctly? – Davislor May 31 '20 at 23:02
  • Not a link but I posted the code (copied and pasted). but it somehow did not happen.I meant this \newcommand\textmalayalam[1]{\foreignlanguage{malayalam}{#1}} \newenvironment{malayalam}{\begin{otherlanguage}{malayalam}{\end{otherlanguage}} – Srinath Jun 01 '20 at 10:43
  • @Srinath Those just let you use the same commands as polyglossia (which are shorter, and also makes it more convenient to migrate between babel and polyglossia if you need to). If you use the first template, most references should use Malayalam numbering. You might need to change counters that use alph or roman, or write \malayalamdigits here or there. – Davislor Jun 01 '20 at 16:55
  • I just copied the original code (above) and processed with xelatex

    I got an error ! Package babel Error: You haven't specified a language option.

    what could be wrong? I used your code without changing anything.

    – Srinath Jun 02 '20 at 22:52
  • @Srinath I can’t duplicate your bug in TeX Live 2020, but I think I have a fix. – Davislor Jun 02 '20 at 23:13
  • @Srinath It looks as if there’s a pretty serious bug with \babelfont in the current version of TeX Live. I’ll see if I can isolate it. Not sure yet whether it’s a fontspec or a babel bug. Thanks. You might try removing the \babelprovide[input]{english} line and changing to \usepackage[english,bidi=default,layout=sectioning]{babel} instead. Or, as a workaround, compiling with luahbtex or lualatex from 2020 instead. – Davislor Jun 02 '20 at 23:49
  • not sure we are speaking about the same code. I don't find \babelprovide[input]{english} in the code I copied. The code I used is the one directly under the title "original answer". I used xelatex engine to process.

    were you mentioning another code?

    – Srinath Jun 03 '20 at 11:07
  • @Srinath I edited my answer, and the version on top might work for you. There seems to be some bug with \babelfont and XeTeX in TeX Live 2020, but it definitely works with the latest version of LuaLaTeX. – Davislor Jun 03 '20 at 15:43
  • Thank you for your efforts to help. I have never used luatex. I processed the file using xelatex. I don't know how to add an attachment here.

    I get the following error

    ! Package babel Error: There is no ini file for the requested language (babel) (). Perhaps you misspelled it or your installation (babel) is not complete..

    – Srinath Jun 04 '20 at 20:50
  • @Srinath I tested the version currently at the top of my answer with XeLaTeX in TeX Live 2019 and with LuaLaTeX from TeX Live 2020. Currently, a bug in TeX Live 2020 breaks it with XeLaTeX. I’d use one of those two engines, or any future versions. – Davislor Jun 04 '20 at 21:20
  • Here is a workaround: \babelprovide[import,maparabic,main,typography/prehyphenchar=]{malayalam}. But it seems a problem in fontspec. – Javier Bezos Jun 06 '20 at 11:38
  • @JavierBezos Thanks. – Davislor Jun 06 '20 at 13:41
  • @JavierBezos Thank you. I shall try – Srinath Jun 08 '20 at 06:13
  • @JavierBezos If may request, could you post a a bare minimum code which I could test on my machine. (with the malayalam package by Alex). I shall be ever so grateful – Srinath Jun 18 '20 at 22:29
  • @Srinath Sorry, but I don't know the malalayam package. I can help with babel. – Javier Bezos Jun 19 '20 at 08:32
  • No problem. Thank you. I use the Malayalam package, type in Latin script , save as *.mm file, raun it through the mal preprocessor to generate a tex file. Using polyglossia to type in Malayalam is difficult as I haven't got a good keyboard. The available ones that know of are extremely poor and type in the terrible new script. Solution: is there a possibility to generate the numbers using a style file? I don't know how to write one. Admin: please delete any duplicate comment from me. – Srinath Jun 20 '20 at 09:20
  • @Srinath On Linux, using Gnome, an alternative is to define an XIM mapping with your Compose key that generates Malayalam characters. This lets you pick any of several keys, such as AltGr, Menu or Windows, as your Compose key. You then could define Compose + k + a + a as ക and Compose + k + a + i as കൈ. I don’t know how well that works for you. And then you can type in Malayalam like you can type Compose + - to get ± and Compose - - to get —. – Davislor Jun 20 '20 at 15:05
  • @Davislor Thank you. That is something totally new to me. Not sure, whether I understand all that, but I need to read up on this and try this out. Difficulty with Malayalam is that we have a few special letters that are difficult to render. I shall try this and revert. Need a bit of time though. – Srinath Jun 20 '20 at 19:18