summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/latexbangla/latexbangla.sty
blob: 71ffb3549f1bc583f0ec4fbd4a514a296b69cba6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
% ----------------------------------------------------------------
% LaTeXbangla package - Enhanced LaTeX integration for Bangla 
% E-mail: adib.hasan8@gmail.com
% Released under the LaTeX Project Public License v1.3c or later
% See http://www.latex-project.org/lppl.txt
% ----------------------------------------------------------------
% This package simplifies the process of writing Bangla in LaTeX and
% addresses most of the common typesetting issues. Additional features
% include automatic transition between languages and many more. (See 
% examples) The user can just type in usual LaTeX syntax and expect 
% everything to work as it should.
% ------------------------------------------------------------------ 
% Copyright (C) 2016 by Adib Hasan adib.hasan8@gmail.com

% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License (LPPL), either
% version 1.3c of this license or (at your option) any later
% version. The latest version of this license is in the file:

% http://www.latex-project.org/lppl.txt

% This work is "maintained" (as per LPPL maintenance status) by
% Adib Hasan

% This work consists of the files:  latexbangla.sty,
%                                   latexbangla.tex, and
%                                   latexbangla.pdf
%
% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{latexbangla}[2016/10/31 v0.2 Enhanced LaTeX integration for Bangla]

\RequirePackage{polyglossia, fontspec, xkeyval, ifxetex}

% Because this package depends on ucharclasses which itself
% requires XeTeX's interchar classes
\RequireXeTeX

%Fully supported Bangla Fonts
%Other banglafonts *are* supported but there might be issues with whitespaces.
\def\@@Kalpurush{Kalpurush}
\def\@Kalpurush#1{
	\ifcase#1{Kalpurush}    %name
	\or{MatchLowercase}     %Scale
	\or{1.1}                %main WordSpace
	\or{1.5}                %tt WordSpace
	\else\fi
}
\def\@@SiyamRupali{SiyamRupali}
\def\@SiyamRupali#1{
	\ifcase#1{SiyamRupali}  %name
	\or{0.8}                %Scale
	\or{1.2}                %main WordSpace
	\or{1.8}                %tt WordSpace
	\else\fi
}
\def\@@SolaimanLipi{SolaimanLipi}
\def\@SolaimanLipi#1{
	\ifcase#1{SolaimanLipi} %name
	\or{0.9}                %Scale
	\or{1.5}                %main WordSpace
	\or{2.1}                %tt WordSpace
	\else\fi
}

\DeclareOptionX{banglamainfont}{%
	\if\relax\detokenize{#1}\relax
		\errmessage{Bangla main font not defined}	
	\else
		\def\bm@name{#1}
		\def\bm@@name{bmfont}
		\bm@init{\bm@name}
    \fi
}
\DeclareOptionX{banglattfont}{%
	\if\relax\detokenize{#1}\relax	
		\errmessage{Bangla tt font not defined}
	\else
		\def\btt@name{#1}
		\def\btt@@name{bttfont}
		\btt@init{\btt@name}
    \fi
}

\newif\if@none	
\newif\if@recom
\newif\if@full	
\@recomtrue
\DeclareOptionX{feature}{		
	\if\relax\detokenize{#1}\relax\fi
	\ifcase#1
		\@recomfalse		
		\@nonetrue
	\or\or\@fulltrue\fi
}

\newif\ifchange@num
\change@numtrue
\DeclareOptionX{changecounternumbering}{
	\if\relax\detokenize{#1}\relax\fi
	\ifcase#1\change@numfalse\fi
}

\def\bm@init#1{
	\ifx#1\@@Kalpurush
    	\def\bm@scale{\@Kalpurush{1}}
    	\def\bm@wordspace{\@Kalpurush{2}}
	\else\ifx#1\@@SiyamRupali
    	\def\bm@scale{\@SiyamRupali{1}}
    	\def\bm@wordspace{\@SiyamRupali{2}}
    \else\ifx#1\@@SolaimanLipi
    	\def\bm@scale{\@SolaimanLipi{1}}
    	\def\bm@wordspace{\@SolaimanLipi{2}}
	\else
	    \def\bm@scale{MatchLowercase}
    	\def\bm@wordspace{1}
    \fi\fi\fi
}
\def\btt@init#1{	
	\ifx#1\@@Kalpurush
    	\def\btt@scale{\@Kalpurush{1}}
    	\def\btt@wordspace{\@Kalpurush{3}}
	\else\ifx#1\@@SiyamRupali
    	\def\btt@scale{\@SiyamRupali{1}}
    	\def\btt@wordspace{\@SiyamRupali{3}}
    \else\ifx#1\@@SolaimanLipi
    	\def\btt@scale{\@SolaimanLipi{1}}
    	\def\btt@wordspace{\@SolaimanLipi{3}}
	\else
		\def\btt@scale{MatchLowercase}
    	\def\btt@wordspace{1.2}    
    \fi\fi\fi
}

\ProcessOptionsX\relax

%From polyglossia
\ifchange@num
	\setmainlanguage[changecounternumbering=true]{bengali}
\else
	\setmainlanguage{bengali}
\fi

\newfontfamily\bengalifont[%
	Script=Bengali,% 
	Scale=\bm@scale,%
	NFSSFamily=\bm@@name,%
	WordSpace=\bm@wordspace,%
	AutoFakeSlant,
	AutoFakeBold
	]{\bm@name}

\newfontfamily\bengalifonttt[%
	Script=Bengali,% 
	Scale=\btt@scale,%
	NFSSFamily=\btt@@name,
	WordSpace=\btt@wordspace,%
	AutoFakeSlant,
	AutoFakeBold
	]{\btt@name}

\newenvironment{latin}{\fontencoding{OT1}\ifx\f@family\btt@@name\fontfamily{lmtt}\else\fontfamily{lmr}\fi\selectfont}\relax

%Devanagari is required since Bangla fullstop dari ("0964) is in
%Devanagari block of Unicode
\RequirePackage[Latin, Bengali, Devanagari]{ucharclasses}
\setTransitionsForLatin{\begin{latin}}{\end{latin}}

%if feature=0 is provided no other modifications will be enabled
%However, from my personal experience, I find the following modifications to be useful.

%the default for feature option is 1, which enables the recommended modifications
\if@recom
	\RequirePackage{titlesec, amsthm, xpatch, amsfonts, amssymb, amsmath, enumerate, chngcntr, hyperref}
	%adding a dot after the number in titles
	\titlelabel{\thetitle.\enspace}
	
	%making the word "proof" in proof env. bold and adding a : after it.	
	\xpatchcmd{\proof}{\itshape}{\bfseries}{}{}
	\xpatchcmd{\proof}{\@addpunct{.}}{\@addpunct{:}}{}{}
		
	\counterwithin{equation}{section}

	\renewcommand\UrlFont{\fontencoding{OT1}\fontfamily{lmtt}\selectfont}

	%increases gap between lines	
	\linespread{1.1}
	
	%defining a \tobangla which converts numbers in any counter to bangla 	
	\def\@banglanumber#1{\expandafter\@@banglanumber\number#1\@nil}
	\def\@@banglanumber#1{\ifx#1\@nil
	\else\char\numexpr#1+"09E6\relax\expandafter\@@banglanumber\fi}
	\def\tobangla#1{\expandafter\@banglanumber\csname c@#1\endcsname}
	\def\numtobangla#1{\@@banglanumber#1\@nil}
	
	%Because polyglossia itself defines প্রমাণ as italic. I'm making it bold.	
	\addto\captionsbengali{\renewcommand\proofname{\bfseries প্রমাণ}}
	
	%a new solution environment	
	\newenvironment{solution}{\proof[\bfseries সমাধান]}{\endproof}
	
	\newtheoremstyle{custom}% name
	{3pt}% space above
	{3pt}% space below
	{\rm}% body font
	{}% indent amount
	{\bfseries}% theorem head font
	{:}% punctuation after theorem head
	{.5em}% space after theorem head
	{}% theorem head spec
	\theoremstyle{custom}
	\newtheorem{example}{\bfseries উদাহরণ}
	\newtheorem{problem}{\bfseries সমস্যা}
	\newtheorem{theorem}{\bfseries উপপাদ্য}[section]
	
	%converting all the useful counters not handled by polyglossia to bangla	
	\renewcommand{\theequation}{\thesection.\tobangla{equation}}
	\renewcommand{\thetheorem}{\thesection.\tobangla{theorem}}
	\renewcommand{\theexample}{\tobangla{example}}
	\renewcommand{\theproblem}{\tobangla{problem}}
	\renewcommand{\theenumi}{\tobangla{enumi}}
	\renewcommand{\theenumii}{\tobangla{enumii}}
	\renewcommand{\theenumiii}{\tobangla{enumiii}}
	\renewcommand{\thefootnote}{\tobangla{footnote}}
\fi

%feature=2 enabes further modifiations as follows
\if@full
	\RequirePackage{titlesec, amsthm, xpatch, amsfonts, amssymb, amsmath, enumerate, chngcntr}
	\theoremstyle{custom}
	\newtheorem{corollary}{\bfseries অনুসিদ্ধান্ত}[section]
	\newtheorem{property}{\bfseries বৈশিষ্ট্য}[section]
	\newtheorem*{remark}{\bfseries মন্তব্য}
	\newtheorem*{hint} {\bfseries হিন্ট}
	\renewcommand{\thecorollary}{\thesection.\tobangla{corollary}}
	\renewcommand{\theproperty}{\thesection.\tobangla{property}}
	\addto\captionsbengali{\renewcommand\abstractname{\bfseries সারসংক্ষেপ}}
	%\addto\captionsbengali{\renewcommand\referencename{\bfseries তথ্যসূত্রসমূহ}}
	\newenvironment{motive}{\proof[\bfseries মোটিভেশন]}{\phantom\qedhere\endproof}
	\def\equationautorefname~#1\null{(#1)\null}
\fi
\endinput