From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/tram/tram.sty | 140 +++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 macros/latex/contrib/tram/tram.sty (limited to 'macros/latex/contrib/tram/tram.sty') diff --git a/macros/latex/contrib/tram/tram.sty b/macros/latex/contrib/tram/tram.sty new file mode 100755 index 0000000000..88cf158d7d --- /dev/null +++ b/macros/latex/contrib/tram/tram.sty @@ -0,0 +1,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 +%% +%% 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'. -- cgit v1.2.3