forked from Neehan/book-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bookstyle.sty
362 lines (307 loc) · 12.2 KB
/
bookstyle.sty
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
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
% !TEX root = main.tex
% --------------------------------------------------------------
% Book Style
% --------------------------------------------------------------
% % space between line as percentage
\linespread{1.15}
% % space between paragraphs.
% \setlength{\parskip}{4pt}
% % paragraph indent
\setlength{\parindent}{0pt} % https://www.overleaf.com/learn/latex/Paragraph_formatting#Paragraph_Indentation
% % discourage breaking of footnote text accorss multiple pages.
% \interfootnotelinepenalty=1000
% % to take care of nonbreakingspace issue in EU1 format of the .bbl
% \DeclareTextCommandDefault{\nobreakspace}{\leavevmode\nobreak\ }
% REQUIRED PACKAGES
%%%%%%%%%%%%%%%%%%%%%
% latexbangla with all features
\RequirePackage[banglamainfont=Kalpurush,
banglattfont=Kalpurush,
]{latexbangla}
%activate polyglossia
\setdefaultlanguage[numerals=Bengali,
changecounternumbering=true]{bengali}
%number all levels
\setcounter{secnumdepth}{5}
\setotherlanguage{english}
% \inlcudegraphics
\RequirePackage{graphicx}
% % URL font is latex default Latin Modern Teletype. If you don't like that
% % change it to something else.
% \renewcommand\UrlFont{\fontencoding{OT1}\fontfamily{lmtt}\selectfont}
% % autoref name for example env. when you call "In \autoref{blah}",
% % it will output "In udahoron blah"
% \newcommand\exampleautorefname{উদাহরণ}
% % translating autoref name for existing commands.
% \appto{\blockextras@bengali}{%
% \renewcommand*{\equationautorefname}{সমীকরণ}%
% }
% % \appto{\blockextras@bengali}{%
% % \renewcommand*{\chapterautorefname}{নিবন্ধ}%
% % }
% \appto{\blockextras@bengali}{%
% \renewcommand*{\sectionautorefname}{সেকশন}%
% }
% \appto{\blockextras@bengali}{%
% \renewcommand{\figureautorefname}{চিত্র}%
% }
% title and section formatting
% \RequirePackage{titlesec}
% section sign before section number
% \titleformat{\section}[hang]{\raggedright\Large\bfseries}{{\uccoff\fontfamily{lmr}\selectfont\large§\,\uccon}\thesection}{0.5em}{}
% chapter sign before chapter number
% \titleformat{\chapter}[hang]{\raggedright\Large\bfseries}{{\uccoff\fontfamily{lmr}\selectfont\large§\,\uccon}\thechapter}{0.5em}{}
% % chapter title
% \RequirePackage{xcolor}
% \definecolor{mygray}{RGB}{60,60,60}
% \titleformat{\chapter}[display]
% {\bfseries\color{mygray}}
% {\filleft%
% \begin{tikzpicture}
% \node[
% outer sep=0pt,
% text width=2.4cm,
% minimum height=2.5cm,
% fill=mygray,
% font=\color{white}\fontsize{75}{80}\selectfont,
% align=center
% ] (num) {\thechapter};
% \node[
% rotate=90,
% anchor=south,
% font=\color{black}\Large
% ] at ([xshift=-5pt]num.west) {\chaptertitlename};
% \end{tikzpicture}%
% }
% {-30pt}
% {\fontsize{22}{24}\selectfont}
% % [\titlerule[2.5pt]\vskip3pt\titlerule\vskip4pt]
% [{\titlerule[2.5pt]\vskip3pt\titlerule\vskip-1em}]
% better double border intersection
% \RequirePackage{hhline}
% enlarged first letter
\RequirePackage{lettrine}
\newcommand{\firstword}[2]{\lettrine[lines=3, lraise=0.2, nindent=0pt, findent=2pt]{#1}{#2}}
% table of contents formatting
\RequirePackage{tocloft}
\setlength{\cftbeforetoctitleskip}{0em} % https://tex.stackexchange.com/a/46863/114006
\setlength{\cftaftertoctitleskip}{0em}
\renewcommand{\cftchapaftersnum}{.} % https://tex.stackexchange.com/a/567930/114006
% \renewcommand\cftchapafterpnum{\vskip-5pt} % Decreasing the line spacing between the names of chapters
% % footnote in tables appear the end of page
% \RequirePackage{footnote}
% \makesavenoteenv{tabular}
% better float management
\RequirePackage{placeins}
\usepackage{float} % https://tex.stackexchange.com/a/8633/114006
% % multiple columns
% \RequirePackage{multicol}
% % compilation time decreases significantly with this package
% % although it produces a warning
% \RequirePackage{subfig}
% % breakable tables
\RequirePackage{longtable}
% NEW ENVIRONMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%
% new font for quotation
\newfontfamily\quotefont[%
Scale= 1.1,
WordSpace=1.4,
AutoFakeSlant=1.2,
AutoFakeBold=1.2
]{[Monotype Corsiva]}
% \qtext command for english quote texts
\newcommand\qtext[1]{{\normalfont \uccoff \quotefont #1 \uccon}}
% % \chapquote command for quotes with author or source
% \RequirePackage{xparse} % https://www.texdev.net/2010/05/23/from-newcommand-to-newdocumentcommand/
% \NewDocumentCommand\chapquote{mO{}O{}}{
% \begin{quotation}
% \noindent \itshape{#1}
% \IfValueTF {#2}{
% \vspace*{-0.5\baselineskip}
% \begin{flushright}
% \textemdash \quad \normalfont{#2} \par \footnotesize\itshape{#3}
% \end{flushright}
% }{}
% \end{quotation}
% } % https://tex.stackexchange.com/a/224069/114006
% \quote command for quotes with no author or source
\RenewDocumentCommand\quote{m}{
\begin{quotation}
\noindent \itshape{#1}
\end{quotation}
}
% https://tex.stackexchange.com/a/601754/114006
% \chapquote for quotes
\def\chapquote#1{%
\begin{quotation}
\noindent \itshape{#1}
\futurelet\next\chapquoteA
}
\def\chapquoteA{\ifx\next[\expandafter\chapquoteB\else\expandafter\chapquoteC\fi}
\def\chapquoteB[#1][#2]{%
\vskip.2\baselineskip
\hfill \textemdash \quad
\ifx^#1^\else \normalfont #1\par \hfill \fi
\footnotesize\itshape #2\par
\chapquoteC
}
\def\chapquoteC{\end{quotation}}
% % for customizable boxes
% \RequirePackage[many]{tcolorbox}
%% The below setup if From My preambles of main.tex file
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{docmute}
\RequirePackage{amsmath, amsfonts, amssymb, amsthm}
%\RequirePackage{physics}
\RequirePackage{graphicx}
\RequirePackage{mathtools}
\RequirePackage{extarrows}
% \RequirePackage{enumitem}
\RequirePackage{lipsum}
\RequirePackage{blindtext}
\RequirePackage{mwe}
\RequirePackage[version=4]{mhchem}
\RequirePackage{wrapfig} % https://tex.stackexchange.com/a/56177/114006
\RequirePackage{cprotect} % https://tex.stackexchange.com/a/8814/114006
\RequirePackage[numbered]{bookmark}
\RequirePackage[font=footnotesize, justification=centering]{caption}
\RequirePackage[font=footnotesize, justification=centering]{subcaption} % https://tex.stackexchange.com/a/119985/114006
% \setlist[itemize]{label*={\uccoff\fontfamily{lmr}\selectfont\textbullet \uccon}} % due to the Bangla fonts
\RequirePackage[
papersize={5.5in, 8.5in},
% margin=0.8in,
top=0.8in, bottom=0.8in, left=0.6in, right=0.6in,
headheight=15.04721pt
]{geometry}
\linespread{1.15}
% % For a bilingual document
% \RequirePackage[banglamainfont=Kalpurush,
% banglattfont=Kalpurush,
% ]{latexbangla}
% %activate polyglossia
% \setdefaultlanguage[numerals=Bengali,
% changecounternumbering=true]{bengali}
% %number all levels
% \setcounter{secnumdepth}{5}
% \setotherlanguage{english}
%..............
\RequirePackage[autostyle]{csquotes} % https://tex.stackexchange.com/q/39285/114006
\RequirePackage[dvipsnames,svgnames,x11names,hyperref]{xcolor} % https://tex.stackexchange.com/a/4506/114006
\RequirePackage{hyperref}
\hypersetup{
colorlinks=true, breaklinks,
linkcolor=blue,
filecolor=magenta,
urlcolor=teal,
}
\urlstyle{same}
% Adding header and footer on pages
\RequirePackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{} % clear all header and footer fields
\lhead{\spaceskip=5pt\href{https://github.com/rafisics/ebook-template}{নিবন্ধ সংকলন}}
\rhead{\spaceskip=5pt\href{https://github.com/rafisics/ebook-template}{মুবতাসিম ফুয়াদ}}
\cfoot{\thepage}
\renewcommand{\headrulewidth}{0.5pt}
\renewcommand{\footrulewidth}{0.5pt}
}
% Adding References
% \RequirePackage[backend=biber, sorting=none, language=english, autolang=other]{biblatex}
% \addbibresource{bookbib.bib}
% Adding pdf pages
\RequirePackage{pdfpages}
%to allow long align env. to break between pages
\allowdisplaybreaks
% % https://tex.stackexchange.com/a/177179/114006 (need to improve)
% \tolerance=1
% \emergencystretch=\maxdimen
% \hyphenpenalty=10000
% \hbadness=10000
% Path relative to the main .tex file
\graphicspath{ {./img/} }
% Adding footer on title page https://tex.stackexchange.com/a/199356/114006
\RequirePackage{titling}
% Shift up the title % https://tex.stackexchange.com/a/29594/114006
\setlength{\droptitle}{-5em}
%% Chapter title page style
%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Adding chapter sign and removing the vertical blank space before chapter heading % https://stackoverflow.com/a/3284059/7673979
\RequirePackage{titlesec}
\titleformat{\chapter}[display]
% {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
% {\normalfont\huge\bfseries}{{\Huge\S\,}\ \thechapter}{20pt}{\Huge} % Adding \S sign before on chapter number in English doc with default font
{\raggedright\normalfont\Huge\bfseries}{{\uccoff\fontfamily{lmr}\selectfont\Huge§\,\uccon}\ \thechapter}{20pt}{\Huge} % % Adding \S sign before on chapter number in Bangla doc with latexbangla
\titlespacing*{\chapter} {0pt}{0pt}{40pt} % this alters "before" spacing (the second length argument) to 0
% % Chapter sign before chapter number
% \makeatletter
% \renewcommand{\@chapapp}{{\uccoff\fontfamily{lmr}\selectfont\Huge§\,\uccon}}
% \makeatother
% Adding Chapter Authors after chapter title: https://tex.stackexchange.com/a/156865/114006
\RequirePackage{suffix}
\newcommand\chapterauthor[1]{\authortoc{#1}\printchapterauthor{#1}}
\WithSuffix\newcommand\chapterauthor*[1]{\printchapterauthor{#1}}
\makeatletter
\newcommand{\printchapterauthor}[1]{%
{\parindent0pt\vspace*{-25pt}%
\linespread{1.1}\spaceskip=7pt\Large\scshape#1%
\par\nobreak\vspace*{35pt}}
\@afterheading%
}
\newcommand{\authortoc}[1]{%
\addtocontents{toc}{\vskip-10pt}%
\addtocontents{toc}{%
\protect\contentsline{chapter}%
{\hskip1.5em\mdseries\scshape\protect\spaceskip=4pt\footnotesize#1}{}{}}
\addtocontents{toc}{\vskip-5pt}%
}
\makeatother
% Command for chapter title photo % https://tex.stackexchange.com/a/91620/114006
\newcommand{\chapterphoto}[1]{\includegraphics[width=\textwidth]{#1}\vspace{0.5cm}}
% Adding chapter ending symbol https://tex.stackexchange.com/a/97175/114006
\RequirePackage{pgfornament}
\RequirePackage{xifthen}
\newcommand{\chapterend}{
\par
\vspace{\stretch{1}}
\begin{center}
\pgfornament[width=2.5cm]{84}
\end{center}
\vspace{\stretch{2}}
}
% \newcommand\measurepage{\dimexpr\pagegoal-\pagetotal-\baselineskip\relax}
% \newcommand{\chapterend}{
% \ifthenelse{\lengthtest{\measurepage>150pt}}{\chapterendsymbol}{}}
% Lists with special labels
\newcommand{\bulletlabel}{\raisebox{0.5pt}{\uccoff\fontfamily{lmr}\selectfont\textbullet\uccon}}
\newcounter{myitemizecounter}
\newenvironment{myitemize}
{\begin{list}{\bulletlabel\;\;}{\labelsep=0em \labelwidth=2em}}{\end{list}}
\newcommand{\diamondlabel}{\raisebox{2.5pt}{\includegraphics[height=8pt, angle=135]{listbullet01}}}
\newcounter{mylistcounter}
\newenvironment{mylist}
{\begin{list}{\diamondlabel\;\;}{\labelsep=0em \labelwidth=2em}}{\end{list}}
% Add dot to the end of chapter numbering in PDF bookmarks
\makeatletter
\renewcommand{\Hy@numberline}[1]{#1. } % https://tex.stackexchange.com/a/150984/114006
\makeatother
% To avoid the problem of nameref and titlesec % https://tex.stackexchange.com/a/603305/114006
\makeatletter
\newcommand\setcurrentname[1]{\def\@currentlabelname{#1}}
\makeatother
% Commnad for blank page texts % https://tex.stackexchange.com/a/66901/114006
\newcommand*\bptext{পৃষ্ঠাটি ইচ্ছাকৃতভাবে খালি রাখা হয়েছে}
\makeatletter
\renewcommand*\cleardoublepage{%
\clearpage\if@twoside\ifodd\c@page\else
\vspace*{\fill}
\begin{center}
% \begin{minipage}{.6\textwidth} % https://tex.stackexchange.com/a/70718/114006
\tiny\spaceskip=4pt\bptext
% \end{minipage}
\end{center}
\vfill % equivalent to \vspace{\fill}
% \thispagestyle{plain}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother