Created
June 1, 2020 10:51
-
-
Save javadr/4eabec318631f905368acb53d915732d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%% | |
%%% This is file `basat-complex.cls', | |
%%% Version 0.3 | |
%%% __________________________________ | |
%%% | |
%%% Copyright © 2017-2020 Seiied-Mohammad-Javad Razavian | |
%%% __________________________________ | |
%%% | |
%%% Change Log: | |
%%% ver 0.3, Jun. 1st, 2020 | |
%%% ApartmentInvest won't be printed if there is no tags. | |
%%% ver 0.221, Apr. 20th, 2020 | |
%%% minor modification in ApartmentInvest | |
%%% https://tex.stackexchange.com/questions/418257 | |
%%% ver 0.22, Sep 10th, 2018 | |
%%% Default page sytle is set to empty for the first page. | |
%%% ver 0.21, Nov 19th, 2017 | |
%%% \ctag macro accumulate its contents two/three times in case of using tabularx, by using the solution of David Carlisle the macro just will be called at the last run of tabularx. | |
%%% https://tex.stackexchange.com/questions/401957/tabularx-causes-a-weird-behavior-in-spreadtab-more-expansion-than-needed | |
%%% ver 0.2, Nov 18th, 2017 | |
%%% \ApartmentInvest macro set automaticly the expenditures by every apartment in a tabular environment | |
%%% ver 0.1, Nov 18th, 2017 | |
%%% First Release | |
\NeedsTeXFormat{LaTeX2e}[1994/06/01] | |
\def\bc@date{2017/11/19} | |
\def\bc@version{0.21} | |
\ProvidesClass{besat-complex}[% | |
\bc@date\space version\bc@version\space Style for Revenue and Expenditures of Be'sat Complex.'% | |
] | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{book}} | |
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{xepersian}} | |
\ProcessOptions\relax | |
\LoadClass[a4paper]{article} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\RequirePackage[top=1.5cm,bottom=2.5cm,left=1.5cm,,right=1.5cm,a4paper]{geometry} | |
\RequirePackage{booktabs} | |
\RequirePackage{amsmath} | |
\RequirePackage{array} | |
%\newcolumntype{C}[1]{>{\centering\arraybackslash$}c<{$}} | |
\RequirePackage{tabularx} | |
\RequirePackage{spreadtab} | |
\RequirePackage{xpatch} | |
\RequirePackage{xparse} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\AtEndPreamble{% | |
\RequirePackage[]{xepersian} | |
\settextfont[Scale=1.1]{XB Niloofar} | |
\setlatintextfont{Linux Libertine} | |
\setdigitfont{Yas} | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
% because of new verison of bidi(30.2) and xepersian(20.1) there is no need to the following code. | |
\defpersianfont\yasfont{Yas} | |
% %کدهای زیر سبب نگارش تمامی ارقام با قلم یاس میگردد. (در این قلم صفرها به صورت صحیح و توخالی نگاشته میشوند.) | |
%\if@bidi@csundef{bidi@digits}{% | |
% \newcount\bidi@digits | |
% \XeTeXinterchartokenstate=\@ne | |
% \newXeTeXintercharclass\bidi@digits@charclass | |
% \bidi@digits=`\0 \loop \XeTeXcharclass \bidi@digits \bidi@digits@charclass \ifnum\bidi@digits<`\9 \advance\bidi@digits \@ne \repeat | |
% \bidi@digits=`\۰ \loop \XeTeXcharclass \bidi@digits \bidi@digits@charclass \ifnum\bidi@digits<`\۹ \advance\bidi@digits \@ne \repeat | |
% }{} | |
% \newif\if@q@verbatim | |
% \bidi@appto\verbatim@font{\@q@verbatimtrue} | |
% \bidi@appto\ttfamily{\@q@verbatimtrue} | |
% \newXeTeXintercharclass\q@leftparen@charclass | |
% \newXeTeXintercharclass\q@rightparen@charclass | |
% \XeTeXcharclass `\( \q@leftparen@charclass | |
% \XeTeXcharclass `\) \q@rightparen@charclass | |
% \XeTeXcharclass `\[ \q@leftparen@charclass | |
% \XeTeXcharclass `\] \q@rightparen@charclass | |
% \XeTeXcharclass `\{ \q@leftparen@charclass | |
% \XeTeXcharclass `\} \q@rightparen@charclass | |
% \XeTeXcharclass `\« \q@leftparen@charclass | |
% \XeTeXcharclass `\» \q@rightparen@charclass | |
% \XeTeXcharclass `\، \q@leftparen@charclass | |
% \XeTeXcharclass `\, \q@leftparen@charclass | |
% \XeTeXcharclass `\؛ \q@leftparen@charclass | |
% \XeTeXcharclass `\; \q@leftparen@charclass | |
% \XeTeXcharclass `\: \q@leftparen@charclass | |
% \XeTeXcharclass `\. \q@leftparen@charclass | |
% \XeTeXcharclass `\- \q@leftparen@charclass | |
% \ifdim\the\XeTeXversion\XeTeXrevision\p@>0.99993\p@ | |
% \chardef\q@alloc@intercharclass@top=4095 | |
% \else | |
% \chardef\q@alloc@intercharclass@top=255 | |
% \fi | |
% \chardef\q@CharNormal=0 | |
% \XeTeXinterchartoks \q@alloc@intercharclass@top \bidi@digits@charclass = {\BeginSwitchDigitFont} | |
% \XeTeXinterchartoks \bidi@digits@charclass \q@alloc@intercharclass@top = {\EndSwitchDigitFont} | |
% \XeTeXinterchartoks \q@leftparen@charclass \bidi@digits@charclass = {\BeginSwitchDigitFont} | |
% \XeTeXinterchartoks \bidi@digits@charclass \q@rightparen@charclass = {\EndSwitchDigitFont} | |
% \XeTeXinterchartoks \q@rightparen@charclass \bidi@digits@charclass = {\BeginSwitchDigitFont} | |
% \XeTeXinterchartoks \bidi@digits@charclass \q@leftparen@charclass = {\EndSwitchDigitFont} | |
% \XeTeXinterchartoks \q@CharNormal \bidi@digits@charclass = {\BeginSwitchDigitFont} | |
% \XeTeXinterchartoks \bidi@digits@charclass \q@CharNormal = {\EndSwitchDigitFont} | |
% \if@bidi@csundef{if@nonlatin}{% | |
% \newcommand*{\BeginSwitchDigitFont}{\if@q@verbatim\else% | |
% \global\edef\currentfont{\the\font}\if@Latin\else\bgroup\yasfont \fi\fi} | |
% \newcommand*{\EndSwitchDigitFont}{\if@q@verbatim\else\if@Latin\else\egroup\currentfont \fi\fi} | |
% }{% | |
% \newcommand*{\BeginSwitchDigitFont}{\if@q@verbatim\else% | |
% \global\edef\currentfont{\the\font}\if@nonlatin\bgroup\yasfont \fi\fi} | |
% \newcommand*{\EndSwitchDigitFont}{\if@q@verbatim\else\if@nonlatin\egroup\currentfont \fi\fi} | |
% } | |
} % end of preamble | |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
\newcounter{tabline} | |
%https://tex.stackexchange.com/questions/401957/tabularx-causes-a-weird-behavior-in-spreadtab-more-expansion-than-needed | |
\newif\ifctag | |
\gdef\ctag#1{\global\ctagtrue\ifx\@footnotetext\TX@trial@ftn\else | |
\addtocounter{tabline}{-1}\@ifundefined{c#1}% | |
{\expandafter\xdef\csname c#1\endcsname{\thetabline}}{\expandafter\bidi@xappto\csname c#1\endcsname{,\thetabline}}\addtocounter{tabline}{1}\fi} | |
\def\gettag#1{\csname c#1\endcsname} | |
%%% https://tex.stackexchange.com/questions/284661/write-conditionnally-rows-of-a-tabular-with-spreadtab | |
%%%%%%%%%%%%%%%%%% | |
\makeatother % in spreadtab @ has different category code | |
\newcommand{\charge}[4]{@ & @ \LR{#1} | |
& @ حقّ شارژ & | |
@ واحد #2 #4 & #3 && \\} | |
\makeatletter | |
\ExplSyntaxOn | |
\DeclareDocumentCommand{\tcharge}{mmgg}{@ & @ #1 | |
& @ حقّ شارژ & | |
@ واحد #2 | |
\IfNoValueTF{#4}{}{#4} & | |
\IfNoValueTF{#3}{300000}{#3} \\} | |
\ExplSyntaxOff | |
%%%%%%%%%%%%%%%%%% | |
%%% https://tex.stackexchange.com/questions/201109/textual-replacement-within-spreadtab | |
\def\spreadtab@ii{\IfSubStr\ST@tab{\noexpand\+}{\expandafter\spreadtab@iii\ST@tab\@nil}{}} | |
\def\spreadtab@iii#1\+#2#3\@nil{\edef\ST@tab{\unexpanded{#1}\unexpanded\expandafter{#2#3}}\spreadtab@ii}% | |
\xpretocmd\spreadtab@i\spreadtab@ii{}{} | |
% | |
\newcommand\ApartmentInvest{% هزینههای صورت گرفته توسط هر واحد | |
\ifctag | |
\begin{center} | |
هزینههای صورت گرفته (و تسویه نشده) از جدول فوق به شرح زیر است. | |
\begin{tabular}{|r|r||r|r||r|r|}\toprule | |
واحد & ردیف هزینهها & واحد & ردیف هزینهها & واحد & ردیف هزینهها \\\midrule | |
واحد ۱ & \gettag{1} & | |
واحد ۲ & \gettag{2} & | |
واحد ۳ & \gettag{3} \\\midrule | |
واحد ۴ & \gettag{4} & | |
واحد ۵ & \gettag{5} & | |
واحد ۶ & \gettag{6} \\\bottomrule | |
\end{tabular} | |
\end{center} | |
\fi} | |
% | |
\AtBeginDocument{ | |
\baselineskip=.8cm | |
\maketitle | |
\parindent=\z@ | |
\thispagestyle{empty} | |
} | |
% | |
\endinput | |
%% | |
%% Copyright © 2017 by Seiied-Mohammad-Javad Razavian | |
%% | |
%% Distributable under the LaTeX Project Public License, | |
%% version 1.3c or higher (your choice). The latest version of | |
%% this license is at: http://www.latex-project.org/lppl.txt | |
%% | |
%% This work is "maintained" (as per LPPL maintenance status) | |
%% by Seiied-Mohammad-Javad Razavian | |
%% | |
%% ____________________________________________________________________ | |
%% Special thanks to Vafa Khalighi for the XePersian Package. | |
%% End of file `besat-complex.cls'. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment