latex-packages-build/math/mkessler-mathsymbindex.sty

161 lines
4.9 KiB
Plaintext
Raw Normal View History

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright © 2022 Maximilian Keßler
%
% Permission is hereby granted, free of charge, to any person obtaining a copy
% of this software and associated documentation files (the “Software”), to deal
% in the Software without restriction, including without limitation the rights
% to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
% copies of the Software, and to permit persons to whom the Software is
% furnished to do so, subject to the following conditions:
% The above copyright notice and this permission notice shall be included in all
% copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
% IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
% FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
% AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
% LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
% OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
% SOFTWARE.
%
% This package has been generated by PyTeX, available at
% https://github.com/kesslermaximilian/PyTeX
% and built from source file 'mathsymbindex.pysty3'.
% It is STRONGLY DISCOURAGED to edit this source file directly, since local
% changes will not be versioned by Git and overwritten by the next build. Always
% edit the source file and build the package again.
%
% Build details:
% PyTeX version: v1.2.0-11-gc8deda5 (commit c8deda5)
% Source code version: v2.5.0 (commit 296afc0)
%
% This LaTeX package is free software and distributed under the MIT License. You
% may use it freely for your purposes. The latest version of the package can be
% obtained via GitHub under
% https://github.com/kesslermaximilian/LatexPackages
% For further information see the url above.
% Reportings of bugs, suggestions and improvements are welcome, see the README
% at the Git repository for further information.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesExplPackage{mkessler-mathsymbindex}{2022/01/11}{v2.5.0}{Declaring of math symbols with automatic indexing}
\RequirePackage{imakeidx}
\RequirePackage{amsmath}
\RequirePackage{xparse}
% Keys used for declaring symbols
\keys_define:nn { symbol }
{
operator .tl_set:N = \l_symbol_operator_tl,
operator .default:n = \use:n,
formula .tl_set:N = \l_symbol_formula_tl,
formula .default:n = \c_novalue_tl,
ordered .tl_set:N = \l_symbol_ordered_tl,
ordered .default:n = \c_novalue_tl,
description .tl_set:N = \l_symbol_description_tl,
description .default:n = \c_novalue_tl,
group .tl_set:N = \l_symbol_group_tl,
group .default:n = \c_novalue_tl
}
% Core macro not be used publicly directly. Usage:
% #1 = indexname / group
% #2 = symbolname,
% #3 = description
% #4 = operator to apply (one argument) - can be \use:n for identity
% #5 = substitution when called
% #6 = ordering in index
\cs_new_protected:Nn\symbol_define:nnnnnn
{
\bool_new:c { used_#2 }
\cs_new_protected:cn { symbol_#2: }
{
#4{#5}
\bool_if:cF { used_#2 }
{
\index[#1]
{
#6
@
$#4{#5}$
#3
}
\bool_gset_true:c { used_#2 }
}
}
\exp_args:Nc\gdef{#2}
{
\use:c { symbol_#2: }
}
}
\cs_generate_variant:Nn\symbol_define:nnnnnn { V n V V V V }
% Main package interface
\NewDocumentCommand{\DeclareSymbol}{ O{} m}
{
\keys_set:nn{ symbol }
{
operator,
formula,
ordered,
description,
group
}
\keys_set:nn{ symbol }{#1}
\tl_if_eq:NnTF\l_symbol_description_tl{\c_novalue_tl}
{
\tl_set:Nn\l_symbol_description_tl { \c_empty_tl }
}
{
\tl_put_left:Nn\l_symbol_description_tl { ,\c_space_tl }
}
\tl_if_eq:NnT\l_symbol_formula_tl{\c_novalue_tl}
{
\tl_set:Nn\l_symbol_formula_tl {#2}
}
\tl_if_eq:NnT\l_symbol_ordered_tl{\c_novalue_tl}
{
\tl_set:Nn\l_symbol_ordered_tl {#2}
}
\symbol_define:VnVVVV
\l_symbol_group_tl
{
#2
}
\l_symbol_description_tl
\l_symbol_operator_tl
\l_symbol_formula_tl
\l_symbol_ordered_tl
}
%% Wrapper commands specific for defining categories
\NewDocumentCommand{\category}{ m }
{
\operatorname{\textbf{#1}}
}
\NewDocumentCommand{\DeclareCategory}{ O{} m }
{
\DeclareSymbol[group = categories, #1]{#2}
}
\NewDocumentCommand{\DeclareSimpleCategory}{ o m }
{
\IfValueTF{#1}
{
\DeclareCategory[operator = \category, description = #1]{#2}
}
{
\DeclareCategory[operator = \category]{#2}
}
}