\documentclass{barticle}
\title{EkiT pRbn/dh} \author{Ajana elkhk} \date{pNNicesh {oi}bshakh, 1413}
\begin{document}
\bng
\maketitle
\section{pRthm pirec/chd}
rbiin/dRnaethr EkiT kibtar shuru inec ed{O}ya Hl.
\begin{verse}
kt Ajanaer jana{I}el tuim \\ kt gher idel ThNNa{I}. \\
duurek kirel inkT bn/dhu,\\ prek kirel bha{I}....
\end{verse}
\end{document}
[Tex/LaTex] How to write Bengali in LaTeX
indiclanguages
Related Solutions
This has been answered in the comments on the question by Arun Debray (also at the other question) and by Will Robertson, fontspec developer; just turning it into an "answer" to get this question off the unanswered list.
Briefly, in the command
\newfontfamily\bengalifont{Noto Sans Bengali}[Script=Bengali]
the Script=Bengali
is just a convenience, part of fontspec's pre-defined mapping of common names to OpenType script tags. As documented in section "Defining new scripts and languages" of the fontspec manual, you can define your own scripts with \newfontscript
.
Thus, if you wish, you can forget about the default fontspec-defined Script=Bengali
and define your own explicitly:
\documentclass[a4paper]{article}
\usepackage{geometry,fontspec,polyglossia}
\setmainlanguage[variant=british]{english}
\setotherlanguage{bengali}
\newfontscript{BengaliOpenTypeOld}{beng}
\newfontscript{BengaliOpenTypeNew}{bng2}
\newfontfamily\bengalifont{Noto Sans Bengali}[Script=BengaliOpenTypeNew]
\begin{document}
x, y, z whatever\dots
\begin{bengali}
আমি
\end{bengali}
\end{document}
and switch between Script=BengaliOpenTypeNew
and Script=BengaliOpenTypeOld
as you wish.
Aside: The rest of this answer is completely tangential, but somewhat related to the motivation for asking this question (looking at the other question): the reason XeTeX is required and LuaTeX does not give correct results (currently) is that XeTeX uses the system libraries—such as Harfbuzz—for complex text layout aka text shaping (glyph reordering, glyph positioning, etc.), while LuaTeX hopes to minimize external dependencies and implement everything in Lua code, and this (IMO highly ambitious) work has, at the moment, simply not been done for Indic scripts other than reasonable support for Devanagari script and some basic support for Malayalam script. (See font-odv.lua in ConTeXt source code.)
For example, the word "আমি" consists of three Unicode "characters" (codepoints) in this order:
where the glyph for the vowel-sign needs to be placed to the left of the consonant. This is done by Harfbuzz (or on Windows, possibly DirectWrite),
but in LuaTeX the glyphs are picked from the font and simply placed one after another meaninglessly:
The algorithms
bundle provides the user with the flexibility to change things to suit their needs, albeit somewhat manually. To that end, I suggest creating a language-specific environment to manage the languages you're using, say frenchalgorithm
and englishalgorithm
:
\documentclass{article}
\usepackage{algorithm,algorithmic,lipsum}
\usepackage[T1]{fontenc}
\usepackage[french,english]{babel}
\newenvironment{englishalgorithm}[1][]
{\begin{algorithm}[#1]
\selectlanguage{english}%
\floatname{algorithm}{Algorithm}%
\renewcommand{\algorithmicif}{\textbf{if}}%
\renewcommand{\algorithmicthen}{\textbf{then}}%
\renewcommand{\algorithmicend}{\textbf{end}}%
% Set other language requirements
}
{\end{algorithm}}
\newenvironment{frenchalgorithm}[1][]
{\begin{algorithm}[#1]
\selectlanguage{french}%
\floatname{algorithm}{Algorithme}%
\renewcommand{\algorithmicif}{\textbf{si}}%
\renewcommand{\algorithmicthen}{\textbf{alors}}%
\renewcommand{\algorithmicend}{\textbf{fin}}%
% Set other language requirements
}
{\end{algorithm}}
\begin{document}
\lipsum[1]
\begin{englishalgorithm}[H]
\caption{An algorithm}
\begin{algorithmic}[1]
\STATE This is a statement
\IF{abc}
\STATE This is another statement
\ENDIF
\end{algorithmic}
\end{englishalgorithm}
\begin{frenchalgorithm}[H]
\caption{Another algorithm}
\begin{algorithmic}[1]
\STATE This is a statement
\IF{abc}
\STATE This is another statement
\ENDIF
\end{algorithmic}
\end{frenchalgorithm}
\lipsum[2]
\end{document}
You'd have to define each of the translated keywords manually. The same would go if you were using the algorithmicx
package.
More about the above changes is briefly discussed in sections 3.14.3 Customization and 4.4 Customization of the algorithms
documentation.
I don't speak French...
Best Answer
Although it's not completely clear what your question is asking, I would recommend using XeLaTeX and the
polyglossia
package for Bengali. This way you just enter your Bengali text in regular form.I used the Akaash font from here: Free Bangla Fonts. Since I don't speak Bengali, I translated a short text from English using Google Translate. My apologies if it did an awful translation.
As the example shows, and as mentioned in the comments, this does not make all numerals Bengali. For a solution to this problem, see: