diff options
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/skmath/README | 12 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/skmath/skmath.pdf | bin | 241635 -> 259421 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/skmath/skmath.tex | 311 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/skmath/skmath.sty | 124 |
4 files changed, 339 insertions, 108 deletions
diff --git a/Master/texmf-dist/doc/latex/skmath/README b/Master/texmf-dist/doc/latex/skmath/README index 920945181b7..a0f89abfc59 100644 --- a/Master/texmf-dist/doc/latex/skmath/README +++ b/Master/texmf-dist/doc/latex/skmath/README @@ -1,7 +1,7 @@ %% skmath improved math commands %% -%% Copyright (C) 2012-2014 by Simon Sigurdhsson <sigurdhsson@gmail.com> -%% +%% Copyright (C) 2012-2015 by Simon Sigurdhsson <sigurdhsson@gmail.com> +%% %% 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. @@ -9,15 +9,15 @@ %% 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 Simon Sigurdhsson. -%% +%% %% This work consists of the file skmath.tex %% and the derived file skmath.sty. -This is version 0.3a of the skmath package, a package which provides +This is version 0.4 of the skmath package, a package which provides improved and new math commands for superior typesetting with lower effort. The following files are enclosed. diff --git a/Master/texmf-dist/doc/latex/skmath/skmath.pdf b/Master/texmf-dist/doc/latex/skmath/skmath.pdf Binary files differindex 41448a69045..fccf58fc313 100644 --- a/Master/texmf-dist/doc/latex/skmath/skmath.pdf +++ b/Master/texmf-dist/doc/latex/skmath/skmath.pdf diff --git a/Master/texmf-dist/source/latex/skmath/skmath.tex b/Master/texmf-dist/source/latex/skmath/skmath.tex index 2362e57e8a1..a63f070a2ca 100644 --- a/Master/texmf-dist/source/latex/skmath/skmath.tex +++ b/Master/texmf-dist/source/latex/skmath/skmath.tex @@ -1,7 +1,7 @@ %% skmath improved math commands %% -%% Copyright (C) 2012-2014 by Simon Sigurdhsson <sigurdhsson@gmail.com> -%% +%% Copyright (C) 2012-2015 by Simon Sigurdhsson <sigurdhsson@gmail.com> +%% %% 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. @@ -9,35 +9,37 @@ %% 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 Simon Sigurdhsson. -%% +%% %% This work consists of the file skmath.tex %% and the derived file skmath.sty. \PassOptionsToPackage{intlimits,sumlimits,namelimits}{amsmath} \documentclass[commonsets,load]{skdoc} \usepackage{amsmath} \usepackage{csquotes} -\ProvideDocumentCommand\d{m}{#1} -\ProvideDocumentCommand\pd{smm}{#2#3} -\ProvideDocumentCommand\abs{m}{#1} -\ProvideDocumentCommand\norm{m}{#1} -\ProvideDocumentCommand\abs{m}{#1} +\ProvideDocumentCommand\d{m}{#1} +\ProvideDocumentCommand\pd{smm}{#2#3} +\ProvideDocumentCommand\abs{m}{#1} +\ProvideDocumentCommand\norm{m}{#1} +\ProvideDocumentCommand\abs{m}{#1} \ProvideDocumentCommand\P{m}{#1} -\ProvideDocumentCommand\given{}{} -\ProvideDocumentCommand\E{m}{#1} -\ProvideDocumentCommand\var{m}{#1} -\ProvideDocumentCommand\cov{mm}{#1#2} -\ProvideDocumentCommand\N{}{} -\ProvideDocumentCommand\Z{}{} -\ProvideDocumentCommand\Q{}{} -\ProvideDocumentCommand\R{}{} -\ProvideDocumentCommand\C{}{} -\ProvideDocumentCommand\sfrac{mm}{#1#2} -\ProvideDocumentCommand\argmin{om}{#1} -\ProvideDocumentCommand\argmax{om}{#1} +\ProvideDocumentCommand\given{}{} +\ProvideDocumentCommand\E{m}{#1} +\ProvideDocumentCommand\var{m}{#1} +\ProvideDocumentCommand\cov{mm}{#1#2} +\ProvideDocumentCommand\N{}{} +\ProvideDocumentCommand\Z{}{} +\ProvideDocumentCommand\Q{}{} +\ProvideDocumentCommand\R{}{} +\ProvideDocumentCommand\C{}{} +\ProvideDocumentCommand\ii{}{i} +\ProvideDocumentCommand\jj{}{j} +\ProvideDocumentCommand\sfrac{mm}{#1#2} +\ProvideDocumentCommand\argmin{om}{#1} +\ProvideDocumentCommand\argmax{om}{#1} % Declare the target files \SelfPreambleTo{\mypreamble} @@ -54,7 +56,7 @@ % This is where the documentation begins \begin{document} % Change & version info - \version{0.3b} + \version{0.4} \changes{0.1}{Initial version} \changes{0.1c}{Moved package from \pkg{docstrip} to \pkg{skdoc}} \changes{0.1d}{Fixed fatal documentation and package errors} @@ -64,6 +66,7 @@ \changes{0.3}{Added \cs{min}/\cs{max} and friends. Added \cs{pd}} \changes{0.3a}{Added \cs{sinh}, \cs{cosh} and \cs{tanh}} \changes{0.3b}{Detect empty arguments in trigonometric and logarithmic functions, fix \cs{ln}} + \changes{0.4}{Added \opt{notation} option, macros for complex numbers} % Don't forget to update the version number and release date of % the package declaration in the implementation! @@ -89,20 +92,26 @@ \section{Usage} \subsection{Options} - As of version \theversion, there is only one option: \opt{commonsets}. - By default, it is disabled but if the option is given the package will - define \cs{N}, \cs{Z}, \cs{Q}, \cs{R} and \cs{C} as blackboard + As of version \theversion, the package provides two key-value options. + + \Option{commonsets}\WithValues{true,false}\AndDefault{false} + Optionally define \cs{N}, \cs{Z}, \cs{Q}, \cs{R} and \cs{C} as blackboard variants of the respective letters, to represent the common sets of numbers. + \Option{notation}\WithValues{iso,english,german,legacy}\AndDefault{legacy} + This option controls the style of a few typographic elements that differ + between countries and standards (such as the style of integrals, derivatives + and greek letters). + \subsection{New commands} The package defines a number of new commands that aid in typesetting certain mathematical formulae. - - \DescribeMacro\N - \DescribeMacro\Z - \DescribeMacro\Q - \DescribeMacro\R + + \DescribeMacro\N + \DescribeMacro\Z + \DescribeMacro\Q + \DescribeMacro\R \DescribeMacro\C These commands are only available if the \opt{commonsets} option is given. They typeset the set of natural, integer, rational, @@ -112,13 +121,20 @@ \N, \Z, \Q, \R, \C. \end{equation*} \end{example} - + + \DescribeMacro\ii + \DescribeMacro\jj + These commands typeset the imaginary unit (either \(\ii\) as used in + mathematics or \(\jj\) as used in electrotechnology). While normal use + of the package simply results in italic characters, setting the \opt{notation} + option to \texttt{iso} will set these upright. + \DescribeMacro\norm{<expression>} \DescribeMacro\abs{<expression>} The commands \Macro\norm and \Macro\abs, quite expectedly, typeset the norm ans absolute value of an expression, respectively. They have one mandatory argument (the expression), and different norms - can be achieved by appending a subscript after the argument of + can be achieved by appending a subscript after the argument of \Macro\norm. \begin{example} \begin{equation*} @@ -127,9 +143,9 @@ ^{\sfrac{1}{p}} \end{equation*} \end{example} - + \DescribeMacro\d{<variable>} - There is also a command \Macro\d, with one mandatory argument, that + There is also a command \Macro\d, with one mandatory argument, that typesets the differential part of an integral. \begin{example} \begin{equation*} @@ -160,14 +176,14 @@ \end{example} \DescribeMacro\P{<expression>\AlsoMacro\given <expression>} - The \Macro\P command typesets a probability. The \Macro\given command + The \Macro\P command typesets a probability. The \Macro\given command can be used to typeset conditional probabilities, within \Macro\P. \begin{example} \begin{equation*} \P{A\given B} = \frac{\P{B\given A}\P{A}}{\P{B}} \end{equation*} -\end{example} +\end{example} \DescribeMacro\var{<expression>} \DescribeMacro\cov{<expression>}{<expression>} @@ -179,39 +195,39 @@ \cov{X}{Y} = \E{XY}-\E{X}\E{Y} \end{gather*} \end{example} - + \subsection{Improved commands} In addition to adding new commands, this package also redefines already existing commands in a mostly backwards-compatible way to improve their usefulness. - - \DescribeMacro\sin[<power>]{<expression>} - \DescribeMacro\arcsin{<expression>} - \DescribeMacro\cos[<power>]{<expression>} - \DescribeMacro\arccos{<expression>} - \DescribeMacro\tan[<power>]{<expression>} - \DescribeMacro\arctan{<expression>} - \DescribeMacro\cot[<power>]{<expression>} - \DescribeMacro\sinh[<power>]{<expression>} - \DescribeMacro\cosh[<power>]{<expression>} - \DescribeMacro\tanh[<power>]{<expression>} + + \DescribeMacro\sin[<power>]{<expression>} + \DescribeMacro\arcsin{<expression>} + \DescribeMacro\cos[<power>]{<expression>} + \DescribeMacro\arccos{<expression>} + \DescribeMacro\tan[<power>]{<expression>} + \DescribeMacro\arctan{<expression>} + \DescribeMacro\cot[<power>]{<expression>} + \DescribeMacro\sinh[<power>]{<expression>} + \DescribeMacro\cosh[<power>]{<expression>} + \DescribeMacro\tanh[<power>]{<expression>} The trigonometric functions have been redefined to typeset more easily. They typeset \meta{expression} as an argument of the expression, and (if applicable) \meta{power} as a superscript between the function and its argument, \emph{e.g.} \(\sin[2]{\phi}\). When the argument is empty, no parentheses are emitted: \(\cos{}\). - + \DescribeMacro\ln{<expression>} - The natural logarithm macro \Macro\ln has also been redefined to + The natural logarithm macro \Macro\ln has also been redefined to require an argument which is typeset as the argument of the logarithm. \DescribeMacro\log[<base>]{<expression>} - The related macro \Macro\log is redefined in a similar way, but also + The related macro \Macro\log is redefined in a similar way, but also accepts an optional argument denoting the base of the logarithm: \(\log[2]{x}\). As with the trigonometric functions, no parentheses are emitted if the mandatory argument is empty: \(\log{}\). - + \DescribeMacro\exp*{<expression>} The exponential, \Macro\exp, is redefined to typeset its argument as a superscript of \(e\) in some display styles, and as an argument of @@ -242,18 +258,25 @@ \subsection{Stylistic changes} Some commands have been redefined in a completely backwards-compatible way to improve the end result of their typesetting. - + \DescribeMacro\frac{<numerator>}{<denominator>} The \Macro\frac command has been changed to improve typesetting, allowing displaystyle math in some settings. - + \DescribeMacro\bar{<expression>} \DescribeMacro\vec{<expression>} - The \Macro\bar command has been changed to cover the entire + The \Macro\bar command has been changed to cover the entire \meta{expression} (\emph{i.e.} \(\bar{uv}\)), and \Macro\vec has - been changed to match the \cs{vectorsym} command provided by + been changed to match the \cs{vectorsym} command provided by \pkg{isomath}. + \DescribeMacro\Re{<expression>} + \DescribeMacro\Im{<expression>} + These commands typeset the real and imaginary part of a number. Standard use + of the package takes definitions roughly from \pkg{amsmath}, while setting + the \opt{notation} option to \texttt{iso} changes the definitions to match + ISO~80000-2. + \section{Known issues} A list of current issues is available in the Github repository of this package\footnote{\url{https://github.com/urdh/skmath/issues}}, but as @@ -278,12 +301,109 @@ \begin{MacroCode}{package} \RequirePackage{expl3,l3keys2e,xparse} \ProvidesExplPackage{skmath} - {2014/06/13}{0.3b}{improved math commands} + {2015/01/05}{0.4}{improved math commands} \PassOptionsToPackage{intlimits,sumlimits,namelimits}{amsmath} -\RequirePackage{amssymb,mathtools,xfrac,isomath} +\RequirePackage{amssymb,mathtools,xfrac} +\end{MacroCode} + +We start by declaring internal options related to the notation styles. +First, some placeholders to detect failures. +\begin{MacroCode}{package} +\msg_new:nnnn{skmath}{undefined-macro}{The~macro~`\token_to_str:N#1'~was~undefined!} + {This~is~an~error~in~the~notation~option~handling.~Please~file~an~issue\\ + on~Github~(https://github.com/urdh/skmath/issues)~with~a~copy~of~this\\ + message~attached~as~well~as~a~list~of~the~options~passed~to~`skmath'.} +\cs_gset_nopar:Npn\__skmath_integral_d:{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_integral_d:} +} +\cs_gset_nopar:Npn\__skmath_natural_log_e:{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_natural_log_e:} +} +\cs_gset_nopar:Npn\__skmath_imaginary_unit:n#1{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_imaginary_unit:n} +} +\end{MacroCode} +Then, the key-value options. +\begin{MacroCode}{package} +\keys_define:nn{skmath / internal}{ + % More on this: + % * http://en.wikipedia.org/wiki/Typographical_conventions_in_mathematical_formulae + % * ISO 80000-2 + % * http://www.tug.org/TUGboat/Articles/tb18-1/tb54becc.pdf + % * http://tex.stackexchange.com/q/14821/66 + integral-d .choice:, + integral-d .value_required:, + integral-d / upright .code:n = { \cs_gset_nopar:Npn\__skmath_integral_d:{{\operator@font d}} }, + integral-d / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_integral_d:{{d}} }, + isomath .bool_set:N = \g__skmath_load_isomath_bool, + isomath .value_required:, + natural-log .choice:, + natural-log .value_required:, + natural-log / upright .code:n = { \cs_gset_nopar:Npn\__skmath_natural_log_e:{{\operator@font e}} }, + natural-log / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_natural_log_e:{{e}} }, + imaginary-unit .choice:, + imaginary-unit .value_required:, + imaginary-unit / upright .code:n = { \cs_gset_nopar:Npn\__skmath_imaginary_unit:n##1{{\operator@font ##1}} }, + imaginary-unit / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_imaginary_unit:n##1{{##1}} }, + complex-part-symbols .bool_set_inverse:N = \g__skmath_iso_complex_parts_bool, + complex-part-symbols .value_required:, +} \end{MacroCode} - First, a utility conditional. +We also declare the \enquote{public} options. +\begin{MacroCode}{package} +\keys_define:nn{skmath}{ + commonsets .bool_set:N = \g__skmath_define_common_sets_bool, + commonsets .default:n = true, + commonsets .initial:n = false, + % TODO: write tests for the notation option + notation .choice:, + notation / iso .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = upright, + imaginary-unit = upright, + complex-part-symbols = false, + }, + notation / german .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = slanted, %??? + imaginary-unit = slanted, %??? + complex-part-symbols = true, %??? + }, + notation / english .meta:nn = {skmath / internal}{ + integral-d = slanted, + isomath = true, + natural-log = slanted, %??? + imaginary-unit = slanted, %??? + complex-part-symbols = true, %??? + }, + notation / legacy .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = slanted, + imaginary-unit = slanted, + complex-part-symbols = true, + }, + % Possibly more style sets... ? + notation .initial:n = legacy, % Or is it? Perhaps a legacy option is required. + notation .value_required:, + % Note also that the styles should probably affect isomath and/or other packages. +} +\ProcessKeysOptions{skmath} +\end{MacroCode} + +We optionally load \pkg{isomath}, depending on notation style. +\begin{MacroCode}{package} +\bool_if:NTF\g__skmath_load_isomath_bool{ + \RequirePackage{isomath} +}{ + % TODO: check if there is an alternative package we should load here. +} +\end{MacroCode} + + Then, a utility conditional\ldots \begin{macro*}{\__skmath_if_novalue_or_empty:nF}[1] {Token or string} \begin{MacroCode}{package} @@ -301,7 +421,7 @@ \end{MacroCode} \end{macro*} - And a helper macro. + \ldots and a helper macro. \begin{macro*}{\__skmath_parens:n}[1] {Argument to wrap in parentheses, unless empty} \begin{MacroCode}{package} @@ -312,9 +432,8 @@ \end{macro*} We optionally provide commands to typeset common sets. - \begin{macro}{\__skmath_define_common_sets:} \begin{MacroCode}{package} -\cs_new:Nn\__skmath_define_common_sets:{ +\bool_if:NT\g__skmath_define_common_sets_bool{ \end{MacroCode} \begin{macro}{\N} \changes{0.1b}{Moved to \textsf{xparse} command definition} @@ -349,8 +468,39 @@ \begin{MacroCode}{package} } \end{MacroCode} + + Then, macros related to complex numbers are defined. + \begin{macro}{\ii} +\begin{MacroCode}{package} +\DeclareDocumentCommand\ii{}{\ensuremath{\__skmath_imaginary_unit:n{i}}} +\end{MacroCode} + \end{macro} + \begin{macro}{\jj} +\begin{MacroCode}{package} +\DeclareDocumentCommand\jj{}{\ensuremath{\__skmath_imaginary_unit:n{j}}} +\end{MacroCode} + \end{macro} + \begin{macro}{\Re} +\begin{MacroCode}{package} +\bool_if:NTF\g__skmath_iso_complex_parts_bool{ + \cs_new_eq:NN\__skmath_Re:\Re + \DeclareDocumentCommand\Re{m}{\ensuremath{\__skmath_Re:\__skmath_parens:n{#1}}} +}{ + \DeclareDocumentCommand\Re{m}{\ensuremath{{\operator@font Re}{#1}}} +} +\end{MacroCode} + \end{macro} + \begin{macro}{\Im} +\begin{MacroCode}{package} +\bool_if:NTF\g__skmath_iso_complex_parts_bool{ + \cs_new_eq:NN\__skmath_Im:\Im + \DeclareDocumentCommand\Im{m}{\ensuremath{\__skmath_Im:\__skmath_parens:n{#1}}} +}{ + \DeclareDocumentCommand\Im{m}{\ensuremath{{\operator@font Im}{#1}}} +} +\end{MacroCode} \end{macro} - + This is followed by commands to typeset the norm and absolute value. \begin{macro}{\abs} \begin{MacroCode}{package} @@ -407,21 +557,21 @@ \changes{0.1e}{Added \cs{var} command} \changes{0.2}{Use \cs{operatorname}} \begin{MacroCode}{package} - \DeclareDocumentCommand\var{m}{% - \ensuremath{\operatorname{Var}\left(#1\right)}% - } +\DeclareDocumentCommand\var{m}{% + \ensuremath{\operatorname{Var}\left(#1\right)}% +} \end{MacroCode} \end{macro} \begin{macro}{\cov} \changes{0.1e}{Added \cs{cov} command} \changes{0.2}{Use \cs{operatorname}} \begin{MacroCode}{package} - \DeclareDocumentCommand\cov{mm}{% - \ensuremath{\operatorname{Cov}\left(#1,#2\right)}% - } +\DeclareDocumentCommand\cov{mm}{% + \ensuremath{\operatorname{Cov}\left(#1,#2\right)}% +} \end{MacroCode} \end{macro} - + We replace all trigonometric functions and some other common functions with alternatives that take an argument (or optionally, several arguments). @@ -553,7 +703,7 @@ \__skmath_exp:\__skmath_parens:n{#2} }{ \mathchoice - {e\c_math_superscript_token{#2}} + {\__skmath_natural_log_e:\c_math_superscript_token{#2}} {\__skmath_exp:\left(#2\right)} {\__skmath_exp:\left(#2\right)} {\__skmath_exp:\left(#2\right)} @@ -625,7 +775,7 @@ {\displaystyle #1}{\displaystyle #2}} \end{MacroCode} \end{macro} - + We introduce a couple of helper macros for the \cs{pd} macro backend. \begin{macro*}{\__skmath_if_numerical_p:n} \begin{macro*}{\__skmath_if_numerical:nT} @@ -796,7 +946,7 @@ {Comma-separated list of variables, possibly with superscripts} \begin{MacroCode}{package} \DeclareDocumentCommand\pd{smm}{ - \ensuremath{ + \ensuremath{ \IfBooleanTF{#1} {\__skmath_pd_subscript:nn{#2}{#3}} {\__skmath_pd_fraction:nn{#2}{#3}} @@ -813,14 +963,14 @@ \changes{0.2}{Use \cs{peek_meaning_ignore_spaces:NT} instead of \cs{@ifnextchar}} \changes{0.3b}{Use \cs{operator@font} instead of \cs{mathrm}} \begin{MacroCode}{package} -\DeclareDocumentCommand\d{m}{\ensuremath{\,{\operator@font d}#1% +\DeclareDocumentCommand\d{m}{\ensuremath{\,\__skmath_integral_d: #1% \peek_meaning_ignore_spaces:NT\d{\!}}} \end{MacroCode} \end{macro} \begin{MacroCode}{package} } \end{MacroCode} - + Finally, we define a nicer way to denote vectors. \begin{macro}{\vec} \changes{0.2}{Use \cs{cs_new_eq:NN} instead of \cs{let}} @@ -829,15 +979,6 @@ \end{MacroCode} \end{macro} - We end by declaring an option. -\begin{MacroCode}{package} -\keys_define:nn{skmath}{ - commonsets .code:n = - {\__skmath_define_common_sets:} -} -\ProcessKeysOptions{skmath} -\end{MacroCode} - \begin{MacroCode}{package} \endinput \end{MacroCode} diff --git a/Master/texmf-dist/tex/latex/skmath/skmath.sty b/Master/texmf-dist/tex/latex/skmath/skmath.sty index c833b397a3f..8ace6a186b0 100644 --- a/Master/texmf-dist/tex/latex/skmath/skmath.sty +++ b/Master/texmf-dist/tex/latex/skmath/skmath.sty @@ -1,7 +1,7 @@ %% This is file `skmath.sty', generated from `skmath.tex' (key `package'). %% skmath improved math commands %% -%% Copyright (C) 2012-2014 by Simon Sigurdhsson <sigurdhsson@gmail.com> +%% Copyright (C) 2012-2015 by Simon Sigurdhsson <sigurdhsson@gmail.com> %% %% This work may be distributed and/or modified under the %% conditions of the LaTeX Project Public License, either version 1.3 @@ -20,9 +20,90 @@ \RequirePackage{expl3,l3keys2e,xparse} \ProvidesExplPackage{skmath} - {2014/06/13}{0.3b}{improved math commands} + {2015/01/05}{0.4}{improved math commands} \PassOptionsToPackage{intlimits,sumlimits,namelimits}{amsmath} -\RequirePackage{amssymb,mathtools,xfrac,isomath} +\RequirePackage{amssymb,mathtools,xfrac} +\msg_new:nnnn{skmath}{undefined-macro}{The~macro~`\token_to_str:N#1'~was~undefined!} + {This~is~an~error~in~the~notation~option~handling.~Please~file~an~issue\\ + on~Github~(https://github.com/urdh/skmath/issues)~with~a~copy~of~this\\ + message~attached~as~well~as~a~list~of~the~options~passed~to~`skmath'.} +\cs_gset_nopar:Npn\__skmath_integral_d:{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_integral_d:} +} +\cs_gset_nopar:Npn\__skmath_natural_log_e:{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_natural_log_e:} +} +\cs_gset_nopar:Npn\__skmath_imaginary_unit:n#1{ + \msg_critical:nnn{skmath}{undefined-macro}{\__skmath_imaginary_unit:n} +} +\keys_define:nn{skmath / internal}{ + % More on this: + % * http://en.wikipedia.org/wiki/Typographical_conventions_in_mathematical_formulae + % * ISO 80000-2 + % * http://www.tug.org/TUGboat/Articles/tb18-1/tb54becc.pdf + % * http://tex.stackexchange.com/q/14821/66 + integral-d .choice:, + integral-d .value_required:, + integral-d / upright .code:n = { \cs_gset_nopar:Npn\__skmath_integral_d:{{\operator@font d}} }, + integral-d / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_integral_d:{{d}} }, + isomath .bool_set:N = \g__skmath_load_isomath_bool, + isomath .value_required:, + natural-log .choice:, + natural-log .value_required:, + natural-log / upright .code:n = { \cs_gset_nopar:Npn\__skmath_natural_log_e:{{\operator@font e}} }, + natural-log / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_natural_log_e:{{e}} }, + imaginary-unit .choice:, + imaginary-unit .value_required:, + imaginary-unit / upright .code:n = { \cs_gset_nopar:Npn\__skmath_imaginary_unit:n##1{{\operator@font ##1}} }, + imaginary-unit / slanted .code:n = { \cs_gset_nopar:Npn\__skmath_imaginary_unit:n##1{{##1}} }, + complex-part-symbols .bool_set_inverse:N = \g__skmath_iso_complex_parts_bool, + complex-part-symbols .value_required:, +} +\keys_define:nn{skmath}{ + commonsets .bool_set:N = \g__skmath_define_common_sets_bool, + commonsets .default:n = true, + commonsets .initial:n = false, + % TODO: write tests for the notation option + notation .choice:, + notation / iso .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = upright, + imaginary-unit = upright, + complex-part-symbols = false, + }, + notation / german .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = slanted, %??? + imaginary-unit = slanted, %??? + complex-part-symbols = true, %??? + }, + notation / english .meta:nn = {skmath / internal}{ + integral-d = slanted, + isomath = true, + natural-log = slanted, %??? + imaginary-unit = slanted, %??? + complex-part-symbols = true, %??? + }, + notation / legacy .meta:nn = {skmath / internal}{ + integral-d = upright, + isomath = true, + natural-log = slanted, + imaginary-unit = slanted, + complex-part-symbols = true, + }, + % Possibly more style sets... ? + notation .initial:n = legacy, % Or is it? Perhaps a legacy option is required. + notation .value_required:, + % Note also that the styles should probably affect isomath and/or other packages. +} +\ProcessKeysOptions{skmath} +\bool_if:NTF\g__skmath_load_isomath_bool{ + \RequirePackage{isomath} +}{ + % TODO: check if there is an alternative package we should load here. +} \prg_new_conditional:Npnn\__skmath_if_novalue_or_empty:n#1{F}{ \IfNoValueTF{#1}{ \prg_return_true: @@ -37,13 +118,27 @@ \cs_new_nopar:Npn\__skmath_parens:n#1{ \__skmath_if_novalue_or_empty:nF{#1}{\left(#1\right)} } -\cs_new:Nn\__skmath_define_common_sets:{ +\bool_if:NT\g__skmath_define_common_sets_bool{ \NewDocumentCommand\N{}{\ensuremath{\mathbb{N}}} \NewDocumentCommand\Z{}{\ensuremath{\mathbb{Z}}} \NewDocumentCommand\Q{}{\ensuremath{\mathbb{Q}}} \NewDocumentCommand\R{}{\ensuremath{\mathbb{R}}} \NewDocumentCommand\C{}{\ensuremath{\mathbb{C}}} } +\DeclareDocumentCommand\ii{}{\ensuremath{\__skmath_imaginary_unit:n{i}}} +\DeclareDocumentCommand\jj{}{\ensuremath{\__skmath_imaginary_unit:n{j}}} +\bool_if:NTF\g__skmath_iso_complex_parts_bool{ + \cs_new_eq:NN\__skmath_Re:\Re + \DeclareDocumentCommand\Re{m}{\ensuremath{\__skmath_Re:\__skmath_parens:n{#1}}} +}{ + \DeclareDocumentCommand\Re{m}{\ensuremath{{\operator@font Re}{#1}}} +} +\bool_if:NTF\g__skmath_iso_complex_parts_bool{ + \cs_new_eq:NN\__skmath_Im:\Im + \DeclareDocumentCommand\Im{m}{\ensuremath{\__skmath_Im:\__skmath_parens:n{#1}}} +}{ + \DeclareDocumentCommand\Im{m}{\ensuremath{{\operator@font Im}{#1}}} +} \DeclarePairedDelimiter\abs{\lvert}{\rvert} \DeclarePairedDelimiter\norm{\lVert}{\rVert} \AtBeginDocument{ @@ -61,12 +156,12 @@ \right)% }% } - \DeclareDocumentCommand\var{m}{% - \ensuremath{\operatorname{Var}\left(#1\right)}% - } - \DeclareDocumentCommand\cov{mm}{% - \ensuremath{\operatorname{Cov}\left(#1,#2\right)}% - } +\DeclareDocumentCommand\var{m}{% + \ensuremath{\operatorname{Var}\left(#1\right)}% +} +\DeclareDocumentCommand\cov{mm}{% + \ensuremath{\operatorname{Cov}\left(#1,#2\right)}% +} \cs_new_eq:NN\__skmath_sin:\sin \cs_new_eq:NN\__skmath_cos:\cos \cs_new_eq:NN\__skmath_tan:\tan @@ -141,7 +236,7 @@ \__skmath_exp:\__skmath_parens:n{#2} }{ \mathchoice - {e\c_math_superscript_token{#2}} + {\__skmath_natural_log_e:\c_math_superscript_token{#2}} {\__skmath_exp:\left(#2\right)} {\__skmath_exp:\left(#2\right)} {\__skmath_exp:\left(#2\right)} @@ -282,14 +377,9 @@ {\__skmath_pd_fraction:nn{#2}{#3}} } } -\DeclareDocumentCommand\d{m}{\ensuremath{\,{\operator@font d}#1% +\DeclareDocumentCommand\d{m}{\ensuremath{\,\__skmath_integral_d: #1% \peek_meaning_ignore_spaces:NT\d{\!}}} } \cs_set_eq:NN\vec\vectorsym -\keys_define:nn{skmath}{ - commonsets .code:n = - {\__skmath_define_common_sets:} -} -\ProcessKeysOptions{skmath} \endinput |