diff options
author | Karl Berry <karl@freefriends.org> | 2014-10-20 22:05:52 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2014-10-20 22:05:52 +0000 |
commit | 260823c9f5fb93d95ec358ad5a70f066c31a76e7 (patch) | |
tree | 1208699b196c527469413f52adebf7b80bb796a6 /Master/texmf-dist/tex/latex/basicarith | |
parent | a8c9ce4d3dc5e2c778bd5a76caf03ee6db726e04 (diff) |
basicarith (20oct14)
git-svn-id: svn://tug.org/texlive/trunk@35408 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/basicarith')
-rw-r--r-- | Master/texmf-dist/tex/latex/basicarith/basicarith.sty | 287 |
1 files changed, 287 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/basicarith/basicarith.sty b/Master/texmf-dist/tex/latex/basicarith/basicarith.sty new file mode 100644 index 00000000000..a91f1328e94 --- /dev/null +++ b/Master/texmf-dist/tex/latex/basicarith/basicarith.sty @@ -0,0 +1,287 @@ +%% +%% This is file `basicarith.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% basicarith.dtx (with options: `package') +%% This is a generated file. +%% +%% This document is copyright 2014 by Donald P. Goodman, and is +%% released publicly under the LaTeX Project Public License. The +%% distribution and modification of this work is constrained by the +%% conditions of that license. See +%% http://www.latex-project.org/lppl.txt +%% for the text of the license. This document is released +%% under version 1.3 of that license, and this work may be distributed +%% or modified under the terms of that license or, at your option, any +%% later version. +%% +%% This work has the LPPL maintenance status 'maintained'. +%% +%% The Current Maintainer of this work is Donald P. Goodman +%% (dgoodmaniii@gmail.com). +%% +%% This work consists of basicarith.dtx, basicarith.ins, and +%% derived files basicarith.sty and basicarith.pdf. + +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{basicarith}[2015/01/01 v1.0 support for typesetting basic arithmetic in the American fashion] +\newif\ifshowdivisionwork % switch for drop arrows +\showdivisionworktrue +\DeclareOption{noshowdivwork}{\showdivisionworkfalse} +\DeclareOption{showdivwork}{\showdivisionworktrue} +\ProcessOptions +\newdimen\b@solverulewidth % rule under the operator line +\b@solverulewidth=0.4pt +\newcount\b@maxcols % maximum length of a problem +\b@maxcols=20 +\newcount\b@maxrows % maximum lines of a problem +\b@maxrows=20 +\newdimen\b@longdivlinewidth % width of above +\def\fractionsymbol{;} +\newdimen\b@topdivline % length of the above +\newdimen\b@totalprobwid % width of widest line of problem +\newdimen\b@digitwid % width of a digit +\def\b@widthofdigit{2ex} +\newcount\b@colnum % row number of problem +\b@colnum=0% +\def\specialdigitstyle{} % style for a given digit +\def\speciallinestyle{} % style for a given digit +\b@longdivlinewidth=0.4pt +\newdimen\b@parenfontsize % size of parenthesis in longdiv +\newcount\b@linenum % row number of problem +\newdimen\b@divisorlen % length of divisor +\newdimen\b@divparenlen % width of the paren in ld +\newdimen\b@ldrowlen % length to add to b@divisorlen +\newdimen\b@fulldivlen % length of divisor + dividend +\b@fulldivlen=0pt +\newcount\b@charcount % number of chars in an argument +\b@charcount=0 +\newcount\b@loopi % generic loop counter +\b@loopi=0 +\def\b@remaindertext{R} % text for the remainder +\newdimen\b@droparrowlen % drop arrow length +\b@droparrowlen=0pt +\def\gobblechar{\let\char= } +\def\assignthencheck{\afterassignment\checknil\gobblechar} +\def\countunlessnil{% +\ifx\char\nil \let\next=\relax% +\else% +\let\next=\auxcountchar% +\advance\b@charcount by1% +\fi% +\ifx\char; \advance\b@charcount by-1\fi% +\next% +}% +\def\auxcountchar{% +\afterassignment\countunlessnil\gobblechar% +}% +\def\countchar#1{\edef\xx{#1}\b@charcount=0 \expandafter\auxcountchar\xx\nil} +\def\b@expandloop#1{% +\hbox{% +\b@xloop#1\relax +}% +} +\def\b@xloop#1{% +\if#1\fractionsymbol\else\advance\b@colnum by-1\fi% +\ifx\relax#1% +\else% +\if#1\fractionsymbol% +\rlap{\hbox to0pt{\hss#1\hss}}% +\else% +\hbox to\b@digitwid{\hfil{% +\csname +speciallinestyle\romannumeral\b@linenum\endcsname% +\csname +specialdigitstyle\romannumeral\b@colnum\endcsname#1}\hfil}% +\fi% +\expandafter\b@xloop% +\fi% +} +\def\b@spaceout#1{% +\countchar{#1}% +\b@colnum=\b@charcount% +\advance\b@colnum by1% +\b@expandloop{#1}% +}% +\def\probline#1#2{% +\advance\b@linenum by1% +\b@digitwid=\b@widthofdigit% +\b@totalprobwid=\b@digitwid% +\multiply\b@totalprobwid by#1% +\hbox to\b@totalprobwid{% +\hfil\b@spaceout{#2}% +}% +}% +\def\opline#1#2{% +\advance\b@linenum by1% +\hbox{% +\hbox to\b@digitwid{\hfil#1}% +\advance\b@totalprobwid by-\b@digitwid% +\hbox to\b@totalprobwid{% +\hfil\b@spaceout{#2}% +}% +}% +\vskip0.5ex% +\hrule width\b@totalprobwid height\b@solverulewidth% +\vskip0.5ex% +}% +\def\noopline#1{% +\opline{}{#1}% +}% +\def\nextpline#1{% +\advance\b@linenum by1% +\hbox{% +\hbox to\b@totalprobwid{% +\hfil\b@spaceout{#1}% +}% +}% +}% +\def\soluline#1{% +\advance\b@linenum by1% +\hbox{% +\hbox to\b@totalprobwid{% +\hfil\b@spaceout{#1}% +}% +}% +\b@linenum=0% +}% +\def\carryline#1#2{% +{% +\advance\b@linenum by1% +\b@digitwid=\b@widthofdigit% +\b@totalprobwid=\b@digitwid% +\multiply\b@totalprobwid by#1% +\footnotesize% +\hbox to\b@totalprobwid{% +\hfil\b@spaceout{#2}% +}% +\hrule width\b@totalprobwid height0pt% +\vskip0.4em% +}% +} +\def\longdiv#1#2#3{% +\advance\b@linenum by1% +\vskip\baselineskip% +\b@digitwid=\b@widthofdigit% +\b@topdivline=\b@digitwid% +\settowidth{\b@divisorlen}{\b@spaceout{#3}} +\b@parenfontsize=\f@size pt% +\multiply\b@parenfontsize by12% +\divide\b@parenfontsize by10% +\settowidth{\b@divparenlen}{% +\fontsize{\b@parenfontsize}{\b@parenfontsize}\selectfont)}% +\multiply\b@topdivline by#1% +\advance\b@topdivline by0.5\b@digitwid% +\vskip0.5ex% +\vbox{% +\hbox{% +\hskip\b@divisorlen% +\vrule width\b@topdivline height\b@longdivlinewidth% +}% +\nointerlineskip% +\hbox{% +\b@spaceout{#3}% +\hfil{\fontsize{\b@parenfontsize}{\b@parenfontsize}\selectfont)}% +\b@spaceout{#2}% +}% +}% +\advance\b@divisorlen by\b@divparenlen% +}% + +\def\ldsoluline#1#2{% +\advance\b@fulldivlen by\b@divisorlen% +\advance\b@fulldivlen by\b@topdivline% +\advance\b@fulldivlen by-\b@digitwid% +\advance\b@fulldivlen by\b@divparenlen% +\vskip-2\baselineskip% +\hbox to\b@fulldivlen{% +\hfil% +\b@spaceout{#1}% +\if#2\relax\else\rlap{\hskip1em \b@remaindertext{ }#2}\fi% +}% +\vskip\baselineskip% +}% +\newdimen\b@droparrowwidth +\def\getdroparrowwidth{% +\setbox\@tempboxa\hbox{$\downarrow$}% +\b@droparrowwidth=\wd\@tempboxa% +}% +\def\nextldline#1#2{% +\advance\b@linenum by1% +\b@ldrowlen=\b@digitwid% +\multiply\b@ldrowlen by#1% +\hbox{% +\hskip\b@divisorlen% +\hskip\b@ldrowlen% +\b@spaceout{#2}% +\b@droparrowlen=\baselineskip% +\ifshowdivisionwork% +\ifnum\b@linenum>2% +\getdroparrowwidth% +\multiply\b@droparrowlen by\b@linenum% +\advance\b@droparrowlen by-2\baselineskip% +\hskip-0.5\b@digitwid% +\vtop{\vskip-\baselineskip\vskip-\b@droparrowlen% +\rlap{% +\vrule width0.4pt height\b@droparrowlen% +\hskip-0.5\b@droparrowwidth{$\downarrow$}% +} +}% +\fi% +\fi% +}% +}% + +\def\linestyle#1#2{% +\b@loopi=0% +\loop\ifnum\the\b@loopi<\the\b@maxrows% +\advance\b@loopi by1% +\ifnum#1=\the\b@loopi +\expandafter\def\csname speciallinestyle\romannumeral\b@loopi\endcsname{#2}% +\fi +\repeat +}% + +\def\digstyle#1#2{% +\b@loopi=0% +\loop\ifnum\the\b@loopi<\the\b@maxcols% +\advance\b@loopi by1% +\ifnum#1=\the\b@loopi +\expandafter\def\csname specialdigitstyle\romannumeral\b@loopi\endcsname{#2}% +\fi +\repeat +}% +\def\clearlinestyles{% +\b@loopi=0% +\loop\ifnum\the\b@loopi<\the\b@maxrows% +\advance\b@loopi by1% +\expandafter\def\csname speciallinestyle\romannumeral\b@loopi\endcsname{}% +\repeat +}% +\def\cleardigitstyles{% +\b@loopi=0% +\loop\ifnum\the\b@loopi<\the\b@maxcols% +\advance\b@loopi by1% +\expandafter\def\csname specialdigitstyle\romannumeral\b@loopi\endcsname{}% +\repeat +}% + +\def\problembox#1{% +\leavevmode\vbox{#1}% +}% +\def\strike#1{% +{\rlap{\bf---}#1}% +} +\def\showdivwork{% +\showdivisionworktrue% +} +\def\noshowdivwork{% +\showdivisionworkfalse% +} +\cleardigitstyles + +\endinput +%% +%% End of file `basicarith.sty'. |