-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomplexpolylongdiv.dtx
328 lines (310 loc) · 9.22 KB
/
complexpolylongdiv.dtx
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
% \iffalse
%<*internal>
\iffalse
%</internal>
%<*readme>
___________________
The complexpolylongdiv package
v0.2
This package provides a simple interface for typesetting
(complex) polynomial long division.
If you want to report any bugs or typos and corrections in the
documentation, or ask for any new features, or suggest any
improvements, or ask any questions about the package, then
please use the issue tracker:
<https://github.com/xepersian/complexpolylongdiv/issues>
In doing so, please always explain your issue well enough,
and always include a minimal working example showing the
issue.
You may also have conversations, ask questions and post answers
without opening issues using the Discussions space:
<https://github.com/xepersian/complexpolylongdiv/discussions>
The announcements for the new releases of the package will
also appear in the Discussions space under the Announcements
category.
Current version release date: 2024/12/30
___________________________________________
Vafa Khalighi
Copyright (c) Vafa Khalighi 2024--2025
It may be distributed and/or modified 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 “author-maintained” (as per LPPL maintenance status)
by Vafa Khalighi.
%</readme>
%<*internal>
\fi
\begingroup
%</internal>
%<*batchfile>
\input docstrip.tex
\keepsilent
\preamble
__________________________________________________
Vafa Khalighi
Copyright (c) 2024--2025 Vafa Khalighi
It may be distributed and/or modified 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 “author-maintained” (as per LPPL maintenance status)
by Vafa Khalighi.
\endpreamble
\askforoverwritefalse
\generate{\file{complexpolylongdiv.sty}{\from{\jobname.dtx}{table,complexpolylongdiv.sty}}}
%</batchfile>
%<batchfile>\endbatchfile
%<*internal>
\generate{\file{\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\nopreamble\nopostamble
\generate{\file{README.txt}{\from{\jobname.dtx}{readme}}}
\generate{\file{complexpolylongdiv-example.tex}{\from{\jobname.dtx}{complexpolylongdiv-example.tex}}}
\endgroup
\immediate\write18{mv README.txt README}
\immediate\write18{makeindex -s gind.ist -o \jobname.ind \jobname.idx}
\immediate\write18{makeindex -s gglo.ist -o \jobname.gls \jobname.glo}
%</internal>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{complexpolylongdiv}
\usepackage{bidicode}
\usepackage{microtype}
\definecolor{niceblue}{rgb}{0.2,0.4,0.8}
\usepackage[numbered]{hypdoc}
\hypersetup{%
pdfauthor={Vafa Khalighi},%
linkcolor=niceblue,%
urlcolor=niceblue,%
citecolor=niceblue%
}
\pdfstringdefDisableCommands{%
\renewcommand\Lcs[1]{\textbackslash#1}
}
\EnableCrossrefs
\CodelineIndex
%\RecordChanges
\begin{document}
\DocInput{\jobname.dtx}
\PrintIndex
% \PrintChanges
\end{document}
%</driver>
%
%
% \fi
%
% \GetFileInfo{\jobname.dtx}
% \title{The \textsf{complexpolylongdiv} Package}
% \author{Vafa Khalighi}
%\date{Version 0.2\quad\today}
%\maketitle
%
%\begingroup
%\parindent 0pt
%\vskip 0pt plus 3fill
%{\color{red!85!black}\fbox{\begin{minipage}{\dimexpr\textwidth-2\fboxsep-2\fboxrule}
%If you want to report any bugs or typos and corrections in the documentation,
%or ask for any new features, or suggest any improvements, or ask any questions about the package, then please use the issue tracker:
%
%\medskip
% \centerline{\url{https://github.com/xepersian/complexpolylongdiv/issues}}
%
%\medskip
%In doing so, please always explain your issue well enough, and always include
%a minimal working example showing the issue.
%
%\bigskip
%You may also have conversations, ask questions and post answers
%without opening issues using the Discussions space:
%
%\medskip
% \centerline{\url{https://github.com/xepersian/complexpolylongdiv/discussions}}
%
%\medskip
%The announcements for the new releases of the package will
%also appear in the Discussions space under the Announcements
%category.
%\end{minipage}
%}}
%
%\vskip 0pt plus 3fill
%
%Copyright (c) 2024--2025 Vafa Khalighi
%
%\medskip
%Permission is granted to distribute and/or modify \emph{both the documentation and the code} under the conditions of the \LaTeX{} Project Public License, either version 1.3c of this license or (at your option) any later version.
%\endgroup
%
%\clearpage
% \tableofcontents
% \section{Introduction}
%To the best of my knowledge, there is no {\TeX} package for
%typesetting (complex) polynomial long division. The
%\textsf{complexpolylongdiv} package provides a simple interface
%for typesetting (complex) polynomial long division.
%
%The package does not provide automatic (complex) polynomial long
%division at present and the long division should be done by hand.
%However, if there is enough interest in the package, I will add this
%feature in the next version.
%
%\section{Using the package}
%\subsection{Loading The Package}
%You can load the package in the ordinary way:
%\begin{BDef}
%\Lcs{usepackage}\Largb{complexpolylongdiv}
%\end{BDef}
%\subsection{The user interface}
%The package provides the environment \texttt{complexpolylongdiv}
%and the control sequence \Lcs{complexpolyquotient} for
%typesetting (complex) polynomial long division.
%\subsubsection{The \texttt{complexpolylongdiv} environment}
%\begin{BDef}
%\LBEG{complexpolylongdiv}\OptArg{pos}\quad\Larga{content}\quad\LEND{complexpolylongdiv}
%\end{BDef}
%
%The \OptArg{pos} is optional and determines the vertical alignment of
%the (complex) polynomial long division. If \texttt{pos} is \texttt{t}, then
%the \Larga{content} is placed vertically at the top and if \texttt{pos} is \texttt{b}, then
%the \Larga{content} is placed vertically at the bottom; otherwise,
%the \Larga{content} is placed vertically at the center (the default
%when the optional \OptArg{pos} is omitted).
%
%\subsubsection{The control sequence \Lcs{complexpolyquotient}}
%\begin{BDef}
%\Lcs{complexpolyquotient}\Largb{\Larga{quotient}}
%\end{BDef}
%
%The control sequence \Lcs{complexpolyquotient} typesets \Larga{quotient}.
%
%\subsection{An Example}
%\begin{lstlisting}[gobble=1]
%\documentclass{article}
%\usepackage{complexpolylongdiv}
%\begin{document}
%\begin{equation}
%\begin{complexpolylongdiv}
%&x+1-2i \\
%x-1&\complexpolyquotient{x^2-2ix+6}\\
%-&\underline{x^2-x}\\
% &(1-2i)x+6\\
% -&\underline{(1-2i)x-(1-2i)}\\
% &7-2i
%\end{complexpolylongdiv}
%\end{equation}
%\end{document}
%\end{lstlisting}
%
%\begin{equation}
%\begin{complexpolylongdiv}
%&x+1-2i \\
%x-1&\complexpolyquotient{x^2-2ix+6}\\
%-&\underline{x^2-x}\\
% -&(1-2i)x+6\\
% -&\underline{(1-2i)x-(1-2i)}\\
% &7-2i\\
%\end{complexpolylongdiv}
%\end{equation}
%
% \StopEventually{}
% \section{Implementation}
%\iffalse
%<*table>
%\fi
%% \CheckSum{52}
%% \CharacterTable
%% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%% Digits \0\1\2\3\4\5\6\7\8\9
%% Exclamation \! Double quote \" Hash (number) \#
%% Dollar \$ Percent \% Ampersand \&
%% Acute accent \' Left paren \( Right paren \)
%% Asterisk \* Plus \+ Comma \,
%% Minus \- Point \. Solidus \/
%% Colon \: Semicolon \; Less than \<
%% Equals \= Greater than \> Question mark \?
%% Commercial at \@ Left bracket \[ Backslash \\
%% Right bracket \] Circumflex \^ Underscore \_
%% Grave accent \` Left brace \{ Vertical bar \|
%% Right brace \} Tilde \~}
%%
% \iffalse
%</table>
%<*complexpolylongdiv.sty>
%\fi
%
%
%
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{complexpolylongdiv}[2024/12/30 v0.2 Typesetting (complex) polynomial long division]
\newenvironment{complexpolylongdiv}[1][c]{%
\let\\\@arraycr
\if #1t
\vtop
\else
\if#1b
\vbox
\else
\vcenter
\fi
\fi
\bgroup
\normalbaselines
\offinterlineskip
\setbox\strutbox\hbox{%
\vrule height 2.1ex depth .5ex width0ex}%
\tabskip=0pt
\halign\bgroup
\hfil$##$&$\,\hphantom{\big)}\mkern2mu ##$\hfil\strut\cr
}{%
\crcr
\egroup
\egroup
}
\newcommand*{\complexpolyquotient}[1]{%
\omit$\,
\overline{%
\vphantom{\big)}%
\hbox{%
\smash{%
\raise3.5\fontdimen8\textfont3\hbox{$\big)$}%
}%
}%
\mkern2mu #1
}$%
}
% \end{macrocode}
% \iffalse
%</complexpolylongdiv.sty>
%\fi
%
% \Finale
%
%
%\iffalse
%<*complexpolylongdiv-example.tex>
\documentclass{article}
\usepackage{complexpolylongdiv}
\begin{document}
\begin{equation}
\begin{complexpolylongdiv}
&x+1-2i \\
x-1&\complexpolyquotient{x^2-2ix+6}\\
-&\underline{x^2-x}\\
&(1-2i)x+6\\
-&\underline{(1-2i)x-(1-2i)}\\
&7-2i
\end{complexpolylongdiv}
\end{equation}
\end{document}
%</complexpolylongdiv-example.tex>
%\fi
%
% \typeout{*************************************************************}
% \typeout{*}
% \typeout{* To finish the installation you have to move the file}
% \typeout{* `complexpolylongdiv.sty' into a directory searched by TeX.}
% \typeout{*************************************************************}
%
\endinput