summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2014-10-28 22:36:45 +0000
committerKarl Berry <karl@freefriends.org>2014-10-28 22:36:45 +0000
commit675c2b874dcbe2c6cea060f7667f9619ae64ee3b (patch)
treefdaee6c968ac30affcb7348f2289aa2c39861217 /Master/texmf-dist/source
parent31ae0d507c9b43a68b2b4e2f44f41a756b23b8c9 (diff)
basicarith (28oct14)
git-svn-id: svn://tug.org/texlive/trunk@35460 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/basicarith/basicarith.dtx80
1 files changed, 49 insertions, 31 deletions
diff --git a/Master/texmf-dist/source/latex/basicarith/basicarith.dtx b/Master/texmf-dist/source/latex/basicarith/basicarith.dtx
index a710be9f64f..949d4c7fd96 100644
--- a/Master/texmf-dist/source/latex/basicarith/basicarith.dtx
+++ b/Master/texmf-dist/source/latex/basicarith/basicarith.dtx
@@ -25,7 +25,7 @@
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
-%<package>\ProvidesPackage{basicarith}[2015/01/01 v1.0 support for typesetting basic arithmetic in the American fashion]
+%<package>\ProvidesPackage{basicarith}[2015/01/01 v1.1 support for typesetting basic arithmetic in the American fashion]
%<*driver>
\documentclass{ltxdoc}
@@ -37,6 +37,7 @@
\renewcommand{\LettrineFontHook}{\color{red}}
\usepackage{url}
\usepackage{spverbatim}
+\usepackage[nocounters]{dozenal}
\usepackage[noshowdivwork]{basicarith}
\usepackage[colorlinks]{hyperref}
\usepackage{makeidx}
@@ -70,15 +71,16 @@
\divide,\multiply,\advance,\edef,\expandafter,\f@size,\ifx,\fi,
\ifshowdivisionwork,\fi,\linewidth,\newdimen,\next,\nil,
\wd,\xx,\hbox,\vbox,\vtop,\hrule,\vrule,\hskip,\hss,\footnotesize,
- \downarrow}
+ \downarrow,\leavevmode,\settowidth}
+\tracingmacros=3
\begin{document}
\DocInput{basicarith.dtx}
\end{document}
%</driver>
% \fi
%
-% \title{The |basicarith| Package, v1.0}
+% \title{The |basicarith| Package, v1.1}
% \author{Donald P.\ Goodman III}
% \date{\today}
%
@@ -417,16 +419,17 @@
% \soluline{521}%
% \end{spverbatim}}
% }\hfil%
-% \vbox{\linestyle{1}{\color{blue}}%
+% \vbox{%
+% \linestyle{1}{\color{blue}}%
% \linestyle{2}{\color{red}}%
% \linestyle{3}{\color{green}}%
% \digstyle{3}{\color{black}\itshape}%
% \vskip-1em%
% \LARGE
% \problembox{
-% \probline{4}{548}%
+% \probline{6}{21;\x48}%
% \opline{$-$}{27}%
-% \soluline{521}%
+% \soluline{5;21}%
% }}%
% \hfil%
% }
@@ -517,7 +520,6 @@
% }%
% \end{center}
%
-%
% \section{Configuration Commands}
%
% There are a variety of other bits and pieces of
@@ -714,7 +716,8 @@
% \end{macrocode}
% Now we define the macros that are used for counting the
% number of characters in various strings; these are adapted
-% from macros by ``Florent'' at \url{tex-and-stuff.blogspot.com}.
+% from macros by ``Florent'' at
+% \url{tex-and-stuff.blogspot.com}.
% \begin{macrocode}
\def\gobblechar{\let\char= }
\def\assignthencheck{\afterassignment\checknil\gobblechar}
@@ -724,13 +727,13 @@
\let\next=\auxcountchar%
\advance\b@charcount by1%
\fi%
- \ifx\char; \advance\b@charcount by-1\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\countchar#1{\def\xx{#1}\b@charcount=0 \expandafter\auxcountchar\xx\nil}
% \end{macrocode}
% Now we define some macros for splitting a string into
% individual characters and putting them in boxes; these are
@@ -750,10 +753,10 @@
\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}%
+ \csname speciallinestyle\romannumeral\b@linenum\endcsname%
+ \csname specialdigitstyle\romannumeral\b@colnum\endcsname%
+ #1%
+ }\hfil}%
\fi%
\expandafter\b@xloop%
\fi%
@@ -854,7 +857,6 @@
}%
\advance\b@divisorlen by\b@divparenlen%
}%
-
\def\ldsoluline#1#2{%
\advance\b@fulldivlen by\b@divisorlen%
\advance\b@fulldivlen by\b@topdivline%
@@ -868,14 +870,21 @@
}%
\vskip\baselineskip%
}%
-% get the width of a box
+% \end{macrocode}
+% This is an interesting little trick which gets the width
+% of a box; we use this to determine the placement of the
+% drop arrows when we're showing our long division work.
+% \begin{macrocode}
\newdimen\b@droparrowwidth
\def\getdroparrowwidth{%
\setbox\@tempboxa\hbox{$\downarrow$}%
\b@droparrowwidth=\wd\@tempboxa%
}%
-% subsequent long division line; first is number of digits
-% of the dividend to cut off, second is number
+% \end{macrocode}
+% Now we get back to long division macros (yes, these do
+% take a rather long time). We start with the macro for
+% subsequent long division lines.
+% \begin{macrocode}
\def\nextldline#1#2{%
\advance\b@linenum by1%
\b@ldrowlen=\b@digitwid%
@@ -901,9 +910,12 @@
\fi%
}%
}%
-
-% style lines of digits; user-level command; first arg is
-% row number, second is style
+% \end{macrocode}
+% Now we move on to the styling macros; this requires a lot
+% of looping and other weirdities (weirdities for \TeX\
+% programming, anyway). First we style lines; then we style
+% columns.
+% \begin{macrocode}
\def\linestyle#1#2{%
\b@loopi=0%
\loop\ifnum\the\b@loopi<\the\b@maxrows%
@@ -913,9 +925,6 @@
\fi
\repeat
}%
-
-% style individual digits; user-level command; first arg is
-% column number, second is style
\def\digstyle#1#2{%
\b@loopi=0%
\loop\ifnum\the\b@loopi<\the\b@maxcols%
@@ -925,7 +934,10 @@
\fi
\repeat
}%
-% called to reset all the special line formatting
+% \end{macrocode}
+% Now we get our commands to clear the styling; again, first
+% lines, then columns.
+% \begin{macrocode}
\def\clearlinestyles{%
\b@loopi=0%
\loop\ifnum\the\b@loopi<\the\b@maxrows%
@@ -933,7 +945,6 @@
\expandafter\def\csname speciallinestyle\romannumeral\b@loopi\endcsname{}%
\repeat
}%
-% called to reset all the special digit commands
\def\cleardigitstyles{%
\b@loopi=0%
\loop\ifnum\the\b@loopi<\the\b@maxcols%
@@ -941,23 +952,30 @@
\expandafter\def\csname specialdigitstyle\romannumeral\b@loopi\endcsname{}%
\repeat
}%
-
-% simple problem box; unites a problem
+% \end{macrocode}
+% A few miscellanies; a box for binding together problems,
+% so that they can be positioned on the page more easily; a
+% macro for doing strikethroughts, quite useful in the
+% carries; and macros for showing or not showing our long
+% division work.
+% \begin{macrocode}
\def\problembox#1{%
\leavevmode\vbox{#1}%
}%
-% for striking out carries or borrowing
\def\strike#1{%
{\rlap{\bf---}#1}%
}
-% for showing division work
\def\showdivwork{%
\showdivisionworktrue%
}
\def\noshowdivwork{%
\showdivisionworkfalse%
}
+% \end{macrocode}
+% Now, finally, we clear all the digit styles (so that they
+% at least exist), and then we're done. Thanks for reading;
+% happy \TeX{}ing!
+% \begin{macrocode}
\cleardigitstyles
% \end{macrocode}
-
% \PrintIndex