summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tram/tram.sty
blob: 88cf158d7d62ec1ee12dd7529a72d1ab36ea1bda (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
%%
%% This is file `tram.sty',

%% 
%%   __________________________________
%%   Copyright © 2011–2013 Persian TeX Group
%% 
%%   License information appended.
%% 
%% 
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tram}[2013/04/04 v0.2 tram boxes in LaTeX]

\newcount\mabnayeteramgozari
\newdimen\@fas
\newcount\@ater
\newcount\@peter
\newbox\@ketram
\newbox\@metram

\def\sotoneteram{\noalign\bgroup\@ifnextchar[{\@setram}{\@setram[\mabnayeteramgozari]}}

\def\@setram[#1]#2{\@tainteram{#1}\@@setram[#2]}

\def\@@setram[#1-#2]#3{%
\global\@ater#1\relax\global\advance\@ater\m@ne
\ifnum\@ater<0 \global\let\@temptokena\@terameyek\else\global\let\@temptokena\@teramedo\fi 
\global\@peter#2\relax\global\advance\@peter-\@ater
\setbox\@ketram\hbox{\ghalameteram\teramemabna}%
\@tempdimb\ht\@ketram \advance\@tempdimb\dp\@ketram
\global\@fas\ht\@arstrutbox \global\advance\@fas\dp\@arstrutbox
\global\@fas #3\@fas
\@tempdima=\@fas \@tempcnta\@tempdima \divide\@tempcnta \@tempdimb
\advance\@tempdima-\@tempcnta\@tempdimb
\ifdim\@tempdima<8\p@ \advance\@tempcnta\@ne\fi
\@tempdima \@tempcnta\@tempdimb
\setbox\@ketram\vbox to \@tempdima{\cleaders\box\@ketram\vfill}%
\global\setbox\@ketram\vbox to \@fas{\vss\box\@ketram\vss}\egroup\@temptokena}  




\def\@terameyek{\multispan\@ater&\@teramedo}

\def\@teramedo{\multispan\@peter\unskip\@ifnextchar[{\@terameseh}{\@ifteramchahar}}

\def\@ifteramchahar{\@ifnextchar>{\@teramechahar}{\@teramechahar>\z@,\z@<}}




\def\@terameseh[#1]{\@tempdima #1\relax\@tempcnta \@tempdima \advance\@tempcnta 200\relax
\divide\@tempcnta \wd\@ketram \@tempdimb \@tempcnta\wd\@ketram
\setbox\@ketram\hbox to \@tempdimb{\cleaders\box\@ketram\hfill}%
\hfill\box\@ketram\hfill\cr\noalign{\vskip-\@fas}}



\def\@teramechahar>#1,#2<{\kern#1\cleaders\box\@ketram\hfill
\kern#2\relax\cr\noalign{\vskip-\@fas}}





\def\@tainteram#1{\count@=#1\relax \@tempcnta=\count@
\divide\@tempcnta by 128
\edef\@tramstep{\ifcase \@tempcnta 482\or 579\or 694\or 833\or 913\or
1000 \or 1095\or 1200\or 1440\or 1728\or 2074\else 2488\fi}%
\multiply\@tempcnta by 128 \advance\count@-\@tempcnta
\font\ghalameteram=tram scaled \@tramstep
\chardef\teramemabna=\count@}




\newenvironment{tram}[1][\mabnayeteramgozari]
{\@tainteram{#1}\setbox\@ketram\hbox\bgroup\ignorespaces}
{\egroup\setbox\@ketram\vbox{\box\@ketram\vskip\z@}%
\setbox\@metram\vbox{\@teramdarabad{\wd\@ketram}{\ht\@ketram}}
\dimen@=\ht\@ketram
\ifdim\dimen@>\ht\@metram \dimen@=\ht\@metram\fi
\setbox\@ketram\vbox to \dimen@{\vss\box\@ketram\vss}%
\setbox\@metram\vbox to \dimen@{\vss\box\@metram\vss}%
\dimen@=\wd\@ketram
\ifdim\dimen@>\wd\@metram \dimen@=\wd\@metram\fi
\setbox\@ketram\hbox to \dimen@{\hss\box\@ketram\hss}%
\setbox\@metram\hbox to \dimen@{\hss\box\@metram\hss}%
\wd\@metram\z@
\ht\@metram\z@
\dp\@metram\z@
\hbox to \dimen@{\box\@metram\box\@ketram}}

                  
                  
                  
                 
\def\@teramdarabad#1#2{{%%
\chardef\behbeh=0           
\dimendef\arzebeh=0
\dimendef\ertebeh=3
\dimendef\dimen@=4
\countdef\tadaar=0
\countdef\tadar=1
\setbox\behbeh=\hbox{\ghalameteram\teramemabna}
\arzebeh=\wd\behbeh
\ertebeh=\ht\behbeh
\dimen@#1\relax
\tadaar\dimen@
\dimen@#2\relax
\tadar\dimen@   
\divide\tadaar by \arzebeh
\divide\tadar by \ertebeh
\dimen@#2\relax
\advance\dimen@-\tadar\ertebeh
\ifdim\dimen@<8\p@ \advance\tadar 2\fi
\dimen@#1\relax
\advance\dimen@-\tadaar\arzebeh
\ifdim\dimen@<8\p@ \advance\tadaar 2\fi   
\hbox{\offinterlineskip
\hbox to \tadaar\arzebeh{\cleaders%
\vbox{\vbox to \tadar\ertebeh{\cleaders\hbox{\copy\behbeh}\vfil}}%%
\hfil}}}}
        
\endinput         
%% 
%% Copyright © 2011–2013      by Persian TeX Group     <persian-tex@tug.org>
%% 
%% 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 Persian TeX Group.
%% 
%% 
%% 
%% 
%%
%% End of file `tram.sty'.