From e127e502f1bc7386699c44d75c89991f1a5e0ac6 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Wed, 1 Dec 2021 03:00:56 +0000 Subject: CTAN sync 202112010300 --- macros/latex/contrib/rbt-mathnotes/LICENSE.txt | 416 ++++++++ macros/latex/contrib/rbt-mathnotes/README.md | 16 + .../contrib/rbt-mathnotes/examples/cheat-sheet.pdf | Bin 0 -> 31176 bytes .../contrib/rbt-mathnotes/examples/cheat-sheet.tex | 227 ++++ .../contrib/rbt-mathnotes/examples/multivar.pdf | Bin 0 -> 68487 bytes .../contrib/rbt-mathnotes/examples/multivar.tex | 507 +++++++++ .../rbt-mathnotes/examples/topology-hw-1.pdf | Bin 0 -> 41673 bytes .../rbt-mathnotes/examples/topology-hw-1.tex | 246 +++++ .../rbt-mathnotes/rbt-mathnotes-formula-sheet.cls | 150 +++ .../contrib/rbt-mathnotes/rbt-mathnotes-hw.cls | 325 ++++++ .../rbt-mathnotes/rbt-mathnotes-messages.sty | 76 ++ .../contrib/rbt-mathnotes/rbt-mathnotes-util.sty | 180 ++++ .../latex/contrib/rbt-mathnotes/rbt-mathnotes.cls | 202 ++++ .../latex/contrib/rbt-mathnotes/rbt-mathnotes.pdf | Bin 0 -> 55670 bytes .../latex/contrib/rbt-mathnotes/rbt-mathnotes.sty | 1122 ++++++++++++++++++++ .../latex/contrib/rbt-mathnotes/rbt-mathnotes.tex | 475 +++++++++ 16 files changed, 3942 insertions(+) create mode 100644 macros/latex/contrib/rbt-mathnotes/LICENSE.txt create mode 100644 macros/latex/contrib/rbt-mathnotes/README.md create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.pdf create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.tex create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/multivar.pdf create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/multivar.tex create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.pdf create mode 100644 macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.tex create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-formula-sheet.cls create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-hw.cls create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-messages.sty create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-util.sty create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.cls create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.pdf create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.sty create mode 100644 macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.tex (limited to 'macros/latex/contrib/rbt-mathnotes') diff --git a/macros/latex/contrib/rbt-mathnotes/LICENSE.txt b/macros/latex/contrib/rbt-mathnotes/LICENSE.txt new file mode 100644 index 0000000000..2244313901 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/LICENSE.txt @@ -0,0 +1,416 @@ +The LaTeX Project Public License +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- + +LPPL Version 1.3c 2008-05-04 + +Copyright 1999 2002-2008 LaTeX3 Project + Everyone is allowed to distribute verbatim copies of this + license document, but modification of it is not allowed. + + +PREAMBLE +======== + +The LaTeX Project Public License (LPPL) is the primary license under +which the LaTeX kernel and the base LaTeX packages are distributed. + +You may use this license for any work of which you hold the copyright +and which you wish to distribute. This license may be particularly +suitable if your work is TeX-related (such as a LaTeX package), but +it is written in such a way that you can use it even if your work is +unrelated to TeX. + +The section `WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE', +below, gives instructions, examples, and recommendations for authors +who are considering distributing their works under this license. + +This license gives conditions under which a work may be distributed +and modified, as well as conditions under which modified versions of +that work may be distributed. + +We, the LaTeX3 Project, believe that the conditions below give you +the freedom to make and distribute modified versions of your work +that conform with whatever technical specifications you wish while +maintaining the availability, integrity, and reliability of +that work. If you do not see how to achieve your goal while +meeting these conditions, then read the document `cfgguide.tex' +and `modguide.tex' in the base LaTeX distribution for suggestions. + + +DEFINITIONS +=========== + +In this license document the following terms are used: + + `Work' + Any work being distributed under this License. + + `Derived Work' + Any work that under any applicable law is derived from the Work. + + `Modification' + Any procedure that produces a Derived Work under any applicable + law -- for example, the production of a file containing an + original file associated with the Work or a significant portion of + such a file, either verbatim or with modifications and/or + translated into another language. + + `Modify' + To apply any procedure that produces a Derived Work under any + applicable law. + + `Distribution' + Making copies of the Work available from one person to another, in + whole or in part. Distribution includes (but is not limited to) + making any electronic components of the Work accessible by + file transfer protocols such as FTP or HTTP or by shared file + systems such as Sun's Network File System (NFS). + + `Compiled Work' + A version of the Work that has been processed into a form where it + is directly usable on a computer system. This processing may + include using installation facilities provided by the Work, + transformations of the Work, copying of components of the Work, or + other activities. Note that modification of any installation + facilities provided by the Work constitutes modification of the Work. + + `Current Maintainer' + A person or persons nominated as such within the Work. If there is + no such explicit nomination then it is the `Copyright Holder' under + any applicable law. + + `Base Interpreter' + A program or process that is normally needed for running or + interpreting a part or the whole of the Work. + + A Base Interpreter may depend on external components but these + are not considered part of the Base Interpreter provided that each + external component clearly identifies itself whenever it is used + interactively. Unless explicitly specified when applying the + license to the Work, the only applicable Base Interpreter is a + `LaTeX-Format' or in the case of files belonging to the + `LaTeX-format' a program implementing the `TeX language'. + + + +CONDITIONS ON DISTRIBUTION AND MODIFICATION +=========================================== + +1. Activities other than distribution and/or modification of the Work +are not covered by this license; they are outside its scope. In +particular, the act of running the Work is not restricted and no +requirements are made concerning any offers of support for the Work. + +2. You may distribute a complete, unmodified copy of the Work as you +received it. Distribution of only part of the Work is considered +modification of the Work, and no right to distribute such a Derived +Work may be assumed under the terms of this clause. + +3. You may distribute a Compiled Work that has been generated from a +complete, unmodified copy of the Work as distributed under Clause 2 +above, as long as that Compiled Work is distributed in such a way that +the recipients may install the Compiled Work on their system exactly +as it would have been installed if they generated a Compiled Work +directly from the Work. + +4. If you are the Current Maintainer of the Work, you may, without +restriction, modify the Work, thus creating a Derived Work. You may +also distribute the Derived Work without restriction, including +Compiled Works generated from the Derived Work. Derived Works +distributed in this manner by the Current Maintainer are considered to +be updated versions of the Work. + +5. If you are not the Current Maintainer of the Work, you may modify +your copy of the Work, thus creating a Derived Work based on the Work, +and compile this Derived Work, thus creating a Compiled Work based on +the Derived Work. + +6. If you are not the Current Maintainer of the Work, you may +distribute a Derived Work provided the following conditions are met +for every component of the Work unless that component clearly states +in the copyright notice that it is exempt from that condition. Only +the Current Maintainer is allowed to add such statements of exemption +to a component of the Work. + + a. If a component of this Derived Work can be a direct replacement + for a component of the Work when that component is used with the + Base Interpreter, then, wherever this component of the Work + identifies itself to the user when used interactively with that + Base Interpreter, the replacement component of this Derived Work + clearly and unambiguously identifies itself as a modified version + of this component to the user when used interactively with that + Base Interpreter. + + b. Every component of the Derived Work contains prominent notices + detailing the nature of the changes to that component, or a + prominent reference to another file that is distributed as part + of the Derived Work and that contains a complete and accurate log + of the changes. + + c. No information in the Derived Work implies that any persons, + including (but not limited to) the authors of the original version + of the Work, provide any support, including (but not limited to) + the reporting and handling of errors, to recipients of the + Derived Work unless those persons have stated explicitly that + they do provide such support for the Derived Work. + + d. You distribute at least one of the following with the Derived Work: + + 1. A complete, unmodified copy of the Work; + if your distribution of a modified component is made by + offering access to copy the modified component from a + designated place, then offering equivalent access to copy + the Work from the same or some similar place meets this + condition, even though third parties are not compelled to + copy the Work along with the modified component; + + 2. Information that is sufficient to obtain a complete, + unmodified copy of the Work. + +7. If you are not the Current Maintainer of the Work, you may +distribute a Compiled Work generated from a Derived Work, as long as +the Derived Work is distributed to all recipients of the Compiled +Work, and as long as the conditions of Clause 6, above, are met with +regard to the Derived Work. + +8. The conditions above are not intended to prohibit, and hence do not +apply to, the modification, by any method, of any component so that it +becomes identical to an updated version of that component of the Work as +it is distributed by the Current Maintainer under Clause 4, above. + +9. Distribution of the Work or any Derived Work in an alternative +format, where the Work or that Derived Work (in whole or in part) is +then produced by applying some process to that format, does not relax or +nullify any sections of this license as they pertain to the results of +applying that process. + +10. a. A Derived Work may be distributed under a different license + provided that license itself honors the conditions listed in + Clause 6 above, in regard to the Work, though it does not have + to honor the rest of the conditions in this license. + + b. If a Derived Work is distributed under a different license, that + Derived Work must provide sufficient documentation as part of + itself to allow each recipient of that Derived Work to honor the + restrictions in Clause 6 above, concerning changes from the Work. + +11. This license places no restrictions on works that are unrelated to +the Work, nor does this license place any restrictions on aggregating +such works with the Work by any means. + +12. Nothing in this license is intended to, or may be used to, prevent +complete compliance by all parties with all applicable laws. + + +NO WARRANTY +=========== + +There is no warranty for the Work. Except when otherwise stated in +writing, the Copyright Holder provides the Work `as is', without +warranty of any kind, either expressed or implied, including, but not +limited to, the implied warranties of merchantability and fitness for a +particular purpose. The entire risk as to the quality and performance +of the Work is with you. Should the Work prove defective, you assume +the cost of all necessary servicing, repair, or correction. + +In no event unless required by applicable law or agreed to in writing +will The Copyright Holder, or any author named in the components of the +Work, or any other party who may distribute and/or modify the Work as +permitted above, be liable to you for damages, including any general, +special, incidental or consequential damages arising out of any use of +the Work or out of inability to use the Work (including, but not limited +to, loss of data, data being rendered inaccurate, or losses sustained by +anyone as a result of any failure of the Work to operate with any other +programs), even if the Copyright Holder or said author or said other +party has been advised of the possibility of such damages. + + +MAINTENANCE OF THE WORK +======================= + +The Work has the status `author-maintained' if the Copyright Holder +explicitly and prominently states near the primary copyright notice in +the Work that the Work can only be maintained by the Copyright Holder +or simply that it is `author-maintained'. + +The Work has the status `maintained' if there is a Current Maintainer +who has indicated in the Work that they are willing to receive error +reports for the Work (for example, by supplying a valid e-mail +address). It is not required for the Current Maintainer to acknowledge +or act upon these error reports. + +The Work changes from status `maintained' to `unmaintained' if there +is no Current Maintainer, or the person stated to be Current +Maintainer of the work cannot be reached through the indicated means +of communication for a period of six months, and there are no other +significant signs of active maintenance. + +You can become the Current Maintainer of the Work by agreement with +any existing Current Maintainer to take over this role. + +If the Work is unmaintained, you can become the Current Maintainer of +the Work through the following steps: + + 1. Make a reasonable attempt to trace the Current Maintainer (and + the Copyright Holder, if the two differ) through the means of + an Internet or similar search. + + 2. If this search is successful, then enquire whether the Work + is still maintained. + + a. If it is being maintained, then ask the Current Maintainer + to update their communication data within one month. + + b. If the search is unsuccessful or no action to resume active + maintenance is taken by the Current Maintainer, then announce + within the pertinent community your intention to take over + maintenance. (If the Work is a LaTeX work, this could be + done, for example, by posting to comp.text.tex.) + + 3a. If the Current Maintainer is reachable and agrees to pass + maintenance of the Work to you, then this takes effect + immediately upon announcement. + + b. If the Current Maintainer is not reachable and the Copyright + Holder agrees that maintenance of the Work be passed to you, + then this takes effect immediately upon announcement. + + 4. If you make an `intention announcement' as described in 2b. above + and after three months your intention is challenged neither by + the Current Maintainer nor by the Copyright Holder nor by other + people, then you may arrange for the Work to be changed so as + to name you as the (new) Current Maintainer. + + 5. If the previously unreachable Current Maintainer becomes + reachable once more within three months of a change completed + under the terms of 3b) or 4), then that Current Maintainer must + become or remain the Current Maintainer upon request provided + they then update their communication data within one month. + +A change in the Current Maintainer does not, of itself, alter the fact +that the Work is distributed under the LPPL license. + +If you become the Current Maintainer of the Work, you should +immediately provide, within the Work, a prominent and unambiguous +statement of your status as Current Maintainer. You should also +announce your new status to the same pertinent community as +in 2b) above. + + +WHETHER AND HOW TO DISTRIBUTE WORKS UNDER THIS LICENSE +====================================================== + +This section contains important instructions, examples, and +recommendations for authors who are considering distributing their +works under this license. These authors are addressed as `you' in +this section. + +Choosing This License or Another License +---------------------------------------- + +If for any part of your work you want or need to use *distribution* +conditions that differ significantly from those in this license, then +do not refer to this license anywhere in your work but, instead, +distribute your work under a different license. You may use the text +of this license as a model for your own license, but your license +should not refer to the LPPL or otherwise give the impression that +your work is distributed under the LPPL. + +The document `modguide.tex' in the base LaTeX distribution explains +the motivation behind the conditions of this license. It explains, +for example, why distributing LaTeX under the GNU General Public +License (GPL) was considered inappropriate. Even if your work is +unrelated to LaTeX, the discussion in `modguide.tex' may still be +relevant, and authors intending to distribute their works under any +license are encouraged to read it. + +A Recommendation on Modification Without Distribution +----------------------------------------------------- + +It is wise never to modify a component of the Work, even for your own +personal use, without also meeting the above conditions for +distributing the modified component. While you might intend that such +modifications will never be distributed, often this will happen by +accident -- you may forget that you have modified that component; or +it may not occur to you when allowing others to access the modified +version that you are thus distributing it and violating the conditions +of this license in ways that could have legal implications and, worse, +cause problems for the community. It is therefore usually in your +best interest to keep your copy of the Work identical with the public +one. Many works provide ways to control the behavior of that work +without altering any of its licensed components. + +How to Use This License +----------------------- + +To use this license, place in each of the components of your work both +an explicit copyright notice including your name and the year the work +was authored and/or last substantially modified. Include also a +statement that the distribution and/or modification of that +component is constrained by the conditions in this license. + +Here is an example of such a notice and statement: + + %% pig.dtx + %% Copyright 2005 M. Y. Name + % + % This work may be distributed and/or modified under the + % conditions of the LaTeX Project Public License, either version 1.3 + % of this license or (at your option) any later version. + % The latest version of this license is in + % http://www.latex-project.org/lppl.txt + % and version 1.3 or later is part of all distributions of LaTeX + % version 2005/12/01 or later. + % + % This work has the LPPL maintenance status `maintained'. + % + % The Current Maintainer of this work is M. Y. Name. + % + % This work consists of the files pig.dtx and pig.ins + % and the derived file pig.sty. + +Given such a notice and statement in a file, the conditions +given in this license document would apply, with the `Work' referring +to the three files `pig.dtx', `pig.ins', and `pig.sty' (the last being +generated from `pig.dtx' using `pig.ins'), the `Base Interpreter' +referring to any `LaTeX-Format', and both `Copyright Holder' and +`Current Maintainer' referring to the person `M. Y. Name'. + +If you do not want the Maintenance section of LPPL to apply to your +Work, change `maintained' above into `author-maintained'. +However, we recommend that you use `maintained', as the Maintenance +section was added in order to ensure that your Work remains useful to +the community even when you can no longer maintain and support it +yourself. + +Derived Works That Are Not Replacements +--------------------------------------- + +Several clauses of the LPPL specify means to provide reliability and +stability for the user community. They therefore concern themselves +with the case that a Derived Work is intended to be used as a +(compatible or incompatible) replacement of the original Work. If +this is not the case (e.g., if a few lines of code are reused for a +completely different task), then clauses 6b and 6d shall not apply. + + +Important Recommendations +------------------------- + + Defining What Constitutes the Work + + The LPPL requires that distributions of the Work contain all the + files of the Work. It is therefore important that you provide a + way for the licensee to determine which files constitute the Work. + This could, for example, be achieved by explicitly listing all the + files of the Work near the copyright notice of each file or by + using a line such as: + + % This work consists of all files listed in manifest.txt. + + in that place. In the absence of an unequivocal list it might be + impossible for the licensee to determine what is considered by you + to comprise the Work and, in such a case, the licensee would be + entitled to make reasonable conjectures as to which files comprise + the Work. + diff --git a/macros/latex/contrib/rbt-mathnotes/README.md b/macros/latex/contrib/rbt-mathnotes/README.md new file mode 100644 index 0000000000..cf7c71a521 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/README.md @@ -0,0 +1,16 @@ +# rbt-mathnotes + +Rebecca Turner’s personal macros and styles for typesetting mathematics notes. + +See `rbt-mathnotes.pdf` for detailed documentation. + +Contents: + +- `rbt-mathnotes` package +- `rbt-mathnotes` document class +- `rbt-mathnotes-hw` document class, containing specialized commands for + typesetting homework assignments and solutions (in particular, the `problem` + environment and `\prob` command) +- `rbt-mathnotes-formula-sheet` document class, optimized for stuffing as much + text as possible onto an exam “cheat sheet” +- Examples of each document class in the `examples` directory diff --git a/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.pdf b/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.pdf new file mode 100644 index 0000000000..8f92b8337f Binary files /dev/null and b/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.pdf differ diff --git a/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.tex b/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.tex new file mode 100644 index 0000000000..11ff82a5a9 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/examples/cheat-sheet.tex @@ -0,0 +1,227 @@ +%% cheat-sheet.tex +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\documentclass{rbt-mathnotes-formula-sheet} +\usepackage{nicefrac} +\ExplSyntaxOn +\NewDocumentCommand \normalized { m } + { \frac { #1 } { \| #1 \| } } +\let \gr \grad +\def \ddx { \frac{d}{dx} } +% VL = vector literal +\NewDocumentCommand \vl { m } { \left\langle #1 \right\rangle } +\ExplSyntaxOff + +\title{Formula Sheet} +\author{Rebecca Turner} +\date{2019-11-12} + +% "The most common size for index cards in North America and UK is 3 by 5 +% inches (76.2 by 127.0 mm), hence the common name 3-by-5 card. Other sizes +% widely available include 4 by 6 inches (101.6 by 152.4 mm), 5 by 8 inches +% (127.0 by 203.2 mm) and ISO-size A7 (74 by 105 mm or 2.9 by 4.1 in)." +\mathnotes{ + height = 4in , + width = 6in , +} +\begin{document} +\maketitle +\begin{gather*} +% 12.2: Vectors +% 12.3: Dot product + \textstyle\vec a \cdot \vec b = \sum_i a_i b_i = |\vec a| |\vec b| \cos \theta. \\ +% 12.4: Cross product + \vec a \times \vec b + % = \left| \begin{array}{rrr} + % \hat{i} & \hat{j} & \hat{k} \\ + % a_1 & a_2 & a_3 \\ + % b_1 & b_2 & b_3 \\ + % \end{array} \right| \\ + = \langle a_2 b_3 - a_3 b_2, + \quad a_3b_1 - a_1b_3, \\ + a_1b_2 - a_2b_1 \rangle.\quad + |\vec a \times \vec b| = |\vec a| |\vec b| \sin \theta. +% 12.5: Equations of lines and planes. +\shortintertext{Param.\ eqns.\ of line through $\langle x_0,y_0,z_0 \rangle$ +par.\ to $\langle a,b,c \rangle$:} + x = x_0 + at, + \quad y = y_0 + bt, + \quad z = z_0 + ct. \\ +\text{Symm.\ eqns.: } + \frac{x-x_0}{a} + = \frac{y-y_0}{b} + = \frac{z-z_0}{c}. \\ +\shortintertext{Vec.\ eqn.\ of plane through $\vec r$ with $\vec n$ normal:} + \vec n \cdot (\vec r - \vec r_0) = 0, + \quad \vec n \cdot \vec r = \vec n \cdot \vec r_0. \\ +% 13.1: Vector functions +% 13.2: Derivatives/integrals of vector functions +% 13.3: Arc length and curvature +\shortintertext{Length along a vec.\ fn.\ $\vec r(t)$:} + \textstyle\int_a^b \left|\vec r'(t)\right|\,dt = \int_a^b \sqrt{\sum_i + r_i'(t)^2}\,dt, \\ +\shortintertext{Unit tang.\ $\vec T(t) = \vec r'(t)/\left|\vec +r'(t)\right|$, so curvature of $\vec r(t)$ w/r/t the arc len.\ fn. $s$:} + \kappa = \left|\frac{d\vec T}{ds}\right| + = \frac{\left| \vec T'(t) \right|}{\left| \vec r'(t) \right|} + = \frac{\left| \vec r'(t) \times \vec r''(t) \right|}{\left| \vec r'(t) + \right|^3}. \\ +\text{Unit normal:}\quad + \vec N(t) = \vec T'(t)\,/\,\left| \vec T'(t) \right| \\ +% 14.1: Functions of several variables +% 14.2: Limits and continuity +% 14.3: Partial derivatives +\text{Clairaut's thm.:}\quad + f_{xy}(a,b) = f_{yx}(a,b) \\ +% 14.4: Tangent planes & linear approximations +\shortintertext{Tan.\ plane to $z = f(x,y)$ at $\langle x_0, y_0, +z_0\rangle$:} + z - z_0 = f_x(x_0, y_0) (x-x_0) \\ + + f_y(x_0, y_0) (y-y_0). \\ +% Partial derivatives of f for each variable exist near a point and are +% continuous => f is differentiable at the po\int. +% 14.6: Directional derivatives and the gradient vector +\text{Grad.:}\quad + \grad f(x,y) = \pd[f]x \hat{i} + \pd[f]y \hat{j}. \\ +\shortintertext{Dir.\ deriv.\ towards $\vec u$ at $\langle x_0, y_0 \rangle$:} + D_{\langle a,b\rangle} f(x_0, y_0) = f_x(x,y) a + f_y(x,y) b \\ + = \grad f(x,y) \cdot \vec u. \\ +\shortintertext{Max of $D_{\vec u} f(\vec x) = \left|\grad f(\vec +x)\right|$. Tan.\ plane of $f$ at $\vec p$:} + 0 = + f_x(\vec p)(x-\vec p_x) + + f_y(\vec p)(y-\vec p_y) \\ + + f_z(\vec p)(z-\vec p_z). +% 14.7: Maximum and minimum values +\shortintertext{If $f$ has loc.\ extrem.\ at $\vec p$, then $f_x(\vec p) = +0$ (\& $f_y$, etc). If so, let} + D = \left| \begin{array}{ll} + f_{xx} & f_{xy} \\ + f_{yx} & f_{yy} + \end{array}\right| + = f_{xx} f_{yy} - (f_{xy})^2. +\shortintertext{% + $D = 0$: no information. + $D < 0$: saddle pt. + $D > 0$: $f_{xx}(\vec p) > 0 \implies$ loc.\ min; + $f_{xx}(\vec p) < 0 \implies$ loc.\ max. + ($D$ is the \textbf{Hessian mat.}) +\endgraf + Set of possible abs. min and max vals of $f$ in reg.\ $D$: $f$ at critical + pts.\ and extreme vals.\ on the boundary of $D$. +% 14.8: Lagrange multipliers +\endgraf + Lagrange mults.: extreme vals of $f(\vec p)$ when $g(\vec p) = k$. + Find all $\vec x, \lambda$ s.t. +} + \grad f(\vec x) = \lambda \grad g(\vec x),\quad g(\vec x) = k. +\shortintertext{i.e.\ $f_x = \lambda g_x$, etc.} +% 15.1: Double integrals over rectangles +% 15.2: Iterated integrals +% 15.3: Double integrals over general regions + \iint f(r\cos\theta, r\sin\theta)r\,dr\,d\theta. \\ + A = \iint_D \left(\sqrt{f_x(x,y)^2 + f_y(x,y)^2 + 1}\right) \,dA. \\ +\shortintertext{Line int.s} + \int_C f(x,y)\,ds = \\ + \int_a^b f(x(t), y(t))\sqrt{\left(\pd[x]t\right)^2 + \left(\pd[y]t\right)^2}\,dt \\ +\shortintertext{If $C$ is a smooth curve given by $\vec r(t)$ from $a \le t +\le b$,} + \int_C \grad f \cdot d\vec r = f(\vec r(b)) - f(\vec r(a)) \\ +\text{Spherical coords:}\quad + x = \rho \sin \phi \cos \theta \\ + y = \rho \sin \phi \sin \theta, z = \rho \cos \phi \\ + \curl \vec F = \\ \left< \pd[R]y - \pd[Q]z, \pd[P]z - \pd[R]x, \pd[Q]x - + \pd[P]y\right>. \\ + \vec F = \langle P,Q,R \rangle,\quad + \curl \vec F = \grad \times \vec F \\ + \vec F \text{ ``conservative''} \implies \exists f, \vec F = \grad f. \\ + \dive \vec F = \grad \cdot \vec F = \pd[P]x + \pd[Q]y + \pd[R]z. \\ + \curl(\grad f) = \vec 0,\quad \dive \curl \vec F = 0 \\ +\shortintertext{If $C$ is a positively-oriented (ccw) closed curve, $D$ +is bounded by $C$, and $\vec n$ represents the normal,} + % \int_C P\,dx + Q\,dy = \iint_D\left( \pd[Q]{x} - \pd[P]{y} \right). \\ + \oint_C \vec F \cdot \vec n\,ds = \iint_D \dive \vec F(x,y)\,dA. +\end{gather*} + +\pagebreak +\raggedright Common derivs: +$f(g(x)) \to g'(x) f'(g(x))$, +$b^x \to b^x \ln b$, +$f^{-1}(x) \to 1/f'(f^{-1}(x))$, +$\ln x \to 1/x$, +$\sin x \to \cos x$, $\cos x \to -\sin x$, +$\tan x \to \sec^2 x$, +$\sin^{-1} x \to 1/\sqrt{1-x^2}$, +$\cos^{-1} x \to -(\sin^{-1}x)'$ (etc.), +$\tan^{-1} x \to 1/(1+x^2)$, +$\sec^{-1} x \to 1/(|x|\sqrt{x^2-1})$. + +Common ints (don't forget $+C$): +\begin{gather*} + x^n \to \frac{x^{n + 1}}{n + 1} + C \quad \text{when } n \ne -1 \\ + 1/x \to \ln |x| \\ + \tan x \to -\ln(\cos x) \\ + \int uv'\,dx = uv - \int u'v\,dx \quad\text{(Int.\ by parts)} \\ + \int u\,dv = uv-\int v\,du \\ + \int_{g(a)}^{g(b)} f(u)\,du = \int_a^b f(g(x))g'(x)\,dx + \quad\text{$u$-substitution.} +\intertext{E.x.\ in $\int 2x \cos x^2\,dx$, let $u=x^2$, find $du/dx=2x +\implies du = 2x\,dx$, subs.\ $\int \cos u\,du = \sin u + C = \sin x^2 + +C$.} + \iint_R f(x,y)\,dA = \int_\alpha^\beta \int_a^b f(r\cos\theta, + r\sin\theta)r\,dr\,d\theta +\end{gather*} +\begin{itemize} + \item Integrand contains $a^2-x^2$, let $x = a\sin\theta$ and use $1 - + \sin^2 \theta = \cos^2 \theta$. + \item $a^2 + x^2$, let $x = a\tan\theta$, use $1 + \tan^2 \theta = \sec^2 + \theta$. + \item $x^2 - a^2$, let $x = a\sec\theta$, use $\sec^2\theta - 1 = \tan^2 + \theta$. +\end{itemize} + +\begin{gather*} + \lim_{x \to 0} \sin x/x = 1 \\ + \lim_{x \to 0} (1-\cos x)/x = 0 \\ + \lim_{x \to \infty} x \sin(1/x) = 1 \\ + \lim_{x \to 0} (1+x)^{1/x} = e \\ + \lim_{x \to 0} (e^{ax}-1)/(bx) = a/b \\ + \lim_{x \to 0^+} x^x = 1 \\ + \lim_{x \to 0^+} x^{-n} = \infty \\ + \text{For $0/0$ or $\pm\infty/\infty$,}\quad + \lim_{x \to c} f(x)/g(x) = \lim_{x \to c} f'(x)/g'(x) \\ + \text{For $g(x)$ cont.\ at $L$,} + \lim_{x \to c} f(x) = L \implies \lim_{x \to c} g(L) +\end{gather*} + +\end{document} diff --git a/macros/latex/contrib/rbt-mathnotes/examples/multivar.pdf b/macros/latex/contrib/rbt-mathnotes/examples/multivar.pdf new file mode 100644 index 0000000000..e6fdd5f7a3 Binary files /dev/null and b/macros/latex/contrib/rbt-mathnotes/examples/multivar.pdf differ diff --git a/macros/latex/contrib/rbt-mathnotes/examples/multivar.tex b/macros/latex/contrib/rbt-mathnotes/examples/multivar.tex new file mode 100644 index 0000000000..fc026754f6 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/examples/multivar.tex @@ -0,0 +1,507 @@ +%% multivar.tex +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\documentclass[knowledge]{rbt-mathnotes} +\title{Multivariable Calculus} +\mathnotes{ + instructor = Prof.~Corey Bregman , + name = Rebecca Turner , + email = rebeccaturner@brandeis.edu , + course = \textsc{math} 20a (multivariable calculus) , + institution = Brandeis University , + semester = Fall 2019 , +} + +\ExplSyntaxOn +\NewDocumentCommand \normalized { m } + { \frac { #1 } { \| #1 \| } } +\let \gr \grad +\def \ddx { \frac{d}{dx} } +% VL = vector literal +\NewDocumentCommand \vl { m } { \left\langle #1 \right\rangle } +\ExplSyntaxOff + +% \makeatletter +% \@ifpackageloaded{knowledge} +% { +\knowledge{notion, index={Derivative!Partial}} + | partial derivative +\AtBeginDocument{\index{Partial derivative|see{Derivative, partial}}} + +\knowledge{notion, index={Derivative!Directional}} + | directional derivative +\AtBeginDocument{\index{Directional derivative|see{Directional, partial}}} + +\knowledge{notion, index=Unit vector} + | unit vector + +\knowledge{notion, index=Limit} + | limit + +\knowledge{notion, index={Differentiable functions}} + | differentiable + +\knowledge{notion, index=Gradient} + | gradient + +\knowledge{notion, index={Neighborhood (topology)}} + | neighborhood + +\knowledge{notion, index=Local maximum} + | local maximum + | local maxima + +\knowledge{notion, index=Local minimum} + | local minimum + | local minima + +\knowledge{notion, index=Absolute maximum} + | absolute maximum + | absolute maxima + +\knowledge{notion, index=Absolute minimum} + | absolute minimum + | absolute minima + +\knowledge{notion, index=Local extremum} + | local extremum + | local extrema + +\knowledge{notion, index=Critical point} + | critical point + +\knowledge{notion, index=Saddle point} + | saddle point + +\knowledge{notion, index={Lagrange multiplier}} + | Lagrange multiplier + | Lagrange multipliers + | the method of Lagrange multipliers + +\knowledge{url={https://en.wikipedia.org/wiki/Joseph-Louis_Lagrange}} + | Joseph-Louis Lagrange + | Lagrange + +\knowledge{url={https://en.wikipedia.org/wiki/Marquis_de_Condorcet}} + | Marquis de Condorcet + + \knowledge{url={https://en.wikipedia.org/wiki/Adrien-Marie_Legendre}} + | Adrien-Marie Legendre +% } +% {} +% \makeatother +\date{2019-10-23} +\begin{document} +\maketitle +\tableofcontents + +\chapter{Vectors} +I already know about vectors --- I've been taught them in about five +different courses so far. I'm skipping this. + +\chapter{Partial derivatives} + +If we have a function of multiple variables, say +\[f(a_1, a_2, a_3, \dots),\] +we might care about the change of $f$ with respect to only one variable. By +picking a fixed value for all but one of the variables, we can determine +this. + +Say that we want to find the "partial derivative" of $f$ with respect to +$a_2$; then, by constructing $g(a_2) = f(c_1, a_2, c_3, \dots)$, we've +created a function of \emph{one} variable, which we can differentiate as +usual. +\begin{notation} + We write the "partial derivative" of a function $f$ at a point $\vec p$ + with respect to a basis element $a$ of $\vec p$ as \fbox{$f_a(\vec p)$.} + + We may also use much more common notation + \[\pd[f]{a},\] + using the "partial derivative" symbol $\partial$, a stylized cursive + ``d''.\footnote{Introduced by "Marquis de Condorcet" in 1770, who used it + to represent a partial \emph{differential}, i.e.~the $dy$ or $dx$ in + $dy/dx$, and then adapted in 1786 by "Adrien-Marie Legendre" for use as the + partial derivative.} + + In the interest of completeness, I'll exhaustedly note that the book also + uses, on occasion, the notation $D_a f$. +\end{notation} + +We can also calculate ""higher partial derivatives"" --- similarly to the +higher ordinary derivatives. The notation is a fairly clear extension: +\[(f_x)_x = f_{xx} = \pd x \left( \pd[f]{x} \right) = \pd[^2 f]{x^2}.\] + +\begin{thm}[Clairaut's Theorem] + Suppose $f$ is defined on a neighborhood $N$ about a point $\vec p$. + If $f_{xy}$ and $f_{yx}$ are continuous in $N$, then $f_{xy}(\vec p) = + f_{yx}(\vec p)$. +\end{thm} + +\section{Gradients} +\begin{notation} + This ridiculous textbook denotes the "partial derivative" of a function + $f(x, y) = z$ with respect to $x$ as $f_x(x, y)$. +\end{notation} + +\begin{defn} + The ""directional derivative"" of a function $f$ at $(x_0, y_0)$ in the + direction of a "unit vector" $\vec u = \langle a, b \rangle$ is + \[D_{\vec u} f(x_0, y_0) = \lim_{h \to 0} \frac{f(x_0 + ha, y_0 + hb) - + f(x_0, y_0)}{h},\] + if the "limit" exists. +\end{defn} + +If $f : \Re^2 \mapsto \Re$ is a "differentiable" function, then $f$ has a +"directional derivative" in the direction of any "unit vector" $\vec u = +\langle a, b \rangle$ of +\begin{alignat*}{1} + D_{\vec u} f(x, y) &= f_x(x, y) a + f_y(x, y) b. +\intertext{Or, if $\vec u = \langle \cos \theta, \sin \theta \rangle$, then} + D_{\vec u} f(x, y) &= f_x(x, y) \cos \theta + f_y(x, y) \sin \theta. +\end{alignat*} + +Noticing that the "directional derivative" of a function can be written as +the dot product of two vectors, +\begin{alignat*}{1} + D_{\vec u} f(x, y) &= f_x(x, y) a + f_y(x, y) b \\ + &= \langle f_x(x, y), f_y(x, y) \rangle \cdot \langle a, b \rangle \\ + &= \langle f_x(x, y), f_y(x, y) \rangle \cdot \vec u, +\end{alignat*} +we call the first vector $\langle f_x(x, y), f_y(x, y) \rangle$ the +""gradient"" of $f$ and denote it as $\grad f$. + +\begin{defn} + The "gradient" of a function $f$ of two variables is defined as + \[\grad f(x, y) = \langle f_x(x, y), f_y(x, y) \rangle + = \frac{\partial f}{\partial x} \vec i + \frac{\partial f}{\partial y} + \vec j.\] +\end{defn} + +Therefore, we can rewrite the "directional derivative" of a function $f$ +as +\[D_{\vec u} f(x, y) = \grad f(x, y) \cdot \vec u.\] +It's intuitive, then, that the maximum value of the "directional derivative" +is $|\grad f(x, y)|$, when $\vec u$ is parallel to $\grad f(x, y)$. + +\section{Maximum and minimum values} +\begin{defn} + $f : A^k \mapsto B$ has a ""local maximum"" at $\vec a$ if for some + "neighborhood" $N \subset A$ about $\vec a$, for all $\vec x \in N$, + $f(\vec x) \le f(\vec a)$. + + Conversely, if $f(\vec x) \ge f(\vec a)$, then $f(\vec a)$ is a ""local + \emph{minimum}@local minimum"". + + If the statement also holds true for $N = A$, then $\vec a$ is an + ""absolute maximum"" (or ""absolute minimum""). +\end{defn} + +If $f$ has a "local maximum" or "minimum@local minimum" at $\vec a$ and the +partials of $f$ exist at $\vec a$, then $\partial f/\partial x (\vec a) = 0$ +and $f_y(a, b) = 0$; geometrically, the tangent plane to a maximum or +minimum must be horizontal. + +\begin{defn} + A point $\vec a$ is called a ""critical point"" of $f$ if $f_x(\vec a) = + 0$ or $f_x(\vec a)$ doesn't exist for all variables of $f$. +\end{defn} + +\begin{defn} + A ""saddle point"" of a function is a "critical point" which is not a + "local extremum" of the function. +\end{defn} + +If $(a, b)$ is a critical point of $f$, then let +\[D = D(a, b) = f_{xx} (a,b) \, f_{yy} (a,b) - (f_{xy}(a,b))^2.\] +If $D < 0$, then $(a, b)$ is a "saddle point" of $f$. + +\section{Lagrange multipliers} +Often we want to find the "local extrema" of a function subject to +constraints, i.e.~maximizing the volume of an object while keeping its +surface area constant. The method of "Lagrange multipliers"\footnote{After +"Joseph-Louis Lagrange" (1736--1813), ``an Italian Enlightenment Era +mathematician and astronomer [who] made significant contributions to the +fields of analysis, number theory, and both classical and celestial +mechanics.''} is a strategy for doing this. + +To find extrema of $f(\vec p)$ constrained with $g(\vec p) = k$, +we look for extrema of $f$ that are restricted to lie on the level curve +$g(\vec p) = k$; it happens that the largest $c$ such that $f(\vec p) = c$ +intersects with $g(\vec p) = k$ when the two level curves are tangent with +each other, i.e.~they have identical normals. In other words, for some +scalar $\lambda$, $\grad f(\vec p) = \lambda \grad g(\vec p)$. + +More formally, suppose $f$ has an extrema at $\vec p_0$. Then, let the level +surface generated by the constraint $g(\vec p) = k$ be called $S$, where +$\vec p_0 \in S$. Then, let $C$ be the set of points given by $\vec r(t)$ such +that $C \subset S$ and $\vec p_0 \in C$. Further, let $t_0$ be a point such +that $\vec r(t_0) = \vec p_0$. + +Then, $f \after \vec r$ gives the values of $f$ on the curve $C$. $f$ has an +extrema at $\vec p$, so $f \after \vec r$ must also, and $(f \after \vec +r)'(t_0) = 0$. If $f$ is "differentiable", we can use the chain rule to +write +\begin{alignat*}{1} + 0 &= (f \after \vec r)'(t_0) \\ + &= \grad f(\vec p_0) \cdot \vec r'(t_0). +\end{alignat*} +Therefore, the gradient of $f$ is orthogonal to the tangent of every such +curve $C$. We also know that $\grad g(\vec p_0)$ is orthogonal to $\vec +r'(t_0)$, so the gradients of $f$ and $g$ at $\vec p_0$ must be parallel. +Therefore, if $\grad g(\vec p_0) \ne 0$, there exists some $\lambda$ such +that +\begin{equation} + \grad f(\vec p_0) = \lambda \grad g(\vec p_0), +\end{equation} +where the constant $\lambda$ is called a "Lagrange multiplier". + +Then, the ""method of Lagrange multipliers"" gives us a process to +find the maximum and minimum values of a function $f(\vec p)$ subject to the +constraint $g(\vec p) = k$, where $\vec p \in \Re^n$. To use the method of +Lagrange multipliers, we assume that the extreme values exist and that +$\grad g \ne 0$ on the level surface $g(\vec p) = k$. +\begin{enumerate} + \item Find all values of $\vec p$ and $\lambda$ such that + \begin{alignat*}{1} + \grad f(\vec p) &= \lambda \grad g(\vec p) \\ + \text{and}\qquad g(\vec p) &= k. \\ + \end{alignat*} + + \item Next, evaluate $f$ at all of the points found in the first step. The + largest of these values is the maximum value of $f$, and the smallest of + them is the minimum value. +\end{enumerate} + +\chapter{Multiple integrals} +Single integrals are good for functions of one variable. To integrate +functions of multiple variables, we use multiple integrals. Straightforward +enough. + +Multiple integrals allow us to calculate things like surface areas and +volumes of geometric objects. + +In general, for some double integral +\[\underbrace{\int_a^b \overbrace{\int_c^d f(x,y)\,dx}^{\mathclap{\text{We +treat $y$ as constant while evaluating this.}}}\,dy,}_{\mathclap{\text{We've +eliminated $x$ from the equation before evaluating this.}}}\] +we do the opposite of partial differentiation and treat all variables other +than the one we're integrating for as constant, repeatedly, until we've +integrated with respect to all variables; each step in this process is +called, predictably, ""partial integration"". + +\section{Double integrals} +For an axis-aligned rectangle $R$ on the $xy$-plane from $(x_0, y_0)$ to $(x_1, +y_1)$, the area of a function $f(x, y)$ under $R$ is given by the double +integral +\begin{alignat*}{1} + \iint_{Y} f(x,y)\,dA &= \underbrace{\int_{x_0}^{x_1} \int_{y_0}^{y_1} + f(x,y)\,dy\,dx}_{\mathclap{\text{This is the iterated form of the + integral.}}} \\ + &= \int_{y_0}^{y_1} \int_{x_0}^{x_1} f(x,y)\,dx\,dy, \\ +\end{alignat*} +where we use $\iint_R$ to mean ``integrating over the area of $R$'' and +``$dA$'' to mean ``with respect to area.'' + +The right-hand side of the equation above is called the ""iterated form"", +or an \reintro*"iterated integral". + +We can also iterate over funkier regions if we're willing to play with the +limits of integration a bit. The easiest regions to integrate over are the +ones that are easily expressible as the region bounded above and below by +functions of one variable, e.g. ``the region under the line $y = 2x$ and +above the line $y = x^2$'' (note that this is bounded on the left at $x = 0$ +and on the right at $x = 2$). + +% Area[ImplicitRegion[x^2 < y \[And] y < 2 x, {x, y} +The area of that region is expressed by the integral +\begin{alignat*}{1} + A &= \int_0^2 \int_{x^2}^{2x}\,dy\,dx \\ + &= \int_0^2 {\bigg[ x \bigg]}_{x^2}^{2x}\,dx \\ + &= \int_0^2 {\bigg( 2x-x^2 \bigg)}\,dx \\ + &= {\left[ x^2 - \frac{x^3}{3} \right]}_0^2 \\ + &= 4 - \frac{8}{3} = \frac{4}{3}. +\end{alignat*} + +A more complicated region might be ``the region under the paraboloid $z = +x^2 + y^2$ and above the region in the $xy$-plane bounded by $y = \sqrt{x}$ +and $y=1-\cos x$.'' + +We can build larger regions out of pieces, by summing smaller integrals. + +\section{Polar coordinates} +Use the conversions +\begin{alignat*}{1} + r &= \sqrt{x^2+y^2} \\ + x &= r\cos\theta \\ + y &= r\sin\theta \\ +\intertext{for the coordinates and then we have that if $R$ is a ``polar +rectangle'' (arc-shaped region bounded by angles and radii) from $r=a$ to +$r=b$ and $\theta = \alpha$ to $\theta = \beta$, we have} + \iint_R f(x,y)\,dA &= \int_\alpha^\beta \int_a^b f(r\cos\theta, + r\sin\theta)r\,dr\,d\theta, \\ +\intertext{which makes our lives easier for circly areas and volumes. Don't +forget to multiply by $r$. +\endgraf +For squiggly and varying radii, we can use functions $h_1(\theta)$ and +$h_2(\theta)$ instead of constants $a$ and $b$:} + \iint_D f(x,y)\,dA &= \int_\alpha^\beta \int_{h_1(\theta)}^{h_2(\theta)} f(r\cos\theta, + r\sin\theta)r\,dr\,d\theta. \\ +\end{alignat*} + +\section{Cylindrical coordinates} +Just add $z$. + +\section{Spherical coordinates} +I can never remember how these work. If we have a point $P$, and we drop it +down to the $xy$-plane, the angle between the positive $x$-axis and the +segment from the origin to $P$ is $\theta$. + +Next, the angle between the positive $z$-axis and the segment from the origin +to $P$ is $\phi$. + +Finally, the length of the segment from the origin to $P$ is $\rho$. + +The conversions +\begin{alignat*}{1} + x &= \rho \sin \phi \cos \theta \\ + y &= \rho \sin \phi \sin \theta \\ + z &= \rho \cos \phi \\ +\intertext{give us the integral-conversion for the spherical wedge bounded +by $a \le \rho \le b, \alpha \le \theta \le \beta, c \le \phi \le d$ as} + \iiint_E f(x,y,z)\,dV &= \int_c^d \int_\alpha^\beta \int_a^b + f(\rho \sin\phi \cos\theta,\, + \rho \sin\phi \sin\theta,\, + \rho \cos \theta) + [\rho^2 \sin\phi] + \,d\rho\,d\theta\,d\phi. \\ +\end{alignat*} +Very gross! + +\section{Surface area} + +For $f(x,y)$ with $f_x$, $f_y$ continuous, the surface area of $f$ within +a region $D$ is +\[A = \iint_D \left(\sqrt{f_x(x,y)^2 + f_y(x,y)^2 + 1}\right) \,dA.\] + +% Need notes on: +% - Change of variables (in multiple integrals) + +\chapter{Vector calculus} +A vector field is a mapping $\R^k \mapsto \R^n$; for each point in +$k$-dimensional Euclidean space, we associate an $n$-dimensional vector. +These vectors can represent velocity, distance, or anything else, and come +up in all sorts of applied fields. + +We'll be mostly concerned with vector fields $\R^2\mapsto\R^2$ and +$\R^3\mapsto\R^3$. + +If we have a plane curve given by the vector equation +\begin{alignat*}{1} + \vec r(t) &= \left< x(t), y(t) \right> \qquad a \le t \le b, \\ +\intertext{then the line integral of $f$ along $\vec r(t)$ from $a$ to $b$ +is} + & \int_a^b f(x(t), y(t)) \sqrt{{\left(\dd[x]{t}\right)}^2 + + {\left(\dd[y]{t}\right)}^2}\,dt, +\end{alignat*} +i.e.\ the length of the curve multiplied, at each point, by the value of the +vector field $f$ at that point. + +% Need notes on: +% 16.1, 16.2, 16.3, 16.4, 16.5, +% Need to update cheat sheet. + +\appendix +\chapter{Common formulas for derivatives and integrals} +\backmatter +\section{Derivatives} + +\begin{alignat*}{2} + \ddx&\;& (f + g) &= f' + g' \\ + \ddx&& x^n &= nx^{n - 1} \\ + \ddx&& (fg) &= fg' + f'g \\ + \ddx&& \frac{h}{l} &= \frac{l h' - h l'}{l^2} \\ + \ddx&& f(g(x)) &= f'(g(x)) g'(x) \quad\text{(Chain rule.)} \\ + \ddx&& b^x &= b^x \ln b \\ + \ddx&& f^{-1}(x) &= \frac{1}{f'(f^{-1}(x)} \\ + \ddx&& c &= 0 \\ + \ddx&& c\,f &= c\,f' \\ + \ddx&& e^x &= e^x \\ + \ddx&& e^{f(x)} &= f'(x) e^{f(x)} \quad\text{(By the chain rule.)} \\ + \ddx&& \ln x &= \frac{1}{x} \\ + \ddx&& \log_b x &= \frac{1}{x \ln b} \\ + \ddx&& [\vec u \cdot \vec v] &= \vec u' \cdot \vec v + \vec u \cdot \vec v' \\ + \ddx&& [\vec u \times \vec v] &= \vec u' \times \vec v + \vec u \times \vec v' \\ +\end{alignat*} + +\subsection{Trigenometric} +\begin{alignat*}{2} + \ddx&\;& \sin x &= \cos x \\ + \ddx&& \cos x &= -\sin x \\ + \ddx&& \tan x &= \sec^2 x \\ + \ddx&& \cot x &= -\csc^2 x \\ + \ddx&& \sec x &= \sec x \tan x \\ + \ddx&& \csc x &= -\csc x \cot x \\ + % inverse + \ddx&& \sin^{-1} x &= \frac{ 1}{\sqrt{1 - x^2}} \\ + \ddx&& \cos^{-1} x &= \frac{-1}{\sqrt{1 - x^2}} \\ + \ddx&& \tan^{-1} x &= \frac{ 1}{1 + x^2} \\ + \ddx&& \cot^{-1} x &= \frac{-1}{1 + x^2} \\ + \ddx&& \sec^{-1} x &= \frac{ 1}{|x| \sqrt{x^2 - 1}} \\ + \ddx&& \csc^{-1} x &= \frac{-1}{|x| \sqrt{x^2 - 1}} \\ +\end{alignat*} + +\section{Integrals} +See also: +\emph{\href{https://www.whitman.edu/mathematics/calculus/calculus_08_Techniques_of_Integration.pdf}{Techniques +of Integration}}. +\begin{alignat*}{1} + \int x^n\,dx &= \frac{x^{n + 1}}{n + 1} + C \quad \text{when } n \ne -1 \\ + \int x^{-1}\,dx &= \ln|x| + C \\ + \int e^x\,dx &= e^x + C \\ + \dd{t} \int_{a(t)}^{b(t)} g(s)\,ds &= b'(t) g(b(t)) - a'(t) g(a(t)) + \quad\text{(Leibniz' rule.)} \\ + \int uv'\,dx &= uv - \int u'v\,dx \\ +\end{alignat*} + +\subsection{Trigenometric} +\begin{alignat*}{1} + \int \sin x\,dx &= -\cos x + C \\ + \int \cos x\,dx &= \sin x + C \\ + \int \sec^2 x\,dx &= \tan x + C \\ + \int \sec x \tan x\,dx &= \sec x + C \\ + \int \frac{1}{1 + x^2}\,dx &= \tan^{-1} x + C \\ + \int \frac{1}{\sqrt{1 + x^2}}\,dx &= \sin^{-1} x + C \\ +\end{alignat*} + +\printindex +\end{document} diff --git a/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.pdf b/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.pdf new file mode 100644 index 0000000000..3bbc7d93fb Binary files /dev/null and b/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.pdf differ diff --git a/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.tex b/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.tex new file mode 100644 index 0000000000..406ce622ad --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/examples/topology-hw-1.tex @@ -0,0 +1,246 @@ +%% topology-hw-1.tex +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\documentclass[twocolumn, noxcolor, maketitle]{rbt-mathnotes-hw} +\mathnotes{ + instructor = Prof.~Ruth Charney , + name = Rebecca Turner , + email = rebeccaturner@brandeis.edu , + course = \textsc{math} 104a (Intro to Topology) , + institution = Brandeis University , + semester = Spring 2020 , +} +\title{Homework 1} +\date{2020-01-18} +\def\T{\mathcal{T}} +\def\basis{\mathcal{B}} +\usepackage[ + letterpaper, + margin = 1in, +]{geometry} +\raggedbottom +\begin{document} +\maketitle + +\section{Topological Spaces} +\subsection{Open Sets and the Definition of a Topology} +\begin{problem}[1.7] + Define a topology on $\R$ (by listing the open sets within it) that contains + the open sets $(0,2)$ and $(1,3)$ that contains as few open sets as possible. +\end{problem} +$\T = \{ \emptyset, (0,2), (1,3), (1,2), (0,3), \R \}$. + +\subsection{Basis for a Topology} +\begin{problem}[1.10] + Show that $\mathcal{B} = \{[a,b) \subset \R : a < b\}$ is a basis for a + topology on $\R$. +\end{problem} +\begin{enumerate} + \item \textbf{$\emptyset \in \T$, $\R \in \T$.} $\emptyset \in \T$ (by the + definition of the completion of a basis to a topology). + + Next, we show $\R \in \T$. For all $n \in \Z_{\ge 0}$, $[n-1, n) \in \basis$ + and $[-n + 1, -n) \in \basis$. We know that if $b_1, b_2 \in \basis$, $b_1 + \union b_2 \in \T$, so these short intervals can be gathered together (``unionized'') + to produce $\R$: + \[ \bigunion_{n=1}^{\infty} \left( [n-1, n) \union [-n + 1, -n] \right) = \R, \] + so $\R \in \T$. + + \item \textbf{$\T$ contains all finite intersections of elements of $\T$.} + Suppose we have two intervals $[a, b)$ and $[c, d)$. Then, we define + \begin{alignat*}{1} + a' &= \max(a, c) \\ + b' &= \min(b, d). + \end{alignat*} + If $a' > b'$, the intersection $[a, b) \inter [c, d) = \emptyset$, which is + in $\T$. Otherwise, the intersection is $[a', b')$, which is an element of + $\basis$. All elements of the basis are in $\T$, so the intersection of two + elements is in the topology. + + Thankfully, the intersection is itself always a basis element, so we can + use the same process to show that finite intersections are in $\T$ by + induction. + + \item \textbf{Unions of elements of $\T$ are in $\T$.} By the definition of + the completion of a basis to a topology, this is true (all unions of basis + elements are included in $\T$). +\end{enumerate} + +\begin{problem}[1.12] + % See example 1.9 for defn of \R_l + Determine which of the following are open sets in $\R_l$. In each case, prove + your assertion. + \[ A = [4,5) + \quad B = \{3\} + \quad C = [1,2] + \quad D = (7,8) \] +\end{problem} +\begin{enumerate} + \item $A$ is open in $\R_l$; $[4,5) \in \basis$. + \item $B$ is not an open set in $\R_l$; there is no $[a, b) \subset \R$ where + both $b > a$ and $|[a, b)| = 1$ (because $[0,1) \cong \R$, i.e.~all + intervals contain infinitely many points). + + (Where $\cong$ means ``is isomorphic to.'') + \item $C$ is not open in $\R_l$ because the upper bound of an open set in + $\R_l$ is never inclusive. There is no set of intervals $[a_1, b_1), \dots$ + where the union or intersection of the intervals has an inclusive upper bound. + \item $D$ is open because we can take + \[ D = \lim_{n\to\infty} \left[7 + \frac{1}{n}, 8\right), \] + where $[7 + 1/n, 8) \in \basis$ for any $n \in \R$ with $n \ne 0$. +\end{enumerate} + +\pagebreak +\begin{problem}[1.15] + An arithmetic progression in $\Z$ is a set + \[ A_{a,b} = \{\dots, a - 2b, a - b, a, a + b, a + 2b, \dots\} \] + with $a,b \in \Z$ and $b \ne 0$. Prove that the collection of arithmetic + progressions + \[ \mathcal{A} = \{ A_{a,b} : a, b \in \Z \text{ and } b \ne 0 \} \] + is a basis for a topology on $\Z$. The resulting topology is called the + arithmetic progression topology on $\Z$. +\end{problem} + +\begin{proof} + \def\Ar#1#2{A_{#1,#2}} + \def\Ars{\mathcal{A}} + Let us describe the \emph{minimal form} of an arithmetic progression $\Ar ab$ + to be the progression $\Ar{a'}{b'} = \Ar ab$ with $a', b' > 0$ and the + smallest possible $a'$; in particular, that $a' < b'$. + + We can obtain the minimal form of the progression like so: + \begin{alignat*}{1} + a' &= a \bmod b \\ + b' &= |b|, \\ + \Ar{a'}{b'} &= \Ar ab. + \end{alignat*} + + \begin{remark} + Two arithmetic progressions have the same elements if their minimal forms are + the same; this give an equivalence relation on $\Ars$. + \end{remark} + + Now, suppose we have two arithmetic progressions $\Ar ab$ and $\Ar cd$. We + assume that the progressions are in minimal form without loss of generality. We + also assume that $b \le d$ (by swapping $(a,b)$ with $(c,d)$ if necessary), + again without loss of generality. + + If $b \mid d$ and $a = c$, we have $\Ar ab \subset \Ar cd$. In particular, $\Ar + ab \inter \Ar cd = \Ar cd$. + + If $b \mid d$ and $a \ne c$, we have $\Ar ab \inter \Ar cd = \emptyset$. + + If $b \nmid d$, we have a different progression. An intersection is generated by + an index $(n_1, n_2)$, where + \begin{alignat*}{1} + a + b n_1 &= c + d n_2. \\ + \intertext{We can then solve for $n_1$:} + t(n) &= c - a + dn \\ + n_1 &= \frac{t(n_2)}{b}. \\ + \intertext{Next, we have an infinite \emph{set} of possibilities for $n_2$:} + n_2 &\in \left\{n \in \Z : t(n) \mid b \right\}. + \intertext{Sorting the possible values of $n_2$ by absolute value, let us call + the smallest two values $i_1$ and $i_2$. Then, the difference between + adjacent elements in the intersection progression $\Ar ab \inter \Ar cd$ + is $i_2 - i_1$. + \endgraf + Let} + a' &= a + bi_1 \\ + b' &= i_2 - i_1 \\ + \Ar ab \inter \Ar cd &= \Ar{a'}{b'}. + \end{alignat*} + This isn't super rigorous, admittedly (we're missing some inductive reasoning + about the integers to prove that there are an infinite set of valid values of + $n_2$, in particular), but I have some fairly convincing Haskell code. And the + missing steps are mostly boilerplate, and it's late at night already\dots + + In all cases, the intersection of two arithmetic progressions is either empty or + another arithmetic progression (i.e.~either the empty set or another basis + element), so the same argument given above for $\R_l$ holds (namely that we can + extend this to all finite intersections of elements of $\Ars$ inductively). + + Therefore, finite intersections are in the basis. Unions are in the completion + of the basis (again by definition). The special element $\emptyset$ is in the + completion (by definition), and $\Z = \Ar01$, so $\Z \in \basis$. Therefore, + $\Ars$ forms the basis of a topology on $\Z$. +\end{proof} + +\pagebreak +\subsection{Closed Sets} +\begin{problem}[1.27(a)] + The infinite comb $C$ is the subset of the plane illustrated in Figure~1.17 + and defined by + \begin{multline*} + C = \{(x,0) : 0 \le x \le 1\} \;\union \\ + \bigg\{ \left( \frac{1}{2^n}, y \right) : n = 0,1,2, \dots \\ + \text{ and } 0 \le y \le 1 \bigg\}. + \end{multline*} + Prove that $C$ is not closed in the standard topology on $\R^2$. +\end{problem} +\begin{proof} + Suppose $C$ is closed in the standard topology on $\R^2$. Then, its complement + $C^c = \R^2 \setminus C$ must be an open set. + + The point $(0, 1)$ is not in $C$, so $(0, 1) \in C^c$. Every open ball in $\R^2$ + containing $(0, 1)$ also contains a smaller open ball centered about $(0, 1)$. + (For example, the open ball about $(-1, 1)$ of radius $1.1$ contains the open + ball centered about $(0, 1)$ of radius $0.1$.) + + However, every open ball centered about $(0, 1)$ contains infinitely many + points of $C$; if the ball has radius $r$, all the comb's ``tines'' at $x = + 1/2^n$ for $n > - \log_2 r$ intersect with the ball. + + Therefore, every open ball containing $(0, 1)$ also contains points in $C$. As + a result, $C^c$ is not open, which contradicts our assumption. Therefore, $C$ + is not closed. +\end{proof} + +\begin{problem}[1.32] + Prove that intervals of the form $[a, b)$ are closed in the lower limit + topology on $\R$. +\end{problem} +\begin{proof} + Take some interval $[a, b)$. Its complement is given by $(-\infty, a) \union + [b, \infty)$. Given that + \begin{alignat*}{1} + (-\infty, a) &= \bigunion_{n=1}^\infty [a-n, a) \\ + [b, \infty) &= \bigunion_{n=1}^\infty [b, b+n), + \end{alignat*} + the complement of $[a, b)$ is the union of a number of lower-limit intervals + in $\R$, i.e.~the basis elements. The basis elements and its unions are open + sets, so the complement of $[a, b)$ is an open set. Then, by the definition of + a closed set, $[a, b)$ is closed in $\R_l$. +\end{proof} + + +\end{document} diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-formula-sheet.cls b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-formula-sheet.cls new file mode 100644 index 0000000000..85e789b34a --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-formula-sheet.cls @@ -0,0 +1,150 @@ +%% rbt-mathnotes-formula-sheet.cls +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplClass{rbt-mathnotes-formula-sheet}{2021/11/29}{1.0.2}{Styles + for mathematical exam formula sheets.} + +\LoadClass{article} + +\RequirePackage{rbt-mathnotes} + +\cs_set:Npn \@maketitle + { + \textbf{\@title}~ + (\@author,~\@date) + } + +\cs_set:Npn \mn__tiny_thm:nn #1#2 + { + \RenewDocumentEnvironment { #1 } { o } + { + \textbf + { + #2 + \IfValueT { ##1 } + { + :~##1 + } + . + } + } + { + } + } + +\mn__tiny_thm:nn { thm } { Thm } +\mn__tiny_thm:nn { lem } { Lem } +\mn__tiny_thm:nn { cor } { Cor } +\mn__tiny_thm:nn { prop } { Prop } +\mn__tiny_thm:nn { defn } { Defn } +\mn__tiny_thm:nn { ex } { Ex } +\mn__tiny_thm:nn { note } { Note } +\mn__tiny_thm:nn { remark } { Rmrk } + +\prg_new_conditional:Npnn \mn__if_should_use_multicols: + { T, } + { + \int_compare:nNnTF + { \g__mn_fs_columns_int } = { \c_one_int } + { \prg_return_false: } + { \prg_return_true: } + } + +\RequirePackage{multicol} +\AtBeginDocument + { + \scriptsize + \mn__if_should_use_multicols:T + { + \begin + { + multicols + \bool_if:NF \g__mn_should_balance_multicols_bool + { * } + } + { + \int_use:N \g__mn_fs_columns_int + } + } + \skip_set:Nn \abovedisplayskip { 0pt } + \skip_set:Nn \belowdisplayskip { 0pt } + } + +\AtEndDocument + { + \mn__if_should_use_multicols:T + { + \end + { + multicols + \bool_if:NF \g__mn_should_balance_multicols_bool + { * } + } + } + } + +\bool_new:N \g__mn_should_balance_multicols_bool + +\keys_define:nn { mn__main } + { + columns .int_set:N = \g__mn_fs_columns_int , + columns .initial:x = 3 , + + balance~columns .default:n = true , + balance~columns .bool_set:N = \g__mn_should_balance_multicols_bool , + + width .value_required:n = true , + width .code:n = \geometry{ paperwidth = #1 } , + + height .value_required:n = true , + height .code:n = \geometry{ paperheight = #1 } , + } + +\RequirePackage + [ + letterpaper , + margin = 0.1in , + ] + { geometry } + +\skip_set:Nn \parskip { 0.25em } + +\RequirePackage { enumitem } +\setlist + { + nosep + } + +\def\section#1{\hrulefill\\\textbf{#1}\\} diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-hw.cls b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-hw.cls new file mode 100644 index 0000000000..24e91f715e --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-hw.cls @@ -0,0 +1,325 @@ +%% rbt-mathnotes-hw.cls +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplClass{rbt-mathnotes-hw}{2021/11/29}{1.0.2}{Companion styles + to rbt-mathnotes for typeset homework assignments.} + +% \PassOptionsToPackage{noxcolor}{rbt-mathnotes} + +\RequirePackage{kvoptions} +\DeclareDefaultOption + { + \PassOptionsToClass { \CurrentOption } { rbt-mathnotes } + } +\ProcessKeyvalOptions* + +\LoadClass { rbt-mathnotes } + +\cs_set:Npn \mn__undefine_thm:n #1 + { + \cs_undefine:c { #1 } + \cs_undefine:c { end#1 } + \cs_undefine:c { #1* } + \cs_undefine:c { end#1* } + } + +\mn__undefine_thm:n { thm } +\mn__undefine_thm:n { lem } +\mn__undefine_thm:n { cor } +\mn__undefine_thm:n { prop } +\mn__undefine_thm:n { defn } +\mn__undefine_thm:n { notation } +\mn__undefine_thm:n { ex } + +\cs_undefine:N \mn__undefine_thm:n + +\theoremstyle { definition } +\newtheorem { thm } { Theorem } +\newtheorem { lem } { Lemma } +\newtheorem { cor } { Corollary } +\newtheorem { prop } { Proposition } +\newtheorem { defn } { Definition } +\newtheorem { notation } { Notation } +\newtheorem { ex } { Example } + +% The displayed problem number. \g__mn_problems_int isn't incremented if a +% custom number is given. +\int_new:N \g__mn_problems_int +\int_set_eq:NN \g__mn_problems_int \c_one_int + +% The internal problem number. \g__mn_all_problems_int is *always* +% incremented, so it can be used as a unique identifier in hyperref +% pdf bookmark names. +\int_new:N \g__mn_all_problems_int +\int_set_eq:NN \g__mn_all_problems_int \c_one_int + +% Label prepended to problem numbers. +\tl_const:Nn \g__mn_problem_string_tl { Problem } + +\skip_const:Nn \g__mn_problem_before_skip { 2em } + +% Label appended to problem numbers; omitted from PDF bookmarks. +\tl_const:Nn \g__mn_problem_after_tl { . } + +% A possible custom problem number. If \c_novalue_tl, use +% \g__mn_problems_int instead. +\tl_new:N \mn__problem_number_tl +\tl_set_eq:NN \mn__problem_number_tl \c_novalue_tl + +\tl_const:Nn \mn__problem_number_default_tl + { + \int_to_arabic:n { \g__mn_problems_int } + } + +% Current problem number, either from \g__mn_problems_int or +% \mn__problem_number_tl. +\tl_new:N \mn__problem_number_current_tl + +% Current problem display title, including "problem" label, number, and +% custom title. +% \tl_new:N \mn__problem_display_title_tl + +\keys_define:nn { mn__main } + { + problem~string .value_required:n = true , + problem~string .tl_set:N = \g__mn_problem_string_tl , + problem~before~skip .skip_set:N = \g__mn_problem_before_skip + } + +\keys_define:nn { mn__problem } + { + number .value_required:n = true , + number .tl_set:N = \mn__problem_number_tl , + + title .value_required:n = true , + title .tl_set:N = \mn__problem_title_tl , + title .initial:n = , + + label .value_required:n = true , + label .tl_set:N = \mn__problem_label_tl , + + % Treat unknown keys as the problem number; this lets us avoid having + % 2 or more optional arguments. + unknown .code:n = + \tl_if_empty:nTF { #1 } + { + % No value; use it for the problem number. + \tl_set_eq:NN \mn__problem_number_tl \l_keys_key_tl + } + { + % Non-empty value; give an error. + \msg_error:nnx + { mathnotes } + { no key in problem } + { \tl_use:N \l_keys_key_tl } + } , + } + +\cs_set:Npn \mn__problem_title_pdf: + { + % A string like "Problem" or "Exercise" or "Question" + \tl_use:N \g__mn_problem_string_tl + % The problem number. + \tl_if_empty:NF \mn__problem_number_current_tl + { + \ \tl_use:N \mn__problem_number_current_tl + } + \tl_if_empty:NF \mn__problem_title_tl + { + :~\tl_use:N \mn__problem_title_tl + } + } + +\cs_set:Npn \mn__problem_title: + { + \mn__problem_title_pdf: + % The text after the problem, nominally a period ("."). + \tl_use:N \g__mn_problem_after_tl + } + +% PDF anchor / bookmark name for hyperref. +\cs_set:Npn \mn__problem_anchor: + { + problem.\int_to_arabic:n { \g__mn_all_problems_int } + } + +\NewDocumentEnvironment { problem } + { + O{} % Problem number or options + } + { + \keys_set:nn { mn__problem } { #1 } + + % Set the problem number + \tl_set:Nn \mn__problem_number_current_tl { } + \tl_if_eq:NNTF \mn__problem_number_tl \c_novalue_tl + { + % No number given + \tl_set_eq:NN \mn__problem_number_current_tl \mn__problem_number_default_tl + } + { + % Some number given, *maybe* empty + \tl_set_eq:NN \mn__problem_number_current_tl \mn__problem_number_tl + } + + \vspace { \skip_use:N \g__mn_problem_before_skip } + + \phantomsection + \addcontentsline + { toc } + { chapter } + { \mn__problem_title_pdf: } + \begin{mdframed} + [ + style = note , + startinnercode = + \mn__note_title:n + { + \cs_gset:Npx \@currentlabel { \tl_use:N \mn__problem_number_current_tl } + \cs_gset:Npx \@currentlabelname { \mn__problem_title: } + \tl_if_empty:NF \mn__problem_label_tl + { + \exp_after:wN \label { \tl_use:N \mn__problem_label_tl } + } + \mn__problem_title: + } + , + ] + } + { + \end{mdframed} + % If we didn't get a custom number, increment the counter. + \tl_if_eq:NNT \mn__problem_number_tl \c_novalue_tl + { + \int_gincr:N \g__mn_problems_int + } + % But always increment the internal counter. + \int_gincr:N \g__mn_all_problems_int + } + +\NewDocumentCommand \prob + { + O{} % Problem number or options + m % Problem text + } + { + \begin{problem}[#1] + #2 + \end{problem} + } + +\cs_set:Npn \mn__add_par_arg_to_sectioning_cmd:N #1 + { + \cs_set_eq:cN { mn__\cs_to_str:N #1 _old } #1 + \cs_set_eq:cc + { mn__the\cs_to_str:N #1 _old } + { the\cs_to_str:N #1 } + \RenewDocumentCommand #1 + { + s % ##1: Numbered / in ToC? + d() % ##2: Number override. + o % ##3: ToC title. + o % ##4: Page header title. + m % ##5: Title. + } + { + \group_begin: + \cs_set:Npx \mn__current_thesection_cmd + { the\cs_to_str:N #1 } + % Is there a number override? + \IfValueTF { ##2 } + { + % If yes, *globally* change the number format. + \cs_gset:cpn { \mn__current_thesection_cmd } { ##2 } + } + { + % Otherwise, restore the number format from a previous override, + % if applicable. + \cs_gset_eq:cc + { \mn__current_thesection_cmd } + { mn__the\cs_to_str:N #1 _old } + } + % Save the original command so we can use it as a single token. + \cs_set_eq:Nc \mn__orig_sectioning_cmd { mn__\cs_to_str:N #1 _old } + \exp_last_unbraced:Ne \mn__orig_sectioning_cmd + { + % Propagate the star. + \IfBooleanT { ##1 } { * } + % Propogate other arguments. + \IfValueT { ##3 } { [##3] } + \IfValueT { ##4 } { [##4] } + { ##5 } + } + \group_end: + } + } + +\cs_set:Npn \mn__add_par_arg_to_sectioning_cmds:n #1 + { + \clist_map_function:nN { #1 } \mn__add_par_arg_to_sectioning_cmd:N + } + +\makeheadstyles { rbt-mathnotes-hw } + { + \chapterstyle { rbt-mathnotes } + \headstyles { rbt-mathnotes } + + % Don't use chapter numbers in sections and beyond: + \cs_set:Npn \thesection { \arabic{section} } + + % Add paren-arg to override numbers in sectioning commands. + \mn__add_par_arg_to_sectioning_cmds:n + { + \chapter , + \section , + \subsection , + \subsubsection , + \paragraph , + \subparagraph , + } + } + +\headstyles { rbt-mathnotes-hw } + +\setlength{\columnsep}{3em} + +% No chapter numbers for figures. +\counterwithout{figure}{chapter} + +% Put author name, title in headings +\makeevenfoot { headings } { } { } { } +\makeoddfoot { headings } { } { } { } +\makeevenhead { headings } { } { } { \thepage } +\makeoddhead { headings } { \@author,~\textit{ \@title } } { } { \thepage } diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-messages.sty b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-messages.sty new file mode 100644 index 0000000000..30b0c1a777 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-messages.sty @@ -0,0 +1,76 @@ +%% rbt-mathnotes-messages.sty +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplPackage{rbt-mathnotes-messages}{2021/11/29}{1.0.2}{Messages + for mathnotes.} + +\msg_new:nnnn { mathnotes } + { no name } + { + No~author~name~given~but~\exp_not:N \maketitle~was~still~used. + } + { + Set~your~name~in~the~preamble: \\ + \exp_not:N \mathnotes\{~name~=~Your~name~...~,~\} + } + +\msg_new:nnnn { mathnotes } + { acronym already defined } + { + Command~#1~already~defined;~refusing~to~redefine~as~an~acronym~for~#2. + } + { + Pick~a~different~destination~control~sequence~with~\protect\newacronym's~ + optional~argument? + } + +\msg_new:nnnn { mathnotes } + { no key in problem } + { + Key~#1~is~not~defined~for~the~problem~environment. + } + { + If~you~meant~to~set~the~problem~number,~don't~include~a~value. + } + + +\msg_new:nnnn { mathnotes } + { requires memoir class } + { + Option~#1~can~only~be~used~with~the~memoir~class! + } + { + Use~the~memoir~document~class~or~one~of~the~rbt-mathnotes~classes~wrapping~it. + } diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-util.sty b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-util.sty new file mode 100644 index 0000000000..b95c73da01 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes-util.sty @@ -0,0 +1,180 @@ +%% rbt-mathnotes-util.sty +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplPackage{rbt-mathnotes-util}{2021/11/29}{1.0.2}{Utility commands + for rbt-mathnotes.} + +\cs_set:Npn \mn__legacy_bool_option:n #1 + { + \bool_new:c { g__mn_#1_bool } + \csname if\@currname @#1 \endcsname + \bool_gset_true:c { g__mn_#1_bool } + \else + \bool_gset_false:c { g__mn_#1_bool } + \fi + } + +\keys_define:nn { mn_options } + { + init .tl_set:N = \l__mn_options_init_tl , + init .default:n = true , + init .initial:x = \tl_use:N \c_novalue_tl , + + default .tl_set:N = \l__mn_options_default_tl , + default .value_required:n = true , + default .initial:x = \tl_use:N \c_novalue_tl , + + type .choice: , + type .choices:nn = { bool, str } + { \tl_set_eq:NN \l__mn_options_type_tl \l_keys_choice_tl } , + type .value_required:n = true , + type .initial:n = bool , + } + +% A hook which executes after \ProcessKeyvalOptions and is used to convert +% TeX booleans and so on to LaTeX3 booleans and strings. +\tl_new:N \g__mn_after_options_hook_tl +% A hook used to define a particular option, allowing keys to be set only in +% a group. +\tl_new:N \g__mn_define_option_tl +% Initializes complementary #1 and no#1 package options. +\NewDocumentCommand \mn__option_new { o m } + { + \tl_gclear:N \g__mn_define_option_tl + \group_begin: + \tl_if_novalue:nF { #1 } + { \keys_set:nn { mn_options } { #1 } } + + \tl_set:Nn \l_tmpa_tl { bool } + \tl_if_eq:NNT \l__mn_options_type_tl \l_tmpa_tl + { + % If no default was given, use `false` for bools. + \tl_if_eq:NNT \l__mn_options_init_tl \c_novalue_tl + { \tl_set:Nn \l__mn_options_init_tl { false } } + + \tl_gput_right:Nx \g__mn_define_option_tl + { + \exp_not:N \DeclareBoolOption [\l__mn_options_init_tl]{#2} + \exp_not:N \DeclareComplementaryOption {no#2}{#2} + } + + % After we process options, convert to an expl3 bool. + \tl_gput_right:Nn \g__mn_after_options_hook_tl + { + % Adapt the legacy bool into an expl3 bool. + \mn__legacy_bool_option:n { #2 } + % Then, delete the legacy bool. + \mn__legacy_bool_undefine:n { \@currname @#2 } + } + } + + % For a string option: + \tl_set:Nn \l_tmpa_tl { str } + \tl_if_eq:NNT \l__mn_options_type_tl \l_tmpa_tl + { + \tl_gput_right:No \g__mn_define_option_tl + { + \exp_not:N \DeclareStringOption + \tl_if_eq:NNF \l__mn_options_init_tl \c_novalue_tl + { [\l__mn_options_init_tl] } + { #2 } + \tl_if_eq:NNF \l__mn_options_default_tl \c_novalue_tl + { [\l__mn_options_default_tl] } + } + + \tl_gput_right:Nn \g__mn_after_options_hook_tl + { + % Create the new tl for this option. + \tl_new:c { g__mn_#2_tl } + % Set it to the command kvoptions created. + \tl_set:co { g__mn_#2_tl } { \cs:w \@currname @#2 \cs_end: } + % Delete the old command. + \cs_undefine:c { \@currname @#2 } + } + } + \group_end: + \tl_use:N \g__mn_define_option_tl + } + +\cs_set:Npn \mn__process_options:n #1 + { + \ProcessKeyvalOptions { #1 } + \tl_use:N \g__mn_after_options_hook_tl + } + +\cs_set:Npn \mn__legacy_bool_undefine:n #1 + { + \cs_undefine:c { if#1 } + \cs_undefine:c { #1true } + \cs_undefine:c { #1false } + } + +% Package configuration string values. +% {< module >}{< family >}{< key name >} +\cs_set:Npn \mn__key_new:nnn #1#2#3 + { + \tl_set_eq:cN { l__#1_#3_tl } \c_novalue_tl + \keys_define:nn { #2 } + { + #1 .value_required:n = true, + #1 .tl_set:c = l__#1_#3_tl, + } + } + +\cs_set:Npn \mn__mathnotes_key_new:n #1 + { + \mn__key_new:nnn { mn } { mathnotes } { #1 } + } + +\cs_set:Npn \mn__keys_new:n #1 { \clist_map_function:nN { #1 } \mn__mathnotes_key_new:n } + +\prg_new_conditional:Npnn \mn__if_package_loaded:n #1 + { p, T, F, TF } + { + \@ifpackageloaded { #1 } + { \prg_return_true: } + { \prg_return_false: } + } + +\prg_new_conditional:Npnn \mn__if_novalue:N #1 + { p, T, F, TF } + { + \tl_if_eq:NNTF \c_novalue_tl #1 + { \prg_return_true: } + { \prg_return_false: } + } +\prg_generate_conditional_variant:Nnn \mn__if_novalue:N + { c } + { p, T, F, TF } diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.cls b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.cls new file mode 100644 index 0000000000..df69338ad1 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.cls @@ -0,0 +1,202 @@ +%% rbt-mathnotes.cls +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplClass{rbt-mathnotes}{2021/11/29}{1.0.2}{Styles for mathematical + note taking.} + +\PassOptionsToClass { openany, oneside } { memoir } + +\LoadClass{memoir} +\setsecnumdepth{subsubsection} +\settocdepth{subsubsection} +\nouppercaseheads +\makeevenfoot { plain } { } { } { } +\makeoddfoot { plain } { } { } { } +\makeevenhead { plain } { } { } { \thepage } +\makeoddhead { plain } { } { } { \thepage } + +\RequirePackage{etoolbox} +\RequirePackage{xparse} +\AtBeginDocument{ + \patchcmd { \@tocmaketitle } + { \thispagestyle { chapter } } + { } + { } + { } + } + +\makechapterstyle { rbt-mathnotes } + { + % allow for 99 chapters! + \settowidth{\chapindent}{\chapnumfont 999} + + \RenewDocumentCommand \chapnumfont { } + { + \normalfont + \huge + \exp:w \mn__color:n {MNsecnum} + } + \RenewDocumentCommand \chapterheadstart { } { } + \RenewDocumentCommand \printchaptername { } { } + \RenewDocumentCommand \chapternamenum { } { } + \RenewDocumentCommand \printchapternum { } + { + \noindent + \llap + { + \makebox [ \chapindent ] + { \chapnumfont \thechapter } + } + } + \RenewDocumentCommand \afterchapternum { } { } + \RenewDocumentCommand \printchaptertitle { m } + { + \raggedright + \huge + ##1 + } + \RenewDocumentCommand \afterchaptertitle { } + { + \vskip \onelineskip + \hrule + \vskip \onelineskip + } + } + +\makeheadstyles { rbt-mathnotes } + { + \chapterstyle { rbt-mathnotes } + + \setsecnumformat + { + \group_begin: + \exp:w \mn__color:n {MNsecnum} + \cs:w the##1 \cs_end: + \quad + \group_end: + } + + % Sections. + \setbeforesecskip + { + -1\onelineskip plus -0.5\onelineskip minus -0.5\onelineskip + } + \setaftersecskip + { + 1\onelineskip plus 0.1\onelineskip + } + \setsecheadstyle + { + \normalfont + \memRTLraggedright + \bfseries + \LARGE + % \scshape + % \MakeTextLowercase + } + + % Subsections. + \setbeforesubsecskip + { + -1.0\onelineskip plus -0.25\onelineskip minus -0.25\onelineskip + } + \setaftersubsecskip + { + 1.0\onelineskip plus 0.1\onelineskip + } + \setsubsecheadstyle + { + \sethangfrom { \noindent ####1 } + \normalfont + \bfseries + \memRTLraggedright + } + + % Subsubsections. + \setbeforesubsubsecskip + { + 1.0\onelineskip plus 0.5\onelineskip minus 0.2\onelineskip + } + \setaftersubsubsecskip + { + 1.0\onelineskip plus 0.1\onelineskip + } + \setsubsubsecheadstyle + { + \normalfont + \normalsize + \bfseries + \memRTLraggedright + } + + % Paragraphs. + \setbeforeparaskip + { + 1.0\onelineskip plus 0.5\onelineskip minus 0.2\onelineskip + } + \setafterparaskip { -1em } + \setparaheadstyle + { + \normalfont + \normalsize + \bfseries + } + + % Subparagraphs. + \setsubparaindent { \parindent } + \setbeforesubparaskip + { + 1.0\onelineskip plus 0.5\onelineskip minus 0.2\onelineskip + } + \setaftersubparaskip { -1em } + \setsubparaheadstyle + { + \normalfont + \normalsize + \itshape + \addperiod + } + } + +\headstyles { rbt-mathnotes } + +% \chapterstyle{hangnum} +% \cs_set:Npn \chapnumfont + % { + % \HUGE \bfseries + % \exp:w \mn__color:n {MNsecnum} + % } + +\RequirePackage { rbt-mathnotes } diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.pdf b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.pdf new file mode 100644 index 0000000000..0041a12eb2 Binary files /dev/null and b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.pdf differ diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.sty b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.sty new file mode 100644 index 0000000000..afa05cbfb8 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.sty @@ -0,0 +1,1122 @@ +%% rbt-mathnotes.sty +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\NeedsTeXFormat{LaTeX2e} +\RequirePackage{expl3} +\ProvidesExplPackage{rbt-mathnotes}{2021/11/29}{1.0.2}{Styles for + mathematical note taking.} +\errorcontextlines 20 +% Module 'mn' + +% Load some utility packages. +\RequirePackage{xparse} % Better command declarations. +\RequirePackage{xkeyval} % Better keyval parsing. +% {{{ Package options +\RequirePackage{kvoptions} % More flexible package options. +\RequirePackage{rbt-mathnotes-util} + +\SetupKeyvalOptions + { + family = mn__package_options , + } + +\mn__option_new[init = true]{fonts} +\mn__option_new[init = true]{stix} +\mn__option_new[init = true]{symbols} +\mn__option_new[init = true]{maketitle} +\mn__option_new[init = true]{titles} +\mn__option_new[init = true]{xcolor} +\mn__option_new[init = true]{theorems} +\mn__option_new[init = true]{enumitem} +\mn__option_new{listings} +\mn__option_new{knowledge} +\mn__option_new{index} +\mn__option_new{footnotes} +\mn__option_new{figures} +\mn__option_new{tabu} +\mn__option_new{kindle} + +\mn__process_options:n { mn__package_options } % }}} + +\RequirePackage{rbt-mathnotes-messages} + +% {{{ Load fonts. +% Check if we can load fontspec; this is taken from fontspec.sty. +\bool_new:N \c__mn_fontspec_bool +\bool_set:Nn \c__mn_fontspec_bool + { + \sys_if_engine_xetex_p: || \sys_if_engine_luatex_p: + } + +% NOTE: The order these packages are loaded in is very important. +% - mathtools has to be loaded before these or overbrackets and such get +% messed up +% - unicode-math overwrites a bunch of commands, so should be loaded after +% amsmath and others +% - amsmath should be loaded after stix2 (not sure why, but the stix2 +% documentation specifies this) -- however, if we can use fontspec, we +% just load the stix2 fonts without the stix2 package itself, so we load +% amsmath before unicode-math (and the stix2 fonts) +\RequirePackage{mathtools} +\bool_if:NTF \g__mn_fonts_bool + { + \bool_if:NTF \c__mn_fontspec_bool + { + \RequirePackage{amsmath}[2013/01/14] + % unicode-math makes equations copy/pastable in PDF output. + % Note that unicode-math encapsulates the functionality of fontspec. + \RequirePackage[ + warnings-off={mathtools-colon,mathtools-overbracket} + ]{unicode-math} + \bool_if:NT \g__mn_stix_bool + { + \setmainfont + [ + UprightFont = *-Regular , + ItalicFont = *-Italic , + BoldFont = *-Bold , + BoldItalicFont = *-BoldItalic , + Extension = .otf , + ] + { STIX2Text } + + \setmathfont + [ + StylisticSet = + { + 1 , % better caligraphic forms + 8 , % upright integrals + } , + Extension = .otf , + ] + { STIX2Math } + } + } + { + % Otherwise, load non-XeTeX fallbacks. + \bool_if:NT \g__mn_stix_bool + { + \RequirePackage[upint]{stix2} + } + \RequirePackage{amsmath}[2013/01/14] + } + } + { + % No fonts + \RequirePackage{amsmath}[2013/01/14] + } % }}} + +\bool_if:NT \g__mn_symbols_bool % {{{ Define math symbol commands + { + % Logical not + \mn__if_package_loaded:nTF { unicode-math } + { \DeclareDocumentCommand \lnot {} { \char "AC } } % 0xAC = ¬ + { \mathchardef \Not = "1218 } + + % Blackboard bold set symbols + \NewDocumentCommand \Rational {}{\mathbb{Q}} + \ProvideDocumentCommand \Rat {}{\Rational} + \ProvideDocumentCommand \Q {}{\Rational} + + % \NewDocumentCommand \Irrational {}{\mathbb{I}} + % \ProvideDocumentCommand \Irrat {}{\Irrational} + % \ProvideDocumentCommand \I {}{\Irrational} + + \NewDocumentCommand \Natural {}{\mathbb{N}} + \ProvideDocumentCommand \Nat {}{\Natural} + \ProvideDocumentCommand \N {}{\Natural} + + \NewDocumentCommand \Integer {}{\mathbb{Z}} + \ProvideDocumentCommand \Int {}{\Integer} + \ProvideDocumentCommand \Z {}{\Integer} + + \NewDocumentCommand \Complex {}{\mathbb{C}} + \ProvideDocumentCommand \Comp {}{\Complex} + % Renew \C to mean \Complex in math-mode; normally, \C just gives an + % error in math-mode. + % ...if \C isn't defined, just define it normally. + \AtBeginDocument + { + \cs_if_free:NTF \C + { \NewDocumentCommand } + { + \cs_set_eq:NN \mn__C_old \C + \RenewDocumentCommand + } + \C {}{ + \mode_if_math:TF + { \Complex } % Complex set + { \mn__C_old } % Copyright sign + } + } + + \NewDocumentCommand \Real {}{\mathbb{R}} + \ProvideDocumentCommand \R {}{\Real} + + % Using the Weierstrass p here is probably a bit controversial, but I like + % it. I'm open to change, though... + \ProvideDocumentCommand \powerset {}{\wp} + + \RenewDocumentCommand \vec {m}{\mathbf{#1}} + + % Operator synonyms. + % Set intersect. + \ProvideDocumentCommand \intersection {}{\cap} + \ProvideDocumentCommand \inter {}{\cap} + \ProvideDocumentCommand \bigintersection {}{\bigcap} + \ProvideDocumentCommand \biginter {}{\bigcap} + + % Set union. + \ProvideDocumentCommand \union {}{\cup} + \ProvideDocumentCommand \bigunion {}{\bigcup} + % Disjoint union. + \ProvideDocumentCommand \disjointunion {}{\sqcup} + \ProvideDocumentCommand \disunion {}{\sqcup} + + % Divisiblity. + \ProvideDocumentCommand \divisible {}{\mid} + \ProvideDocumentCommand \div {}{\mid} + % Negation. + \ProvideDocumentCommand \notdivisible {}{\nmid} + \ProvideDocumentCommand \ndivisible {}{\nmid} + \ProvideDocumentCommand \notdiv {}{\nmid} + \ProvideDocumentCommand \ndiv {}{\nmid} + + % Wrappers around floor and ceil. + \ProvideDocumentCommand \floor {m}{\lfloor #1\rfloor} + \ProvideDocumentCommand \ceil {m}{\lceil #1\rceil} + + % The default empty set symbol is very ugly. Use \varnothing instead, + % which is less ugly. + \AtBeginDocument{\RenewDocumentCommand \emptyset {}{\varnothing}} + \ProvideDocumentCommand \es {}{\emptyset} + + % Function composition. The notation g \after f helps internalize the + % order of operations. :) + \ProvideDocumentCommand \after {}{\circ} + + % Cross product. + \ProvideDocumentCommand \cross {}{\times} + + % Operators. + % Function image. + \cs_if_free:NT \img + { \DeclareMathOperator \img {img} } + % Function pre-image. + \cs_if_free:NT \pre + { \DeclareMathOperator \pre {pre} } + % Function stabilizer. + \cs_if_free:NT \Stab + { \DeclareMathOperator \Stab {Stab} } + % Set of a function's fixed points. + \cs_if_free:NT \FixPt + { \DeclareMathOperator \FixPt {FixPt} } + % Identity function + \cs_if_free:NT \id + { \DeclareMathOperator \id {id} } + + % Injective function. + \ProvideDocumentCommand \injection {}{\hookrightarrow} + \ProvideDocumentCommand \inj {}{\hookrightarrow} + % Surjective function. + \ProvideDocumentCommand \surjection {}{\twoheadrightarrow} + \ProvideDocumentCommand \surj {}{\twoheadrightarrow} + % Bijective function. + \ProvideDocumentCommand \bijection {}{\twoheadrightarrowtail} + \ProvideDocumentCommand \bijective {}{\twoheadrightarrowtail} + \ProvideDocumentCommand \bij {}{\twoheadrightarrowtail} + % Function restriction. + \cs_if_free:NT \restriction + { \DeclareMathOperator \restriction {|} } + \ProvideDocumentCommand \restr {}{\restriction} + + % d/dx + \ProvideDocumentCommand \dd { O{} m }{\frac{d#1}{d#2}} + \ProvideDocumentCommand \pd { O{} m }{\frac{\partial#1}{\partial#2}} + \ProvideDocumentCommand \gradient {}{\nabla} + \ProvideDocumentCommand \grad {}{\nabla} + \cs_if_free:NT \curl + { \DeclareMathOperator \curl {curl} } + \cs_if_free:NT \dive + { \DeclareMathOperator \dive {div} } + } % }}} + +% Gives this an equation a number in an amsmath starred environment. +\ProvideDocumentCommand \numberthis { } % {{{ + { + \tag { \theequation } + \refstepcounter { equation } + } % }}} + +% Gives this equation a number and label in an amsmath starred environment. +\ProvideDocumentCommand \labelthis { m } % {{{ + { + \numberthis + \IfValueT { #1 } + { \label { #1 } } + } % }}} + +\bool_if:NT \g__mn_enumitem_bool + { \RequirePackage{enumitem} } + +\bool_if:NT \g__mn_listings_bool + { \RequirePackage{listings} } + +\bool_if:NT \g__mn_xcolor_bool % {{{ Load xcolor and define MN colors + { + \PassOptionsToPackage { rgb } { xcolor } + \RequirePackage { xcolor } + \providecolorset { HTML } + % Prefix/postfix of all color names + { } { } + { + \use_none:n + ; MNthmtitle , 0F0066 + ; MNthmbg , EBFEFF + ; MNthmline , 4836B3 + ; MNextitle , 692219 + ; MNexbg , FFF0EB + ; MNexline , CC7468 + ; MNdefntitle , 00540B + ; MNdefnline , 196924 + ; MNdefnbg , EBFFED + ; MNnotetitle , 6B0019 + ; MNnoteline , CC3F60 + ; MNnotebg , FFF5F7 + + ; MNsecnum , 8015A1 + + ; MNlink , 113DB8 + } + } % }}} + +\bool_if:NT \g__mn_listings_bool % {{{ Better default styles + { + \RequirePackage { xcolor } + \lstset + { + % Use a monospace font for code listings. + basicstyle = \ttfamily , + language = Mathematica , + % Tab size of 4, but you should probably use spaces. + tabsize = 4 , + % Keywords in blue. + keywordstyle = \bfseries\ttfamily\color[rgb]{0,.3,.7} , + % Comments in green. + commentstyle = \color[rgb]{0.133,0.545,0.133} , + % Strings in orange. + stringstyle = \color[rgb]{0.75,0.49,0.07} , + % The default listings characters are too widely-spaced. + % 0.55em/character makes things look a lot better. + basewidth = 0.55em , + % Wrap lines if they're too long, and wrap at whitespace. + breaklines , + breakatwhitespace = true , + } + } % }}} + +% Creates an acronym-command. +% \newacronym[<\command>]{} defines \command to be \textsc{text}. +% \newacronym{} defines \text to be \textsc{text}. +\ProvideDocumentCommand \newacronym { o m } % {{{ + { + \group_begin: + % If we have #1, then #1 is the cs we're going to define; #1 is a cs. + % Otherwise, we define \#2. + \IfValueTF { #1 } + { \cs_set:Npn \mn__acronym_cs: { \cs_to_str:N #1 } } + { \cs_set:Npn \mn__acronym_cs: { #2 } } + + % Ensure that the cs is undefined. + \cs_if_exist:cT { \mn__acronym_cs: } + { + \msg_error:nnxx + { mathnotes } + { acronym already defined } + { \exp_not:c { \mn__acronym_cs: } } + { #2 } + } + + % Finally, define the acronym command. + \cs_new:cpn { \mn__acronym_cs: } + { \textsc { #2 } } + \group_end: + } % }}} + +% \newacronyms takes a comma-separated list as its argument and defines them +% all as acronyms. +\ProvideDocumentCommand \newacronyms { m } + { \clist_map_function:nN { #1 } \newacronym } + +% {{{ Package configuration string values; \mathnotes command +\keys_define:nn { mn__main } + { + date .value_required:n = true , + date .code:n = \date{#1} , + author .value_required:n = true , + author .code:n = \author{#1} , + title .value_required:n = true , + title .code:n = \title{#1} , + + generate~thanks .value_required:n = false , + generate~thanks .bool_set:N = \g__mn_should_make_thanks , + generate~thanks .default:n = true , + generate~thanks .initial:n = true , + } + +\cs_set:Npn \mn__key_new:n #1 + { + \keys_define:nn { mn__main } + { + #1 .value_required:n = true , + #1 .tl_gset:c = g__mn_#1_tl , + #1 .initial:x = , + } + } + +\cs_set:Npn \mn__keys_new:n #1 { \clist_map_function:nN { #1 } \mn__key_new:n } + +\mn__keys_new:n + { + instructor, course, name, email, institution, semester, + } + +\NewDocumentCommand \mathnotes { m } + { + \keys_set:nn { mn__main } { #1 } + } +% }}} + +\bool_if:NT \g__mn_maketitle_bool % {{{ \author, \title, \maketitle, \thanks, etc. + { + \bool_new:N \g__mn_author_set + \cs_set:Npn \author #1 + { + \bool_gset_true:N \g__mn_author_set + \cs_gset:Npn \@author { #1 } + } + + \bool_new:N \g__mn_title_set + \cs_set:Npn \title #1 + { + \bool_gset_true:N \g__mn_title_set + \cs_gset:Npn \@title { #1 } + } + + \prg_new_conditional:Npnn \mn__if_should_make_thanks: % {{{ + { T, } + { + \bool_if:NTF \g__mn_should_make_thanks + { + \bool_lazy_all:nTF + { + { \tl_if_empty_p:N \g__mn_email_tl } + { \tl_if_empty_p:N \g__mn_course_tl } + { \tl_if_empty_p:N \g__mn_instructor_tl } + { \tl_if_empty_p:N \g__mn_institution_tl } + { \tl_if_empty_p:N \g__mn_semester_tl } + } + { \prg_return_false: } + { \prg_return_true: } + } + { \prg_return_false: } + } % }}} + + \cs_set:Npn \mn__make_thanks_text % {{{ + { + \tl_if_empty:NF \g__mn_email_tl + { + \email { \tl_use:N { \g__mn_email_tl } } + \bool_lazy_all:nF + { + { \tl_if_empty_p:N \g__mn_course_tl } + { \tl_if_empty_p:N \g__mn_instructor_tl } + { \tl_if_empty_p:N \g__mn_institution_tl } + { \tl_if_empty_p:N \g__mn_semester_tl } + } + { ;~ } + } + \tl_if_empty:NF \g__mn_course_tl + { + \tl_use:N \g__mn_course_tl + \bool_lazy_all:nF + { + { \tl_if_empty_p:N \g__mn_instructor_tl } + { \tl_if_empty_p:N \g__mn_institution_tl } + { \tl_if_empty_p:N \g__mn_semester_tl } + } + { ~ } + } + \tl_if_empty:NF \g__mn_instructor_tl + { + \bool_lazy_all:nTF + { + { \tl_if_empty_p:N \g__mn_email_tl } + { \tl_if_empty_p:N \g__mn_course_tl } + } + { Taught~by~ } + { taught~by~ } + \tl_use:N \g__mn_instructor_tl + } + \tl_if_empty:NF \g__mn_institution_tl + { + \bool_lazy_all:nTF + { + { \tl_if_empty_p:N \g__mn_email_tl } + { \tl_if_empty_p:N \g__mn_course_tl } + { \tl_if_empty_p:N \g__mn_instructor_tl } + } + { At~ } + { ~at~ } + \tl_use:N \g__mn_institution_tl + } + \tl_if_empty:NF \g__mn_semester_tl + { + \bool_lazy_all:nF + { + { \tl_if_empty_p:N \g__mn_email_tl } + { \tl_if_empty_p:N \g__mn_course_tl } + { \tl_if_empty_p:N \g__mn_instructor_tl } + { \tl_if_empty_p:N \g__mn_institution_tl } + } + { ,~ } + \tl_use:N \g__mn_semester_tl + } + . + } % }}} + + \cs_set:Npn \@author % {{{ + { + % If the author hasn't been set, we provide this (complicated, PITA) + % default; however, if we don't have any information to put in it, we + % still give a warning. + \tl_if_eq:NNTF \g__mn_name_tl \c_novalue_tl + { + \msg_warning:nn { mathnotes } { no name } + } + { + \tl_use:N \g__mn_name_tl + % Do we have any information to put in a \thanks? + \mn__if_should_make_thanks:T + { + \thanks { \mn__make_thanks_text } + } + } + } % }}} + + % {{{ \@maketitle and \maketitle + \skip_const:Nn \g__mn_maketitle_after_title { 1em } + \skip_const:Nn \g__mn_maketitle_after_author { 0.5em } + \skip_const:Nn \g__mn_maketitle_after { 1.5em } + + \RenewDocumentCommand \@maketitle {} + { + \begin{center} + \let \footnote \thanks + + % Set the title, if it exists. + \bool_if:NT \g__mn_title_set + { + \group_begin: + \HUGE + \bfseries + \@title + \par + \group_end: + } + \skip_vertical:N \g__mn_maketitle_after_title + + % Set the author. + \group_begin: + \LARGE + \lineskip 0.5em + \begin{tabular}[t]{c} + \@author + \end{tabular} + \par + \group_end: + \skip_vertical:N \g__mn_maketitle_after_author + + % Set the date. + \large + \@date + + \end{center} + \par + \skip_vertical:N \g__mn_maketitle_after + } + + \RenewDocumentCommand \maketitle {} + { + \par + \group_begin: + \cs_set:Npn \thefootnote + { + \@fnsymbol + \c@footnote + } + \cs_set:Npn \@makefnmark + { + \rlap + { + \@textsuperscript { \normalfont \@thefnmark } + } + } + \cs_set:Npn \@makefntext ##1 + { + \parindent 1em + \noindent + \hbox_to_wd:nn + { 1.8em } + { + \hss + \@textsuperscript { \normalfont \@thefnmark } + } + ##1 + } + \legacy_if:nTF { @twocolumn } + { + \if_int_compare:w \col@number = \@ne + \@maketitle + \else: + \twocolumn [ \@maketitle ] + \fi: + } + { + \newpage + \global\@topnum\z@ + \@maketitle + } + \thispagestyle{empty} + \@thanks + \group_end: + \setcounter{footnote}{0} + \cs_set:Npn \thanks ##1 { } + % NOTE: we don't erase the definitions of \@title, etc. + } + % }}} \@maketitle and \maketitle + } % }}} + +\bool_if:NT \g__mn_kindle_bool % {{{ + { + \keys_set:nn { mn__main } + { + generate~thanks = false , + } + \skip_gset:Nn \g__mn_maketitle_after_title { 0em } + \skip_gset:Nn \g__mn_maketitle_after_author { 0em } + \skip_gset:Nn \g__mn_maketitle_after { 0em } + \@ifclassloaded { memoir } + { + \pagestyle { empty } + + \setstocksize{12.2cm}{9cm} + \settrimmedsize{12.2cm}{9cm}{*} + \settypeblocksize{12.2cm}{9cm}{*} + + \setlrmargins{0cm}{*}{*} + \setulmargins{0cm}{*}{*} + + \setlength{\headheight}{0cm} + \setlength{\headsep}{0cm} + \setlength{\footskip}{0cm} + + \checkandfixthelayout + } + { + \msg_error:nnx + { mathnotes } + { requires memoir class } + { kindle } + } + } % }}} + +% e.g. `\exp:w \mn__color:n { MNnotetitle }` +\cs_set:Npn \mn__color:n #1 % {{{ + { + \bool_if:NTF \g__mn_xcolor_bool + { + \exp_end: + \color{#1} + } + { + \exp_end: + } + } % }}} + +\bool_if:NT \g__mn_theorems_bool % {{{ mdtheorem setup + { + \RequirePackage[thmmarks, amsmath, amsthm]{ntheorem} + + \RequirePackage{mdframed} + + \mdfdefinestyle { theorem } + { + linewidth = 1.5pt , + } + + \bool_if:NT \g__mn_xcolor_bool + { + \mdfapptodefinestyle { theorem } + { + frametitlefont = \normalfont\bfseries\color{MNthmtitle} , + linecolor = MNthmline , + backgroundcolor = MNthmbg , + } + } + + \mdfdefinestyle { minor-theorem } + { + style = theorem , + linewidth = 0.75pt , + } + + \mdfdefinestyle { example } + { + theoremtitlefont = \normalfont , + } + + \bool_if:NT \g__mn_xcolor_bool + { + \mdfapptodefinestyle { example } + { + frametitlefont = \normalfont\bfseries\color{MNextitle} , + linecolor = MNexline , + backgroundcolor = MNexbg , + } + } + + \mdfdefinestyle { definition } + { + } + + \bool_if:NT \g__mn_xcolor_bool + { + \mdfapptodefinestyle { definition } + { + frametitlefont = \normalfont\bfseries\color{MNdefntitle} , + linecolor = MNdefnline , + backgroundcolor = MNdefnbg , + } + } + + \mdfdefinestyle { note } + { + topline = false , + rightline = false , + bottomline = false , + linewidth = 2pt , + } + + \bool_if:NT \g__mn_xcolor_bool + { + \mdfapptodefinestyle { note } + { + frametitlefont = \normalfont\bfseries\color{MNnotetitle} , + linecolor = MNnoteline , + backgroundcolor = MNnotebg , + } + } + + \mdfdefinestyle { example } + { + theoremtitlefont = \normalfont , + } + + \bool_if:NT \g__mn_xcolor_bool + { + \mdfapptodefinestyle { example } + { + frametitlefont = \normalfont\bfseries\color{MNextitle} , + linecolor = MNexline , + backgroundcolor = MNexbg , + } + } + + \mdtheorem + [ style = theorem ] + { thm } + { Theorem } + % \newtheorem{shortthm}[thm]{Theorem} + \mdtheorem + [ style = minor-theorem ] + { lem } + { Lemma } + \mdtheorem + [ style = minor-theorem ] + { cor } + { Corollary } + \mdtheorem + [ style = minor-theorem ] + { prop } + { Proposition } + + % \theoremstyle{definition} + \mdtheorem + [ style = definition ] + { defn } + { Definition } + \mdtheorem + [ style = definition ] + { notation } + { Notation } + + % \theoremstyle{remark} + \mdtheorem + [ style = example ] + { ex } + { Example } + + \skip_new:N \mn__note_title_after_skip + \skip_set:Nn \mn__note_title_after_skip { 1em plus 0.25em minus 0.75em } + \cs_set:Npn \mn__note_title:n #1 + { + \textbf + { + \exp:w \mn__color:n { MNnotetitle } + #1 + } + \skip_horizontal:N \mn__note_title_after_skip + } + + \newmdenv + [ + style = note , + startinnercode = \mn__note_title:n { Note: } , + ] + { note } + + \newmdenv + [ + style = note , + startinnercode = \mn__note_title:n { Remark: } , + ] + { remark } + + \newmdenv + [ + style = note , + startinnercode = \mn__note_title:n { Hint: } , + ] + { hint } + + \newmdenv + [ + style = note , + startinnercode = \mn__note_title:n { Abuse of notation: } , + ] + { abuse-of-notation } + + % % reset for future defn.s + % \theoremstyle{plain} + } % }}} + +\NewDocumentCommand \TODO { o } % {{{ + { + \framebox + { + \textbf{ TODO \IfValueT { #1 } { :~} } + \IfValueT { #1 } { #1 } + } + } % }}} + +% \bool_if:NT \g__mn_titles_bool % {{{ + % { + % \RequirePackage{titlesec} + % % \titleformat { \command } [ shape ] { format } { label } { sep } { before-code } [ after-code ] + % % before-code can be a command + % \titleformat { \chapter } + % [ block ] + % { \bfseries \HUGE } + % { { \exp:w \mn__color:n {MNsecnum} \thechapter} } + % { 20pt } + % { } + % [ ] + + % \titleformat { \section } + % [ hang ] + % { \bfseries \LARGE } + % { { \exp:w \mn__color:n {MNsecnum} \thesection} } + % { 16pt } + % { } + % [ ] + + % \titleformat { \subsection } + % [ hang ] + % { \bfseries \Large } + % { { \exp:w \mn__color:n {MNsecnum} \thesubsection} } + % { 16pt } + % { } + % [ ] + + % % \titlespacing* { \command } { left } { before } { after } [ right ] + % \titlespacing* { \chapter } { 0em } { 0em } { 2em } [ 0em ] + % \titlespacing* { \section } { 0em } { 2em } { 0.5em } [ 0em ] + % \titlespacing* { \subsection } { 0em } { 1em } { 0em } [ 0em ] + % \titlespacing* { \subsubsection } { 0em } { 1em } { 0em } [ 0em ] + % } % }}} + +\bool_if:NT \g__mn_xcolor_bool % {{{ + { + \RequirePackage[hidelinks]{hyperref} + \hypersetup + { + colorlinks = true , + allcolors = MNlink , + } + } % }}} + +\bool_if:NT \g__mn_index_bool + { + \bool_set_true:N \g__mn_knowledge_bool + } + +\bool_if:NTF \g__mn_knowledge_bool % {{{ + { + \bool_if:NT \g__mn_xcolor_bool + { + \PassOptionsToPackage{xcolor}{knowledge} + \providecolorset { HTML } + % Prefix/postfix of all color names + { } { } + { + \use_none:n + ; MNunknown , DE0B0F + ; MNunknowncont , AD483E + ; MNintro , 051338 + } + } + \RequirePackage[quotation, notion, makeidx]{knowledge} + + % Disable the redefined \label command; this fixes some documents. + \KnowledgeConfigureBooleanOption[\knowledge_configuration_label_autoscope_bool]{patch~label} + + % {{{ Patch in the automatic-AP feature + \bool_new:N \g__mn_noAP_bool + \NewDocumentCommand \noAP { } + { \bool_gset_true:N \g__mn_noAP_bool } + \cs_set:Npn \mn__maybe_AP:N #1 + { + \bool_if:NTF \g__mn_noAP_bool + { \bool_gset_false:N \g__mn_noAP_bool } + { #1 } + } + + \RequirePackage{etoolbox} + \pretocmd { \intro } + { \mn__maybe_AP:N \AP } + { } { } + + \bool_new:N \l__mn_using_itemAP + \cs_set:Npn \mn__use_itemAP: + { + \bool_if:NF \l__mn_using_itemAP + { + \let \mn__item_orig: \item + \bool_set_true:N \l__mn_using_itemAP + \RenewDocumentCommand \item { o } + { + \IfNoValueTF { ##1 } + { + \mn__item_orig: + \mn__maybe_AP:N \AP + } + { + \mn__item_orig: + [ + \mn__maybe_AP:N \knowledge_itemAP: + % NOTE: this isn't expandable, which fucks up + % everything. + \cs_set_eq:NN \AP \prg_do_nothing: + ##1 + ] + } + } + } + } + \apptocmd { \enumerate } { \mn__use_itemAP: } { } { } + \apptocmd { \itemize } { \mn__use_itemAP: } { } { } + \apptocmd { \description } { \mn__use_itemAP: } { } { } + % }}} + + % {{{ Make some better styles. + \knowledgeconfigure + { + visible~anchor~points = false + } + \cs_set:Npn \mn__knowledgestyles:nn #1#2 + { + \clist_map_inline:nn { #1 } + { \knowledgestyle* { ##1 } { #2 } } + } + % List of default styles + % notion, intro notion + % intro, intro unknown, intro unknown cont + % kl unknown, kl unknown cont + \bool_if:NTF \g__mn_xcolor_bool + { + \mn__knowledgestyles:nn + { notion , intro~notion } + { + color = MNlink , + } + \mn__knowledgestyles:nn + { intro , intro~notion , intro~unknown, intro~unknown~cont , } + { + boldface , + color = MNintro , + } + \mn__knowledgestyles:nn + { intro~unknown , intro~unknown~cont , kl~unknown , kl~unknown~cont , } + { + underline = false , + color = MNunknown , + } + \mn__knowledgestyles:nn + { intro~unknown~cont , kl~unknown~cont , } + { + color = MNunknowncont , + } + } + { + % These blank definitions are important for erasing some very poorly + % typeset decisions. + \mn__knowledgestyles:nn + { notion , intro~notion } + { + } + \mn__knowledgestyles:nn + { intro , intro~notion , intro~unknown, intro~unknown~cont , } + { + boldface , + } + \mn__knowledgestyles:nn + { intro~unknown , intro~unknown~cont , kl~unknown , kl~unknown~cont , } + { + } + \mn__knowledgestyles:nn + { intro~unknown~cont , kl~unknown~cont , } + { + } + } + % }}} + } + { + % If we don't load the knowledge package, provide a *similar* interface + % to make writing commands that *optionally* use the knowledge interface + % easier. + \ProvideDocumentCommand \itemAP { O{} } { \item[#1] } + \ProvideDocumentCommand \AP { } { } + \ProvideDocumentCommand \phantomintro { d() m } { } + \ProvideDocumentCommand \nointro { m } { } + \ProvideDocumentCommand \reintro { s o m } { #3 } + \ProvideDocumentCommand \intro { d() o d() m } { #4 } + \ProvideDocumentCommand \kl { d() o d() m } { #4 } + } % }}} + +\bool_if:NT \g__mn_index_bool + { + \makeindex + } + +% The \emailstyle command gives the style of an email; by default, we +% initialize it to \texttt. +\ProvideDocumentCommand \emailstyle { m } { \texttt{#1} } +% The \email command typesets an email; if the user has loaded the +% hyperref package, we can add a link as well. +\mn__if_package_loaded:nTF { hyperref } % {{{ + { + \ProvideDocumentCommand \email { m } + { \href{mailto:#1}{\emailstyle{#1}} } + } + { + \ProvideDocumentCommand \email { m } + { \emailstyle{#1} } + } % }}} + +\bool_if:NT \g__mn_tabu_bool % {{{ + { + \RequirePackage{multirow} + \RequirePackage{booktabs} + \RequirePackage{longtable} + \RequirePackage{tabu} + \ProvideExpandableDocumentCommand \Th { O{l} m } + { + \multicolumn + { 1 } % For 1 column... + { #1 } % ...with column-spec #1... + { \textbf{#2} } % Typeset #2 in bold. + } + } % }}} + +\bool_if:NT \g__mn_figures_bool % {{{ + { + % figure captions + \RequirePackage{graphicx} + \RequirePackage{caption} + \captionsetup + { + format = hang, + font = { sf, footnotesize }, + margin = 1in + } + } % }}} + +% {{{ Footnotes +\bool_if:NT \g__mn_footnotes_bool + { + \PassOptionsToPackage{bottom, hang}{footmisc} + \RequirePackage{footmisc} + } +\setlength { \footnotesep } { \baselineskip } +% }}} + +% Document style. +\setlength { \parindent } { 0em } +\setlength { \parskip } { 1em } +% {{{ Set \parskip=0 around \tableofcontents +\RequirePackage{etoolbox} +\pretocmd { \tableofcontents } + { + \group_begin: + \setlength{\parskip}{0pt} + } + { } { } +\apptocmd { \tableofcontents } + { \group_end: } + { } { } +% }}} + +% This has to be hooked so that it doesn't break the other bools undefined +% with it first. +\AtEndOfPackage { \cs_undefine:N \mn__legacy_bool_undefine:n } diff --git a/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.tex b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.tex new file mode 100644 index 0000000000..59550cc105 --- /dev/null +++ b/macros/latex/contrib/rbt-mathnotes/rbt-mathnotes.tex @@ -0,0 +1,475 @@ +%% rbt-mathnotes.tex +%% Copyright 2021 Rebecca B. Turner. +% +% This work may be distributed and/or modified under the +% conditions of the LaTeX Project Public License, either version 1.3 +% of this license or (at your option) any later version. +% The latest version of this license is in +% http://www.latex-project.org/lppl.txt +% and version 1.3 or later is part of all distributions of LaTeX +% version 2005/12/01 or later. +% +% This work has the LPPL maintenance status `maintained'. +% +% The Current Maintainer of this work is Rebecca B. Turner. +% +% This work consists of the files: +% README.md +% rbt-mathnotes.tex +% rbt-mathnotes.sty +% rbt-mathnotes.cls +% rbt-mathnotes-util.sty +% rbt-mathnotes-messages.sty +% rbt-mathnotes-hw.cls +% rbt-mathnotes-formula-sheet.cls +% examples/cheat-sheet.tex +% examples/multivar.tex +% examples/topology-hw-1.tex +% and the derived files: +% rbt-mathnotes.pdf +% examples/cheat-sheet.pdf +% examples/multivar.pdf +% examples/topology-hw-1.pdf + +\documentclass{ltxguidex} + +\errorcontextlines=10 +\usepackage{longtable} +\usepackage{changepage} +\usepackage{metalogo} +\usepackage{changelog} +\newcommand{\mn}{\ctan{rbt-mathnotes}} + +\makeatletter +\renewcommand{\SX@explpreset}{ + language=[LaTeX]TeX, + numbers=none, +} +\makeatother + +%\setmainfont{Charter} +\lstset{basewidth=0.6em} + +\usepackage[ + nomaketitle, + notitles, + noxcolor, + noenumitem, + notheorems, +]{rbt-mathnotes} + +\usepackage{FiraSans} +\usepackage{FiraMono} + +\NewDocumentEnvironment{ctandescription}{} + {\NewDocumentCommand{\pkg}{m}{\item[\ctan{##1}]} + \begin{description}} + {\end{description}} + +\author{Rebecca Turner\thanks{\email{rbt@sent.as}, \https{becca.ooo}}} +\title{The \mn\ Package} +\date{1.0.2 2021/11/29} +\begin{document} +\maketitle + +\begin{abstract} + Rebecca Turner's personal macros and styles for typesetting mathematics + notes. +\end{abstract} + +\begin{note} + Browse the sources, contribute, or complain at \\ + \https{github.com/9999years/latex-mathnotes} +\end{note} + +\tableofcontents +\vfill +\pagebreak + +\begin{note} + Copyright 2021 Rebecca B. Turner. + + This work may be distributed and/or modified under the + conditions of the LaTeX Project Public License, either version 1.3 + of this license or (at your option) any later version. + The latest version of this license is in + \https{www.latex-project.org/lppl.txt} + and version 1.3 or later is part of all distributions of LaTeX + version 2005/12/01 or later. + + This work has the LPPL maintenance status `maintained'. + + The Current Maintainer of this work is Rebecca B. Turner. + + This work consists of the files: + \begin{itemize} + \item \texttt{README.md} + \item \texttt{rbt-mathnotes.tex} + \item \texttt{rbt-mathnotes.sty} + \item \texttt{rbt-mathnotes.cls} + \item \texttt{rbt-mathnotes-util.sty} + \item \texttt{rbt-mathnotes-messages.sty} + \item \texttt{rbt-mathnotes-hw.cls} + \item \texttt{rbt-mathnotes-formula-sheet.cls} + \item \texttt{examples/cheat-sheet.tex} + \item \texttt{examples/multivar.tex} + \item \texttt{examples/topology-hw-1.tex} + \end{itemize} + and the derived files: + \begin{itemize} + \item \texttt{rbt-mathnotes.pdf} + \item \texttt{examples/cheat-sheet.pdf} + \item \texttt{examples/multivar.pdf} + \item \texttt{examples/topology-hw-1.pdf} + \end{itemize} +\end{note} + +\vfill +\pagebreak + +\section{Package options} + +Some options are enabled by default, and can be disabled by passing +|no