Debian Codegraph @

texmf-dist/doc/latex/longdivision/longdivision_manual.tex

raw
1 \documentclass{ltxdoc}
2 \def\version{Version 1.2.2}
3
4 \let\ifluatex\relax
5 \usepackage{ifluatex}
6 \usepackage[a4paper,left=2.25cm,right=2.25cm,top=2.5cm,bottom=2.5cm,nohead]{geometry}
7 \usepackage{longdivision}
8
9 \usepackage{tikz}
10 \usepackage[documentation]{tcolorbox}
11 \usepackage{etoolbox}
12 \usepackage{amssymb}
13 \usepackage[notmath]{sansmathfonts}
14
15 \usepackage{hyperref}
16 \usepackage{hyperxmp}
17 \hypersetup{%
18 colorlinks=true,
19 linkcolor=blue,
20 filecolor=blue,
21 urlcolor=thered,
22 citecolor=blue,
23 pdfborder=0 0 0,
24 }
25
26 \makeatletter % !!!!
27 \input{pgfmanual.code} % This must be exectuted when catcode of @ is letter
28 \makeatother % !!!!
29
30 \include{pgfmanual-en-macros} % This must be executed when catcode of @ is other
31 \makeatletter
32
33 \MakeShortVerb{\|}
34
35 %\let\pgfmanual@verb@collect@code\pgfmanual@verb@collect
36 \patchcmd\pgfmanual@verb@collect{\pgfmanualprettyprintpgfkeys}{\pgfmanualprettyprintcode}{}{\error}
37 %\let\pgfmanual@verb@code\pgfmanual@verb
38
39
40 \patchcmd\extractkey{\hfill(\extrakeytext no value)}{}{}{\error}
41 \patchcmd\extractkey{\def\mykey}{\gdef\mykey}{}{\error}
42 \patchcmd\extractkeyequal{\hfill(\extrakeytext no default)}{}{}{\error}
43 \patchcmd\extractkeyequal{\def\mykey}{\gdef\mykey}{}{\error}
44 \patchcmd\extractinitial{no default, }{}{}{\error}
45 \patchcmd\extractinitial{\def\mykey}{\gdef\mykey}{}{\error}
46 \patchcmd\extractdefault{\def\mykey}{\gdef\mykey}{}{\error}
47 \patchcmd\extractdefault{#2}{{\hskip2pt}#2}{}{\error}
48 \patchcmd\extractequalinitial{\def\mykey}{\gdef\mykey}{}{\error}
49 \let\extractkey@\extractkey
50 \apptocmd\extractkey@{\egroup}{}{\error}
51 \def\extractkey{\bgroup\@ifnextchar*{\def\decompose####1\nil{}\relax\extractkey@\@gobble}{\extractkey@}}
52
53 % Redefine decompose not to do all that fancy crap -- just print as is. Maybe we should get rid of surrounding spaces here and where we do the ref?
54 \def\decompose#1/\nil{%
55 %\index{#1@\protect\texttt{#1} key}%
56 %\index{\mypath#1@\protect\texttt{#1}}%
57 %\pgfmanualpdflabel{#1}{}%
58 }
59
60 \hypersetup{
61 pdftitle={The Long Division Package},
62 pdfauthor={Hood Chatham},
63 pdfsubject={A package for typesetting long division},
64 pdfkeywords={long division,math,teaching},
65 pdflicenseurl={http://www.latex-project.org/lppl/}
66 }
67
68 \def\today{\the\year/\the\month/\the\day}
69
70 \def\@maketitle{%
71 \null\vskip 2em
72 \begin{center}\let\footnote\thanks\sffamily
73 {\huge \@title\par}\vskip 1.5em
74 {\large \parbox{.33\textwidth}{\centering\@author}%
75 \parbox{.33\textwidth}{\centering\@date}}%
76 \vskip2.5em\rule{\textwidth}{.4pt}%
77 \end{center}\par\vskip1.5em}
78 \def\abstractname{}
79 \def\mailtoHC{\href % some PDF viewers don't like spaces:
80 {mailto:<[email protected]>\%20Hood\%20Chatham?subject=[spectralsequences\%20package]}
81 {\texttt{[email protected]}}}
82 \makeatother
83
84 \tcbset{
85 texexp/.style={
86 skin = enhanced,
87 colframe=red!50!yellow!50!black,
88 colback=red!50!yellow!5!white,
89 coltitle=red!50!yellow!3!white,
90 segmentation style = solid,
91 fonttitle=\small\sffamily\bfseries,
92 fontupper=\small,
93 fontlower=\small},
94 texexp
95 }
96 \newtcblisting{texexp}[1]{texexp,#1}
97 \def\longdivname{\textsc{\textsf{\textmd{longdivision}}}}
98 \begin{document}
99 \title{\longdivname}
100 \author{Hood Chatham\\\mailtoHC}
101 \date{\version\\\today}
102 \maketitle
103
104 The \longdivname\ package defines two main commands: |\longdivision| and |\intlongdivision|. The usage for both is |\longdivision[|\meta{options}|]|\marg{dividend}\marg{divisor}. The difference is that |\longdivision| divides until the remainders repeat or the quotient has too many digits to fit the page, whereas |\intlongdivision| does integer division and leaves the remainder. The command |\longdivisionkeys|\marg{options} is also defined to set default options. At most 20 division steps worth of work will be displayed and at most 60 digits worth of division output will be produced. Thanks to Mike Jenck, Ben McKay, Cameron McLeman, Phelype Oleinik, Maximilian Schmidt, and Yu-Tsung Tai for bug reports and feature requests.
105
106 Here is an example usage:
107
108 \begin{tcblisting}{sidebyside}
109 \longdivision{100}{22}
110 \quad
111 \intlongdivision{100}{22}
112 \end{tcblisting}
113
114 These commands have several key-value options:
115
116 \begin{key}{max extra digits = \meta{nonnegative integer}}
117 This key determines the maximum amount of ``extra'' zeroes to add to the end of the dividend in the process of division -- if the quotient has more digits before it repeats, the division will just stop. This is only an option for |\longdivision|, the command |\intlongdivision|\marg{dividend}\marg{divisor} is equivalent to |\longdivision[max extra digits=0]|\marg{dividend}\marg{divisor}. For brevity, this option has the short form where just the value is provided: |\longdivision[2]|\marg{dividend}\marg{divisor} is the same as |\longdivision[max extra digits=2]|\marg{dividend}\marg{divisor}.
118
119 \begin{tcblisting}{}
120 \longdivision[max extra digits = 1]{14.1}{7} \quad
121 \longdivision[2]{14.1}{7}
122 \end{tcblisting}
123 \end{key}
124
125
126 \begin{key}{stage = \meta{nonnegative integer}}
127 This controls how many steps worth of division to do. Thanks to Cam McLeman for suggesting this feature.
128 \begin{tcblisting}{}
129 \longdivision[stage=0]{5.3}{37} \quad
130 \longdivision[stage=1]{5.3}{37} \quad
131 \longdivision[stage=2]{5.3}{37} \quad
132 \longdivision[stage=3]{5.3}{37} \quad
133 \longdivision[stage=4]{5.3}{37}
134 \end{tcblisting}
135 \end{key}
136
137 \begin{key}{style = \meta{style} (initially standard)}
138 Control the style for typesetting the result of long division. The options are |default|, |standard|, |tikz|, or |german|. The option |default| is the same as |tikz| if \tikzname\ is loaded and otherwise is the same as |standard|. You probably should load \tikzname\ because the \tikzname\ version looks significantly better. If you use this option, you'll probably want to set the style once and for all in your preamble with |\longdivisionkeys{style=|\meta{style}|}|.
139 \begin{tcblisting}{}
140 \intlongdivision[style = tikz ]{100.0}{13} \quad
141 \intlongdivision[style = standard]{100.0}{13} \quad
142 \intlongdivision[style = german ]{100.0}{13}
143 \end{tcblisting}
144 You can define your own style with |\longdivisiondefinestyle|\marg{style name}\marg{code}.
145 In the |\marg{code}| you can use the commands |\longdivdivisor| which contains the divisor, |\longdivdividend| which contains the dividend,
146 |\longdivquotient| which contains the quotient, |\longdivwork| which contains the division work
147 and |\longdivremainder| which contains the remainder.
148 For instance, a simplified version of the |german| style is:
149 \begin{tcblisting}{}
150 \longdivisiondefinestyle{my style}{%
151 \begin{tabular}{@{}l@{}}
152 \longdivdividend : \, \longdivdivisor \, = \longdivquotient \\
153 \longdivwork
154 \end{tabular}
155 }
156 \longdivision[style = my style]{2}{3}
157 \end{tcblisting}
158 Send me an email if you cannot figure out how to make a style to your liking.
159 \end{key}
160
161 \begin{key}{repeating decimal style = \meta{style} (initially overline)}
162 Control the way that repeating decimals are typeset. The options are |overline|, |dots|, |dots all|, |parentheses|, or |none|. The default is |overline|. The |parentheses| style creates ugly spacing problems and the |dots| style is insufficiently visible, so the |overline| style is the best. If you use this option, you'll probably want to set the style once and for all in your preamble with |\longdivisionkeys{recurring decimal style=|\meta{style}|}|. Like the |style| key, this is designed to be extensible. However, the process of creating new |repeating decimal style|s is a bit involved. Send me an email if you want a new |repeating decimal style|.
163 \begin{tcblisting}{}
164 \longdivision[repeating decimal style = overline ]{5.3}{37} \quad
165 \longdivision[repeating decimal style = dots ]{5.3}{37} \quad
166 \longdivision[repeating decimal style = dots all ]{5.3}{37} \quad
167 \longdivision[repeating decimal style = parentheses]{5.3}{37} \quad
168 \longdivision[repeating decimal style = none ]{5.3}{37}
169 \end{tcblisting}
170 \end{key}
171
172
173 \begin{key}{decimal separator = \meta{separator character} (initially .)}
174 Control the character used to indicated the decimal point. Most people want this to be a period or a comma. The default is a period. Note that this changes the decimal separator BOTH in the input and in the output. If you set the decimal separator to a comma and then use a period in the input, it will throw an error (though this could be inconvenient for people -- if this behavior causes you trouble, email me and I can fix it).
175 If you want to use the comma decimal separator, I recommend saying |\longdivisionkeys{decimal separator = {,}}| in your preamble.
176 \begin{tcblisting}{}
177 \longdivision[decimal separator = {.}]{2.1}{3} \quad
178 \longdivision[decimal separator = {,}]{2,1}{3}
179 \end{tcblisting}
180 \end{key}
181
182 \begin{key}{digit separator = \meta{separator character} (initially none)}
183 Control the character used to separate groups of digits in the output.
184 By default digit groups have length 3, but that can be configured with the |digit group length| key.
185 %The digit separator will also be deleted from input strings.
186 If value is empty, then no separator is used.
187 Most people want this to be a period or a comma.
188 Note that this changes the decimal separator BOTH in the input and in the output. If you set the decimal separator to a comma and then use a period in the input, it will throw an error.
189 \begin{tcblisting}{}
190 \longdivisionkeys{digit group length = 2}
191 \longdivision[digit separator = {,}]{5}{7} \quad
192 \longdivision[digit separator = {.}, decimal separator = {,}]{5}{7}
193 \longdivision[digit separator = { }]{5}{7}
194 \longdivision[digit separator = {_}]{5}{7}
195 \end{tcblisting}
196 \end{key}
197
198 \begin{key}{digit group length = \meta{integer} (initially 3)}
199 Specify how often to include a digit separator. Does nothing without the |digit separator| key.
200 \begin{tcblisting}{}
201 \longdivision[digit group length = 2, digit separator = {,}]{5}{7} \quad
202 \longdivision[digit group length = 3, digit separator = { }]{5}{7} \quad
203 \longdivision[digit group length = 4, digit separator = {_}]{5}{7}
204 \end{tcblisting}
205 \end{key}
206
207 \begin{key}{separators in work = \meta{bool} (initially true)}
208 Specifies whether to include the decimal and digit separators in division work. When this is false, |\longdivision| will leave a space instead so that the digits are aligned correctly. \begin{tcblisting}{}
209 \longdivision[separators in work = true ]{14.1}{3} \quad
210 \longdivision[separators in work = false]{14.1}{3}
211 \end{tcblisting}
212 \end{key}
213
214 \begin{key}{german division sign = \meta{division sign} (initially :)}
215 \begin{tcblisting}{}
216 \longdivisionkeys{style = german}
217 \longdivision[german division sign = $\,\div\,$ ]{14.1}{3} \quad
218 \longdivision[german division sign = : ]{14.1}{3}
219 \end{tcblisting}
220 \end{key}
221
222 \end{document}