diff options
author | Karl Berry <karl@freefriends.org> | 2017-06-09 22:33:09 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-06-09 22:33:09 +0000 |
commit | 4a29a4d67989a64f1aeab28d89711da8d2e0a09a (patch) | |
tree | c3da58dda62674513be437d591cab2222ce54bed | |
parent | d1f4d483eee9d0c2e75c6915bb559c65992a7cde (diff) |
knowledge (9jun17)
git-svn-id: svn://tug.org/texlive/trunk@44544 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/README.TEXLIVE | 7 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/README.txt | 26 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/knowledge/knowledge-example.tex | 96 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/knowledge/knowledge.sty | 2637 | ||||
-rwxr-xr-x | Master/tlpkg/bin/tlpkg-ctan-check | 2 | ||||
-rwxr-xr-x | Master/tlpkg/libexec/ctan2tds | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc | 1 | ||||
-rw-r--r-- | Master/tlpkg/tlpsrc/knowledge.tlpsrc | 0 |
8 files changed, 2769 insertions, 1 deletions
diff --git a/Master/texmf-dist/doc/latex/knowledge/README.TEXLIVE b/Master/texmf-dist/doc/latex/knowledge/README.TEXLIVE new file mode 100644 index 00000000000..bea3d266f88 --- /dev/null +++ b/Master/texmf-dist/doc/latex/knowledge/README.TEXLIVE @@ -0,0 +1,7 @@ +The following files have been removed in the TeX Live installation of +the current package, typically due to duplication, lack of space, or +missing source code. You can find these files on CTAN at + http://mirror.ctan.org/macros/latex/contrib/knowledge +If questions or concerns, email tex-live@tug.org. + + knowledge.pdf diff --git a/Master/texmf-dist/doc/latex/knowledge/README.txt b/Master/texmf-dist/doc/latex/knowledge/README.txt new file mode 100644 index 00000000000..16cb728d87e --- /dev/null +++ b/Master/texmf-dist/doc/latex/knowledge/README.txt @@ -0,0 +1,26 @@ +This directory contains the package + + name: knowledge.sty + version: 1.0 + date: 2017-06-09 + license: LaTeX Project Public License version 1.2 or above + + author: Thomas Colcombet + mail: thomas.colcombet@irif.fr + web: https://www.irif.fr/~colcombe/knowledge_en.html + + +Purpose: +The knowledge package for LaTeX offers a systematic way to handle +notions/concepts/terms throughout a document. It helps building an +index. In combination with hyperref it makes it easy to have every +references of a concept linked to its introduction. It also offers +simple notations. + + +Content of the file knowledge.zip: + - README.txt: this file + - knowledge.sty: the package file + - knowledge.pdf: a documentation + - knowledge-example.tex: a minimalist example + diff --git a/Master/texmf-dist/doc/latex/knowledge/knowledge-example.tex b/Master/texmf-dist/doc/latex/knowledge/knowledge-example.tex new file mode 100644 index 00000000000..878036ef03d --- /dev/null +++ b/Master/texmf-dist/doc/latex/knowledge/knowledge-example.tex @@ -0,0 +1,96 @@ +\documentclass{article} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +% +% The documentation of the _knowledge package_ can be found at: +% +% http://www.irif.fr/~colcombe/knowledge_en.html +% +% +% Loading other packages before knowledge activates features. +% The most common use of knowledge makes use of hyperref and xcolor: +\usepackage[breaklinks,hidelinks]{hyperref} +\usepackage{xcolor} +% +% The package 'knowledge' has now to be loaded. +% The options +% 'paper', 'electronic' or 'composition' (default) +% can be used. These activates different rendering styles. +% - paper produce a paper to be printed +% - electronic highlights links using color +% - composition (or default) highlights missing knowledges as +% well as other information. It should always be used but when the paper is ready. +% +\usepackage{knowledge} % default +%\usepackage[electronic]{knowledge} % final version to be read electronically +%\usepackage[paper]{knowledge} % final version in black and white for printing +% + +% The 'notion' configuration is commonly used for scientific papers. +\knowledgeconfigure{notion} + +% The 'quotation' configuration is commonly used and triggers the "..." notation. +\knowledgeconfigure{quotation} + + + +% The following +% It is convenient now to provide a list of \knowledge in the preamble: +% \knowledge{knowledge text}[synonym 1|synonym 2|...]{directives} +% Most common in a science paper are 'notion' knowledges that +% are used in the body with \intro and \kl commands/""...""" and "..." notatation: +\knowledge{anchor point}[anchor points|Anchor points]{notion} +\knowledge{diagnose file}{notion} +\knowledge{knowledge package}{notion,typewriter} +\knowledge{paper mode}{notion} +\knowledge{electronic mode}{notion} +\knowledge{composition mode}{notion} + +% the synonym directive can replace the [...] syntax +\knowledge{knowledge}{notion} +\knowledge{knowledges}{synonym} +\knowledge{Knowledges}{synonym} + +% Some other configurations are possible, such as: +\knowledge{LaTeX}[latex|LATEX|Latex]{url={https://fr.wikipedia.org/wiki/LaTeX}, text=\LaTeX} +\knowledge{pdflatex}{url={https://en.wikipedia.org/wiki/PdfTeX}, typewriter} + + +\title{Mini example for the \texttt{knowledge} package} +\date{} +\begin{document} +\maketitle +\begin{abstract} +\AP This document provides an elementary example of the ""knowledge package"" for "latex". +\end{abstract} + +Try compiling this document (two compilation phases to have proper links) using "pdflatex", and see how some notions are hyperlinked to their introduction point (some viewers make it more obvious than others by displaying a preview of the target of a link inside a document; since there is only one page in this example, this may be worth zooming in this case). +\AP When the "paper mode" is not active, links are clearly identified in blue. Try then compiling it in ""paper mode"" (an option of the "knowledge package"); it now looks like a regular paper (but the links are still there). In ""electronic mode"", +the links are still colored, but some other hints disappear like "anchor points". + +% \AP provides an anchor point: this will be the precise target of the hyperlink. +% It is good practice to use is at the beginning of every paragraph that contains +% \intro commands. If 'final=false', then these anchor points appear as a small +% corner (red with xcolor). + + +\knowledgeconfigure{quotation=false}% temporarily disables the " notation +\AP While writing a document, the two syntaxes \verb|"text"| and \verb|""text""| should be used each time some important concept is used or introduced respectively in the paper. For instance: +\begin{quote} +\verb|Define a ""group"" to be a "monoid" such that...| +\end{quote} +The `@' symbol allows some flexibility by having a displayed text different from the target: +\begin{quote} +\verb|"This kind of algebras@solvable groups"...| +\end{quote} +\knowledgeconfigure{quotation} + +\AP These concepts are referred to as ""knowledges"". "Knowledges" are to be defined (in general in the preamble of the document) using a command of the form: +\begin{quote} +\verb|\knowledge|\texttt{\{name\}[synonym1|synonym2|...]\{directives\}} +\end{quote} +However, using undefined "knowledges" will not cause compile time errors, but be displayed as in the following `"unknown knowledge"' (i.e. in non-"paper mode" in brown, but in regular black in "paper mode" or "electronic mode"). \AP The ""diagnose file"" (that ends with a \texttt{.diagnose} extension) contains detailed information about these warnings, and should be read often when finalising the document. + +\AP Small red corners are visible in the margin. These are called ""anchor points"", are introduced +using the \texttt{\detokenize{\AP}}command usually at the beginning of each paragraph that introduce some concept, or even in the middle of the paragraph. The "anchor points" become invisible in "paper@paper mode" or "electronic mode". +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/knowledge/knowledge.sty b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty new file mode 100644 index 00000000000..a040cc7fc42 --- /dev/null +++ b/Master/texmf-dist/tex/latex/knowledge/knowledge.sty @@ -0,0 +1,2637 @@ +%% +%% This is file `knowledge.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% knowledge.dtx (with options: `head') +%% knowledgeutils.dtx (with options: `package') +%% knowledge.dtx (with options: `package') +%% scopearticle.dtx (with options: `package') +%% +%% This is a generated file. Copyright (C) 2016 by Thomas Colcombet +%% +%% This file may be distributed and/or modified under the +%% conditions of the LaTeX Project Public License, either +%% version 1.2 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.2 or later is part of all distributions of +%% LaTeX version 1999/12/01 or later. +%% +%%%%%%%%%% +\usepackage{expl3} +\ProvidesExplPackage{knowledge}{2017/06/08}{1.0}{first release} +\RequirePackage{l3keys2e} +\RequirePackage{etoolbox} +\RequirePackage[log-declarations=false]{xparse} +\bool_if_exist:NTF\knowledge_package_loaded_bool + {\endinput} + {\bool_set_true:N\knowledge_package_loaded_bool} + +\cs_new:Npn\knowledge_skip_module:#1\knowledge_end_module: + {} +\cs_new:Nn\knowledge_begin_module_if:N + {\bool_if:NF#1\knowledge_skip_module:} +\cs_new:Nn\knowledge_end_module: + {} + +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{knowledgeutils} + [2016/02/26 v2.0 first codes of the new version] +\usepackage{xparse} +\usepackage{currfile} +\ExplSyntaxOn +\tl_if_exist:cF{c_job_name_tl} + {\tl_set_eq:NN\c_job_name_tl\c_sys_jobname_str} +\cs_new_protected:Nn\cs_new_protected_with_variants:Nnn + {\cs_new_protected:Nn#1{#3} + \cs_generate_variant:Nn#1{#2}} +\cs_generate_variant:Nn\cs_new_protected_with_variants:Nnn{cnn} + +\cs_new_protected:Nn\cs_new_with_variants:Nnn + {\cs_new:Nn#1{#3} + \cs_generate_variant:Nn#1{#2}} +\cs_generate_variant:Nn\cs_new_with_variants:Nnn{cnn} + +\cs_generate_variant:Nn\tl_show:n{x} +\cs_new:Nn\tl_if_exist_ne:NTF + {\tl_if_exist:NTF#1{\tl_if_empty:NTF#1{#3}{#2}}{#3}} +\cs_generate_variant:Nn\tl_if_empty:nTF{xTF} +\cs_new_protected:Npn\kl_apply_inline:nnw#1#2 + {\group_begin: + \cs_set:cn{g_tmpa_cs:#1} + {\group_end:#2} + \use:c{g_tmpa_cs:#1}} + +\cs_new_protected:Npn\kl_apply_inline_variant:nnnw#1#2#3 + {\group_begin: + \cs_set:cn{g_tmpa_cs:#1} + {\group_end:#3} + \exp_args:Nc + \cs_generate_variant:Nn{g_tmpa_cs:#1}{#2} + \use:c{g_tmpa_cs:#2}} +\cs_new:Nn\mode_if_preamble:TF{#1} +\AtBeginDocument + {\cs_gset:Nn\mode_if_preamble:TF{#2}} +\makeatletter +\int_new:N\kl_sphack_int +\cs_set_eq:NN\kl_stored_@bsphack\@bsphack +\cs_set_eq:NN\kl_stored_@esphack\@esphack +\cs_set:Nn\kl_hide_begin: + {\@bsphack + \cs_set_eq:NN\@bsphack\relax + \cs_set_eq:NN\@esphack\relax + \int_incr:N\kl_sphack_int} +\cs_set:Nn\kl_hide_end: + {\int_decr:N\kl_sphack_int + \int_compare:nNnTF{\kl_sphack_int}=0 + {\cs_set_eq:NN\@bsphack\kl_stored_@bsphack + \cs_set_eq:NN\@esphack\kl_stored_@esphack}{} + \@esphack} +\makeatother +\cs_new:Nn\if_true:TF{#1} +\cs_new:Nn\if_false:TF{#2} +\cs_generate_variant:Nn\int_compare:nNnTF{cNnTF} +\cs_generate_variant:Nn\use:nn{nx} +\cs_new:Npn\cs_apply_inline:nn#1 + {\cs_set:Npn\g_tmpa_cs:##1{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4##5{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4##5##6{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4##5##6##7{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnnnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4##5##6##7##8{#1} + \g_tmpa_cs:} +\cs_new:Npn\cs_apply_inline:nnnnnnnnnn#1 + {\cs_set:Npn\g_tmpa_cs:##1##2##3##4##5##6##7##8##9{#1} + \g_tmpa_cs:} +\cs_generate_variant:Nn\cs_apply_inline:nn{nc} +\cs_generate_variant:Nn\cs_apply_inline:nnn{ncc} +\cs_generate_variant:Nn\cs_apply_inline:nnnn{nccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnn{ncccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnnn{nccccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnnnn{ncccccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnnnnn{nccccccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnnnnnn{ncccccccc} +\cs_generate_variant:Nn\cs_apply_inline:nnnnnnnnnn{nccccccccc} +\AtBeginDocument{\KAuxActivate} + +\NewDocumentCommand\KAuxActivate{}{ + \cs_gset_eq:NN\KAuxActivate\relax + \KAuxOpen{}} +\AtEndDocument{\KAuxClose} +\iow_new:N\knowledge_kaux_iow + +\NewDocumentCommand\KAuxOpen{} + {\kaux_pretreatment_tl + \tl_gclear:N\kaux_pretreatment_tl + \iow_open:Nn + \knowledge_kaux_iow + {\c_job_name_tl.kaux} + \KAuxWrite*{} + \kaux_inittreatment_tl + \tl_gclear:N\kaux_inittreatment_tl + \KAuxWrite*{}} + +\NewDocumentCommand\KAuxClose{} + {\iow_close:N\knowledge_kaux_iow + \bool_gset_true:N\kaux_can_be_used_bool + \kaux_posttreatment_tl + } +\NewDocumentCommand\KAuxBefore{m} + {\tl_put_right:Nn\kaux_pretreatment_tl{#1}} +\NewDocumentCommand\KAuxAfter{m} + {\tl_put_right:Nn\kaux_posttreatment_tl{#1}} +\NewDocumentCommand\KAuxInit{m} + {\tl_put_right:Nn\kaux_inittreatment_tl{#1}} +\tl_gset:Nn\kaux_pretreatment_tl{} +\tl_gset:Nn\kaux_posttreatment_tl{} +\tl_gset:Nn\kaux_inittreatment_tl{} +\tl_new:N\kaux_command_list_tl +\NewDocumentCommand\NewKAuxCommand{ m m m } +{ \ProvideDocumentCommand#1{#2}{} + \KAuxInit + {\KAuxWrite*{\KAuxCommand#1{#2}{#3}}} + \tl_gset:cn{kaux_\cs_to_str:N#1-args_tl}{#2} + \tl_gput_right:Nn\kaux_command_list_tl{#1} +} +\NewDocumentCommand\KAuxCommand{mmm} + {\ProvideDocumentCommand#1{#2}{}} +\NewDocumentCommand\ActivateKAuxPhase{m}{ + \tl_map_inline:Nn\kaux_command_list_tl + {\kaux_activate_command_phase:Nn##1{#1}} + } +\cs_new:Nn\kaux_activate_command_phase:Nn +{ \tl_gclear:c{kaux_\cs_to_str:N#1-active_tl} + % + \kaux_code_set:Nn\tmpa_code{} + \clist_map_inline:nn{#2} + {\cs_if_exist:cTF{kaux_\cs_to_str:N#1-##1:nnnnnnnnn} + {\exp_args:NNc + \kaux_code_put_right:NN + \tmpa_code{kaux_\cs_to_str:N#1-##1:nnnnnnnnn}} + {}} + \kaux_code_wrap:N\tmpa_code + \exp_args:NNx\kaux_code_put_left:Nn\tmpa_code + {\DeclareDocumentCommand\exp_not:N#1 + {\exp_not:v{kaux_\cs_to_str:N#1-args_tl}}} + \kaux_code_exec:N\tmpa_code +} +\cs_new:Nn\kaux_code_set_eq:NN + {\cs_set_eq:NN#1#2} +\cs_new:Nn\kaux_code_set:Nn + {\cs_set:Npn#1##1##2##3##4##5##6##7##8##9{#2}} +\cs_new:Nn\kaux_code_put_right:NN + {\exp_args:NNo\kaux_code_put_right:Nn#1 + {#2{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}}} +\cs_new:Nn\kaux_code_put_right:Nn + {\exp_args:NNo\cs_set:Nn + \tmp:nnnnnnnnn + {#1{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}#2} + \cs_set_eq:NN#1\tmp:nnnnnnnnn} +\cs_new:Nn\kaux_code_put_left:Nn + {\kaux_code_set:Nn\g_tmpc_code{#2} + \kaux_code_put_right:NN\g_tmpc_code#1 + \kaux_code_set_eq:NN#1\g_tmpc_code} +\cs_new:Nn\kaux_code_wrap:N + {\expandafter\cs_set:Nn + \expandafter\tmp:nnnnnnnnn + \expandafter{ + \expandafter{#1{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}}} + \cs_set_eq:NN#1\tmp:nnnnnnnnn} +\cs_new:Nn\kaux_code_exec:N + {#1{##1}{##2}{##3}{##4}{##5}{##6}{##7}{##8}{##9}} +\NewDocumentCommand\DeclareKAuxPhaseCommand{mmm} +{ \tl_if_exist:cTF{kaux_\cs_to_str:N#1-args_tl}{} + {\ERROR_KAuxCommand_UNDEFINED} + \cs_gset:cn{kaux_\cs_to_str:N#1-#2:nnnnnnnnn}{#3}} +\NewDocumentCommand\KAuxWriteLocation{} + {\KAuxActivate + \group_begin: + \tl_set:Nx\l_tmpa_tl{{\currfilename}{\the\inputlineno}} + \tl_if_eq:NNTF\l_tmpa_tl\kaux_location_tl + {} + {\tl_gset_eq:NN\kaux_location_tl\l_tmpa_tl + \iow_now:Nx\knowledge_kaux_iow{} + \iow_now:Nx\knowledge_kaux_iow + {\KAuxFileAt\kaux_location_tl}} + \group_end:} + +\tl_new:N\kaux_location_tl + +\NewDocumentCommand\KAuxWriteX{sm} + {\KAuxActivate + \IfBooleanTF{#1}{}{\KAuxWriteLocation} + \exp_args:NNx\iow_now:Nn\knowledge_kaux_iow{#2}} + +\NewDocumentCommand\KAuxWrite{sm} + {\KAuxActivate + \IfBooleanTF{#1}{}{\KAuxWriteLocation} + \iow_now:Nn\knowledge_kaux_iow{#2}} + +\NewDocumentCommand\KAuxFileAt{mm} + {\tl_set:Nn\kauxCurrentFile{#1} + \tl_set:Nn\kauxCurrentLine{#2}} + +\tl_new:N\kauxCurrentFile +\tl_new:N\kauxCurrentLine + +\bool_new:N\kaux_can_be_used_bool +\bool_gset_false:N\kaux_can_be_used_bool + +\file_if_exist:nT{\c_job_name_tl.aux} +{\file_if_exist:nT{\c_job_name_tl.kaux} + {\bool_gset_true:N\kaux_can_be_used_bool}} + +\NewDocumentCommand\KAuxProcess{m} +{ \bool_if:NT\kaux_can_be_used_bool + {\ActivateKAuxPhase{#1} + \input{\c_job_name_tl.kaux}}} +\cs_new:Nn\cell_new_type:nnn + { + \cs_new:cn{#1_id:#2}{#3} + \cs_new:cn{#1_id_b:#2}{{#3}} + \cs_new:cpx{#1_at:N#2}##1 + {\exp_not:n{\exp_after:wN\exp_args:Nc\exp_after:wN} + ##1 \exp_not:c{#1_id_b:#2}} + } + +\cs_new:Nn\cell_specialize:nnn + {\cs_new:cpx{#1_#2_id:#3} + {\exp_not:c{#1_id:n#3}{#2}} + \cs_new:cpx{#1_#2_at:N#3}##1 + {\exp_not:c{#1_at:Nn#3}##1{#2}} + } + +\cs_new:Nn\cell_make_tl:nn + {\cs_set:Nn\l_tmpa_cs:nn + {\cs_new:cpx{#1_##1:#2##2} + {\exp_not:c{#1_at:N#2}\exp_not:c{tl_##1:N##2}}} + \l_tmpa_cs:nn{set}{n} + \l_tmpa_cs:nn{gset}{n} + \l_tmpa_cs:nn{set}{x} + \l_tmpa_cs:nn{gset}{x} + \l_tmpa_cs:nn{gput_right}{n} + \l_tmpa_cs:nn{gput_left}{n} + \l_tmpa_cs:nn{put_right}{n} + \l_tmpa_cs:nn{put_left}{n} + \l_tmpa_cs:nn{show}{} + \l_tmpa_cs:nn{use}{} + \l_tmpa_cs:nn{if_exist}{TF} + \l_tmpa_cs:nn{if_empty}{TF} + } + +\cs_new:Nn\cell_make_int:nn + { + \cs_set:Nn\l_tmpa_cs:nn + {\cs_new:cpx{#1_##1:#2##2} + {\exp_not:c{#1_at:N#2}\exp_not:c{int_##1:N##2}}} + \l_tmpa_cs:nn{new}{} + \l_tmpa_cs:nn{show}{} + \l_tmpa_cs:nn{set}{n} + \l_tmpa_cs:nn{gset}{n} + \l_tmpa_cs:nn{incr}{} + \l_tmpa_cs:nn{gincr}{} + \l_tmpa_cs:nn{decr}{} + \l_tmpa_cs:nn{gdecr}{} + \l_tmpa_cs:nn{use}{} + \l_tmpa_cs:nn{to_arabic}{} + } + +\cs_new:Nn\cell_make_bool:nn + { + \cs_set:Nn\l_tmpa_cs:nn + {\cs_new:cpx{#1_##1:#2##2} + {\exp_not:c{#1_at:N#2}\exp_not:c{bool_##1:N##2}}} + \l_tmpa_cs:nn{set_true}{} + \l_tmpa_cs:nn{set_false}{} + \l_tmpa_cs:nn{gset_true}{} + \l_tmpa_cs:nn{gset_false}{} + \l_tmpa_cs:nn{set}{n} + \l_tmpa_cs:nn{gset}{n} + \l_tmpa_cs:nn{if}{TF} + } + +\cs_new:Nn\seq_use:N + {\seq_use:Nn#1,} + +\cs_new:Nn\cell_make_seq:nn + { + \cs_set:Nn\l_tmpa_cs:nn + {\cs_new:cpx{#1_##1:#2##2} + {\exp_not:c{#1_at:N#2}\exp_not:c{seq_##1:N##2}}} + \l_tmpa_cs:nn{new}{} + \l_tmpa_cs:nn{set_from_clist}{n} + \l_tmpa_cs:nn{gset_from_clist}{n} + \l_tmpa_cs:nn{gpush}{n} + \l_tmpa_cs:nn{if_exist}{TF} + \l_tmpa_cs:nn{if_empty}{TF} + \l_tmpa_cs:nn{if_in}{nTF} + \l_tmpa_cs:nn{show}{} + \l_tmpa_cs:nn{use}{n} + \l_tmpa_cs:nn{use}{} + \l_tmpa_cs:nn{map_inline}{n} + } + +\cs_new:Nn\cell_make_tuple:nn + { + \cs_set:Nn\l_tmpa_cs:nn + {\cs_new:cpx{#1_##1:#2##2} + {\exp_not:c{#1_at:N#2}\exp_not:c{tuple_##1:N##2}}} + } + +\cs_new:Nn\cell_specialize_int:nnn + { + \cell_specialize:nnn{#1}{#2}{#3} + \cell_make_int:nn{#1_#2}{#3} + } + +\cs_new:Nn\cell_specialize_tl:nnn + { + \cell_specialize:nnn{#1}{#2}{#3} + \cell_make_tl:nn{#1_#2}{#3} + } + +\cs_new:Nn\cell_specialize_bool:nnn + { + \cell_specialize:nnn{#1}{#2}{#3} + \cell_make_bool:nn{#1_#2}{#3} + } + +\cs_new:Nn\cell_specialize_seq:nnn + { + \cell_specialize:nnn{#1}{#2}{#3} + \cell_make_seq:nn{#1_#2}{#3} + } +\cs_new:Nn\tuple_new:n + { + \cs_new:cx{#1_new:N} + {\exp_not:N\tl_new:N##1 + \exp_not:N\tl_gset:Nn##1{\exp_not:c{#1:}}} + \cs_new:cx{#1_gclear:N} + {\exp_not:N\tl_gset:Nn##1{\exp_not:c{#1:}}} + \cs_new:cx{#1_ensure:N} + {\exp_not:N\tl_if_exist:NTF##1{} + {\exp_not:N\tl_new:N##1 + \exp_not:N\tl_gset:Nn##1{\exp_not:c{#1:}}}} + \cs_new:cn{#1:}{} + % + \cs_set:Nn\l_tmpa_cs:nn + { \cs_new:cpx{#1_##1:##2} + {\exp_not:c{tuple_##1:n##2}{\exp_not:n{#1}}}} + \l_tmpa_cs:nn{new_tl_index}{Nnn} + \l_tmpa_cs:nn{new_tl_index}{nn} + \l_tmpa_cs:nn{new_tl_index}{n} + \l_tmpa_cs:nn{new_int_index}{Nnn} + \l_tmpa_cs:nn{new_int_index}{nn} + \l_tmpa_cs:nn{new_int_index}{n} + \l_tmpa_cs:nn{new_bool_index}{Nn} + \l_tmpa_cs:nn{new_bool_index}{n} + \l_tmpa_cs:nn{show}{N} + \l_tmpa_cs:nn{if_exist}{NTF} + } +\cs_new:Npn\tuple_if_exist:nNTF#1{\tl_if_exist:NTF} +\cs_new:Nn\tuple_new_bool_index:nNNn + { + \cs_new:cn{#1_#4_expands_to:TF}{ + \cs_set:Nn#2{##1} + \cs_set:Nn#3{##2}} + \cs_gset:Nn#2{} + \cs_gset:Nn#3{} + % + \cs_new:cx{#1_#4_if:NTF} + {\exp_not:N\expandafter + \exp_not:c{#1_#4_if~i:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}{##3}{##2}} + \cs_new:cpn{#1_#4_if~i:w} + ##1 #2 ##2 #2 ##3 \tuple_end: + {\tl_if_single:nTF{##3}} + % + \cs_new:cx{#1_#4_gset_false:N} + {\exp_not:N\expandafter + \exp_not:c{#1_#4_gset_false~i:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1} + \cs_new:cpn{#1_#4_gset_false~i:w} + ##1 #2 ##2 #2 ##3 \tuple_end:##4 + {\tl_if_single:nTF{##3} + {\tl_gset:Nn##4{##1}} + {\tl_gset:Nn##4{##1##2}}} + % + \cs_new:cx{#1_#4_gset_true:N} + {\exp_not:N\expandafter + \exp_not:c{#1_#4_gset_true~:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1} + \cs_new:cpn{#1_#4_gset_true~:w} + ##1 #2 ##2 #2 ##3 \tuple_end: ##4 + {\tl_if_single:nTF{##4} + {\tl_gset:Nn##4{##1 #2}}{}} +} +\cs_new:Nn\tuple_new_bool_index:nn + {\use:x{\exp_not:n{\tuple_new_bool_index:nNNn{#1}} + \exp_not:c{BOOL_#1_#2_true:} + \exp_not:c{BOOL_#1_#2_false:} + {#2}}} +\cs_new:Nn\tuple_new_index:nNnn{ + \cs_new:cn{#1_#3_expands_to:n}{\cs_set:Nn#2{##1}} + \cs_gset:Nn#2{} + % + \cs_new:cx{#1_#3_use:N} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_use~i:w} + ##1 \exp_not:n{#2 {#4}\tuple_end:}} + \cs_new:cpx{#1_#3_use~i:w} + ##1 #2 ##2 ##3 \tuple_end:{##2} + % + \cs_new:cx{#1_#3_if_exist:NTF} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_if_exist~i:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}{##3}{##2}} + \cs_new:cpn{#1_#3_if_exist~i:w} + ##1 #2 ##2 ##3 #2 ##4 \tuple_end: + {\tl_if_single:nTF{##4}} + % + \cs_new:cx{#1_#3_gdel:N} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_gdel~i:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1} + \cs_new:cpn{#1_#3_gdel~i:w} + ##1 #2 ##2 ##3 #2 ##4 \tuple_end:##5 + {\tl_if_single:nTF{##4} + {\tl_gset:Nn##5{##1}} + {\tl_gset:Nn##5{##1##3}}} + % + \cs_new:cx{#1_#3_gapply:NN} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_gapply~i:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1##2} + \cs_new:cpn{#1_#3_gapply~i:w} + ##1 #2 ##2 ##3 #2 ##4 \tuple_end: ##5 ##6 + {\tl_if_single:nTF{##4} + {\tl_gset:Nx##5{\exp_not:n{##1 #2}{##6{#4}}}} + {\tl_gset:Nx##5{\exp_not:n{##1 #2}{##6{##2}} \exp_not:n{##3}}}} +} + +\cs_new:Nn\tuple_new_tl_index:nNnn + {\tuple_new_index:nNnn{#1}#2{#3}{#4} + % + \cs_new:cx{#1_#3_gset:Nn} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_gset~:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1{##2}} + \cs_new:cpn{#1_#3_gset~:w} + ##1 #2 ##2 ##3 #2 ##4 \tuple_end: ##5 ##6 + {\tl_if_single:nTF{##4} + {\tl_gset:Nn##5{##1 #2{##6}}} + {\tl_gset:Nn##5{##1 #2{##6} ##3}}} +} +\cs_new:Nn\tuple_new_tl_index:nnn + {\exp_args:Nnc\tuple_new_tl_index:nNnn{#1}{TL_#1_#2_:n}{#2}{#3}} +\cs_new:Nn\tuple_new_tl_index:nn + {\tuple_new_tl_index:nnn{#1}{#2}{}} + +\cs_new:Nn\int_incr:n{\int_eval:n{#1+1}} +\cs_new:Nn\int_decr:n{\int_eval:n{#1-1}} + +\cs_new:Nn\tuple_new_int_index:nNnn{ + \tuple_new_index:nNnn{#1}#2{#3}{#4} + % + \cs_new:cx{#1_#3_get_int:NN} + {\exp_not:n{\int_set:Nn} ##2 {\exp_not:c{#1_#3_use:N} \exp_not:N##1}} + % + \cs_new:cx{#1_#3_gincr:N} + {\exp_not:c{#1_#3_gapply:NN}##1\exp_not:N\int_incr:n} + % + \cs_new:cx{#1_#3_gdecr:N} + {\exp_not:c{#1_#3_gapply:NN}##1\exp_not:N\int_decr:n} + % + \cs_new:cx{#1_#3_gset:Nn} + {\exp_not:N\expandafter + \exp_not:c{#1_#3_gset~:w} + ##1 \exp_not:n{#2 ab #2 c \tuple_end:}##1{##2}} + \cs_new:cpn{#1_#3_gset~:w} + ##1 #2 ##2 ##3 #2 ##4 \tuple_end: ##5 ##6 + {\tl_if_single:nTF{##4} + {\tl_gset:Nx##5{##1 \exp_not:N#2 {\int_eval:n{##6}}}} + {\tl_gset:Nx##5{##1 \exp_not:N#2 {\int_eval:n{##6}} ##3}}} + % + \cs_new:cpx{#1_#3_case:NnTF}##1 + {\exp_not:N\int_case:nnTF{\exp_not:c{#1_#3_eval:n}##1}} +} +\cs_new:Nn\tuple_new_int_index:nnn + {\exp_args:Nnc\tuple_new_int_index:nNnn{#1}{INT_#1_#2_:n}{#2}{#3}} +\cs_new:Nn\tuple_new_int_index:nn + {\tuple_new_int_index:nnn{#1}{#2}{0}} +\cs_new:Nn\int_get_default:N + {\int_if_exist:NTF#1{\int_use:N#1}{0}} +\cs_generate_variant:Nn\int_get_default:N{c} +\cs_new:Nn\int_force:N + {\int_if_exist:NTF#1{}{\int_new:N#1}} +\cs_new:Npn\int_force_gset:Nn#1 + {\int_force:N#1\int_gset:Nn#1} +\NewDocumentCommand\NewGBool{ m m o }{ + \IfNoValueTF{#3}{ + \tl_gset:Nn\g_tmpa_tl{#2} + \tl_remove_all:Nn\g_tmpa_tl{~} + \int_case:nnTF{\tl_count:N\g_tmpa_tl}{ + 0 {\NewGBoolComplete {#1}{#2}{#1:_bool}} + 1 {\NewGBoolComplete {#1}{#2}{#1:##1_bool}} + 2 {\NewGBoolComplete {#1}{#2}{#1:##1...##2_bool}} + 3 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3_bool}} + 4 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4_bool}} + 5 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4...##5_bool}} + 6 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4...##5...##6_bool}} + 7 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4...##5...##6...##7_bool}} + 8 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4...##5...##6...##7...##8_bool}} + 9 {\NewGBoolComplete {#1}{#2}{#1:##1...##2...##3...##4...##5...##6...##7...##8...##9_bool}} + }{}{\ERROR}}{\NewGBoolComplete{#1}{#2}{#3}}} +\NewDocumentCommand\NewGBoolComplete{ m m m }{ + \exp_args:Nc\NewDocumentCommand{#1SetTrue}{#2} + {\bool_gset_true:c{#3}} + \exp_args:Nc\NewDocumentCommand{#1SetFalse}{#2} + {\bool_gset_false:c{#3}} + \exp_args:Nc\NewDocumentCommand{#1Set}{#2} + {\exp_args:Nc\bool_gset_tl:Nn{#3}} + \exp_args:Nc\DeclareExpandableDocumentCommand{#1IfTF}{#2} + {\bool_if:cTF{#3}} +} +\cs_new:Nn\bool_gset_tl:Nn + {\use:c{bool_gset_#2:N}#1} +\NewDocumentCommand\NewGCs{ m m o }{ + \IfNoValueTF{#3}{ + \tl_gset:Nn\g_tmpa_tl{#2} + \tl_remove_all:Nn\g_tmpa_tl{~} + \int_case:nnTF{\tl_count:N\g_tmpa_tl}{ + 0 {\NewGCsComplete {#1}{#2}{#1_:}} + 1 {\NewGCsComplete {#1}{#2}{#1_##1_cs:w}} + 2 {\NewGCsComplete {#1}{#2}{#1_##1...##2_cs:w}} + 3 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3_cs:w}} + 4 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4_cs:w}} + 5 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4...##5_cs:w}} + 6 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4...##5...##6_cs:w}} + 7 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4...##5...##6...##7_cs:w}} + 8 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4...##5...##6...##7...##8_cs:w}} + 9 {\NewGCsComplete {#1}{#2}{#1_##1...##2...##3...##4...##5...##6...##7...##8...##9_cs:w}} + }{}{\ERROR}}{\NewGCsComplete{#1}{#2}{#3}}} +\NewDocumentCommand\NewGCsComplete{ m m m }{} +\cs_new_protected_with_variants:Nnn\kl_copy_file:nn{nV,Vn,VV} + {\file_if_exist:nT{#1} + {\group_begin: + \bool_set_false:N\l_tmpa_bool + \ior_open:Nn\g_tmpa_ior{#1} + \iow_open:Nn\g_tmpa_iow{#2} + \bool_do_until:Nn\l_tmpa_bool{ + \ior_if_eof:NTF\g_tmpa_ior + {\bool_set_true:N\l_tmpa_bool} + {\ior_get_str:NN + \g_tmpa_ior + \l_tmpa_tl + \exp_args:NNV + \iow_now:Nn + \g_tmpa_iow + \l_tmpa_tl} + } + \ior_close:N\g_tmpa_ior + \iow_close:N\g_tmpa_iow + \group_end:}} + +\cs_new_protected_with_variants:Nnn\kl_compare_files:Nnn{NnV,NVn,NVV} + {\group_begin: + \bool_set_false:N\l_tmpa_bool% set when finished + \bool_set_true:N\l_tmpb_bool% result + \file_if_exist:nTF{#2} + {\file_if_exist:nF{#3} + {\bool_set_true:N\l_tmpa_bool + \bool_set_false:N\l_tmpb_bool}} + {\bool_set_true:N\l_tmpa_bool + \file_if_exist:nT{#3} + {\bool_set_false:N\l_tmpb_bool}} + \bool_if:NF\l_tmpa_bool{ + \ior_open:Nn\g_tmpa_ior{#2} + \ior_open:Nn\g_tmpb_ior{#3} + % + \bool_do_until:Nn\l_tmpa_bool{ + \ior_if_eof:NTF\g_tmpa_ior + {\bool_set_true:N\l_tmpa_bool + \ior_if_eof:NF\g_tmpb_ior + {\bool_set_false:N\l_tmp_bool}} + {\ior_if_eof:NTF\g_tmpb_ior + {\bool_set_true:N\l_tmpa_bool + \bool_set_false:N\l_tmp_bool} + {\ior_get_str:NN + \g_tmpa_ior + \l_tmpa_tl + \ior_get_str:NN + \g_tmpb_ior + \l_tmpb_tl + \tl_if_eq:NNF + \l_tmpa_tl\l_tmpb_tl + {\bool_set_true:N\l_tmpa_bool + \bool_set_false:N\l_tmpb_bool} + }} + } + \ior_close:N\g_tmpa_ior + \ior_close:N\g_tmpb_ior} + \bool_if:NTF\l_tmpb_bool + {\group_end:\bool_set_true:N#1} + {\group_end:\bool_set_false:N#1} + } + +\cs_new_protected:Nn\kl_tl_to_file:nn + {\iow_open:Nn\g_tmpa_iow{#1} + \iow_now:Nn\g_tmpa_iow{#2} + \iow_close:N\g_tmpa_iow} +\ior_new:N\g_tmpa_ior +\ior_new:N\g_tmpb_ior +\iow_new:N\g_tmpa_iow +\iow_new:N\g_tmpb_iow +\cs_generate_variant:Nn\cs_gset_eq:NN{cN,cc} +\NewDocumentCommand\OverloadCommand{mmm} + {\exp_args:Nc\cs_gset_eq:NN{SUPER\cs_to_str:N#1}#1 + \exp_args:Nc\NewDocumentCommand{NEW\cs_to_str:N#1}{#2}{#3} + \cs_gset_eq:Nc#1{NEW\cs_to_str:N#1}} +\NewDocumentCommand\XparseArgs{mm} + {\kutils_reverting_args:Nn#1{#2}} +\DeclareExpandableDocumentCommand\ExpXparseArgs{mm} + {\kutils_exec_xreverting_args:Nn#1{#2}} +\cs_new:Nn\kutils_xrevert_arg_s:n + { \IfBooleanTF{#1}{*}{}} +\cs_new:Nn\kutils_xrevert_arg_o:n + { \IfValueTF{#1}{[\exp_not:n{#1}]}{}} +\cs_new:Nn\kutils_xrevert_arg_m:n + { {\exp_not:n{#1}} } +\cs_new:Nn\kutils_xrevert_arg_i:n + { } +\cs_new:Nn\kutils_reverting_args:Nn{ + \use:c{kutils_process_\tl_count:n{#2}:w} + #1{\kutils_exec_xreverting_args:n{#2}}} +\cs_new:Nn\kutils_exec_xreverting_args:n{ + \tl_if_empty:nTF{#1}{} + {\kutils_exec_xreverting_args_internal:w#1\kutils_end:}} +\cs_new:Nn\kutils_exec_xreverting_args:Nn{ + \exp_not:N#1 + \tl_if_empty:nTF{#2}{} + {\kutils_exec_xreverting_args_internal:w#2\kutils_end:}} +\cs_new:Npn\kutils_exec_xreverting_args_internal:w#1#2\kutils_end:#3 + { \use:c{kutils_xrevert_arg_#1:n}{#3} + \tl_if_empty:nTF{#2}{} + {\kutils_exec_xreverting_args_internal:w#2\kutils_end:}} +\cs_new:Nn\kutils_process_args:nn + {#1} +\cs_new:Nn\kutils_process_args:nnn + {\use:nx{#1}{#2{#3}}} +\cs_new:Nn\kutils_process_args:nnnn + {\use:nx{#1}{#2{#3}{#4}}} +\cs_new:Nn\kutils_process_args:nnnnn + {\use:nx{#1}{#2{#3}{#4}{#5}}} +\cs_new:Nn\kutils_process_args:nnnnnn + {\use:nx{#1}{#2{#3}{#4}{#5}{#6}}} +\cs_new:Nn\kutils_process_args:nnnnnnn + {\use:nx{#1}{#2{#3}{#4}{#5}{#6}{#7}}} +\cs_new:Nn\kutils_process_args:nnnnnnnn + {\use:nx{#1}{#2{#3}{#4}{#5}{#6}{#7}{#8}}} +\cs_new:Nn\kutils_process_args:nnnnnnnnn + {\use:nx{#1}{#2{#3}{#4}{#5}{#6}{#7}{#8}{#9}}} +\exp_args:Nc\let{kutils_process_0:w}\kutils_process_args:nn +\exp_args:Nc\let{kutils_process_1:w}\kutils_process_args:nnn +\exp_args:Nc\let{kutils_process_2:w}\kutils_process_args:nnnn +\exp_args:Nc\let{kutils_process_3:w}\kutils_process_args:nnnnn +\exp_args:Nc\let{kutils_process_4:w}\kutils_process_args:nnnnnn +\exp_args:Nc\let{kutils_process_5:w}\kutils_process_args:nnnnnnn +\exp_args:Nc\let{kutils_process_6:w}\kutils_process_args:nnnnnnnn +\exp_args:Nc\let{kutils_process_7:w}\kutils_process_args:nnnnnnnnn +\msg_new:nnn{scope}{LaTeX~obsolete} + {The~command~'#1'~is~deprecated.~ + See~documentation~for~a~replacement.} + +\cs_new:Nn\kutils_secure_latex_command:N + {\cs_new_eq:cN{LaTeX\cs_to_str:N#1}#1} + +\cs_new:Nn\kutils_latex_to_vault:N + {\kutils_secure_latex_command:N#1 + \cs_undefine:N#1} + +\cs_new:Nn\kutils_latex_to_obsolete:N + {\kutils_latex_to_vault:N#1 + \cs_new:Npx#1{\exp_not:N\msg_error:nnn{scope}{LaTeX~obsolete}{\string #1}}} + +\cs_new:Nn\kutils_secure_latex_command:n + {\tl_map_function:nN{#1}\kutils_secure_latex_command:N} +\cs_new:Nn\kutils_latex_to_vault:n + {\tl_map_function:nN{#1}\kutils_latex_to_vault:N} +\cs_new:Nn\kutils_latex_to_obsolete:n + {\tl_map_function:nN{#1}\kutils_latex_to_obsolete:N} +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{knowledge} + [2016/02/26 v2.0 first codes of the new version] +%%%%%%%%%% +\cs_set_eq:Nc\klparse_ifnextchar:NTF{@ifnextchar} + +\NewDocumentCommand\klparse_setnovalue{o} + {\tl_set:Nn\klparse_novalue_tl{#1}} +\klparse_setnovalue\relax + +\cs_new:Npn\klparse_if_novalue:NTF + {\tl_if_eq:NNTF\klparse_novalue_tl} +\cs_new:Nn\knowledge_info:n{\msg_info:nnn{knowledge}{knowledge~info}{#1}} +\cs_new:Nn\knowledge_warning:n{\msg_warning:nnn{knowledge}{knowledge~warning}{#1}} + +\msg_new:nnnn{knowledge}{knowledge~info}{#1}{#2} +\msg_new:nnnn{knowledge}{knowledge~warning}{#1}{#2} + +\cs_generate_variant:Nn\knowledge_info:n{x} +\cs_generate_variant:Nn\knowledge_warning:n{x} +\tl_new:N\knowledge_configuration_pending_tl +\tl_set:Nn\knowledge_configuration_pending_tl{} +\NewDocumentCommand\KnowledgePackageTrigger{mm} + { \keys_define:nn{ knowledge~package~options }{ #1 .code:n = {#2} } } +\NewDocumentCommand\KnowledgeConfigureBooleanOption{om}{ + \tl_set:Nn\l_tmpa_tl{#2} + \tl_remove_all:Nn\l_tmpa_tl{~} + \IfNoValueTF{#1} + {\bool_new:c{knowledge_configuration_#2_bool} + \exp_args:NcnV\knowledge_KnowledgeConfigureBooleanOption:Nnnnn + {knowledge_configuration_#2_bool}{#2}\l_tmpa_tl{}{}} + {\exp_args:NNnV\knowledge_KnowledgeConfigureBooleanOption:Nnnnn + #1{#2}\l_tmpa_tl{}{}} + } +\NewDocumentCommand\KnowledgeConfigureBooleanOptionTF{ommm}{ + \tl_set:Nn\l_tmpa_tl{#2} + \tl_remove_all:Nn\l_tmpa_tl{~} + \IfNoValueTF{#1} + {\bool_new:c{knowledge_configuration_#2_bool} + \exp_args:NcnV\knowledge_KnowledgeConfigureBooleanOption:Nnnnn + {knowledge_configuration_#2_bool}{#2}\l_tmpa_tl{#3}{#4}} + {\exp_args:NNnV\knowledge_KnowledgeConfigureBooleanOption:Nnnnn + #1{#2}\l_tmpa_tl{#3}{#4}} + } + +\cs_new:Nn\knowledge_KnowledgeConfigureBooleanOption:Nnnnn{ + \keys_define:nn{ knowledge~package~options }{ + #3 .choice:, + #3 / true .code:n = {\tl_put_right:Nn\knowledge_configuration_pending_tl{,#2=true}}, + #3 / false .code:n = {\tl_put_right:Nn\knowledge_configuration_pending_tl{,#2=false}}, + #3 .default:n = {true} + } + \keys_define:nn{ knowledge~configuration~options }{ + #2 .choice:, + #2 / true .code:n = {\bool_if:NF#1{\bool_set_true:N#1#4}}, + #2 / false .code:n = {\bool_if:NT#1{\bool_set_false:N#1#5}}, + #2 .default:n = {true} + }} + +\NewDocumentCommand\KnowledgePackageBooleanOption{om}{ + \tl_set:Nn\l_tmpa_tl{#2} + \tl_remove_all:Nn\l_tmpa_tl{~} + \IfNoValueTF{#1} + {\bool_new:c{knowledge_configuration_#2_bool} + \exp_args:NcnV\knowledge_KnowledgePackageBooleanOption:Nnn + {knowledge_configuration_#2_bool}{#2}\l_tmpa_tl} + {\exp_args:NNnV\knowledge_KnowledgePackageBooleanOption:Nnn + #1{#2}\l_tmpa_tl} + } +\cs_new:Nn\knowledge_KnowledgePackageBooleanOption:Nnn{ + \keys_define:nn{ knowledge~package~options }{ + #3 .choice:, + #3 / true .code:n = {\bool_set_true:N#1}, + #3 / false .code:n = {\bool_set_false:N#1}, + #3 .default:n = {true} + } + \keys_define:nn{ knowledge~configuration~options }{ + #2 .code:n = {\OPTION_CANNOT_BE_USED_IN_knowledgeconfigure} + }} + +\NewDocumentCommand\KnowledgeConfigureTrigger{omm}{ + \IfNoValueTF{#1} + {\tl_set:Nn\l_tmpa_tl{#2} + \tl_remove_all:Nn\l_tmpa_tl{~} + \exp_args:NNV\KnowledgeConfigureTrigger[\l_tmpa_tl]{#2}{#3}} + {\keys_define:nn { knowledge~configuration~options } + { #2 .code:n = {#3} } + \keys_define:nn { knowledge~package~options } + { #1 .code:n = {\tl_put_right:Nn\knowledge_configuration_pending_tl{,#2={##1}} }} + } +} +\NewDocumentCommand\KnowledgeConfigureOption{mm}{ + \keys_define:nn { knowledge~configuration~options } + { #1 .code:n = {#2} } +} +\NewDocumentCommand\knowledgeconfigure{m}{ + \keys_set:nn{ knowledge~configuration~options }{#1} +} +\bool_new:N\knowledge_configuration_quotation_bool +\KnowledgeConfigureBooleanOptionTF[\knowledge_configuration_quotation_bool]{quotation}{\klactivatequotation}{\kldeactivatequotation} +\KnowledgeConfigureOption{protect~quotation}{\kl_protect_environment_quotation:n{#1}} +\bool_new:N\knowledge_configuration_visibleAP_bool +\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~anchor~points}\KnowledgeConfigureBooleanOption[\knowledge_configuration_visibleAP_bool]{visible~AP} +\bool_new:N\knowledge_hyperlinks_active_bool +\bool_set_true:N\knowledge_hyperlinks_active_bool + +\tl_set:Nn\knowledge_option_mode_tl{} +\KnowledgePackageTrigger{ paper }{\tl_set:Nn\knowledge_option_mode_tl{paper}} +\KnowledgePackageTrigger{ electronic }{\tl_set:Nn\knowledge_option_mode_tl{electronic}} +\KnowledgePackageTrigger{ composition }{\tl_set:Nn\knowledge_option_mode_tl{composition}} +\KnowledgePackageTrigger{ final }{\tl_set:Nn\knowledge_option_mode_tl{final}} +\KnowledgeConfigureTrigger{ fix~hyperref~twocolumn } + {\knowledgeFixHyperrefTwocolumn} +\KnowledgeConfigureTrigger{ notion } + {\KnowledgeConfigureNotion} +\KnowledgeConfigureTrigger{ protect~links } + {\kl_kl_nesting_incr:} +\KnowledgeConfigureTrigger{ unprotect~links } + {\kl_kl_nesting_decr:} +\cs_new_eq:Nc\package_if_loaded:nTF{@ifpackageloaded} +\cs_new:Nn\knowledge_option_aci_test_loaded:n{ + \bool_new:c{knowledge_#1_active_bool} + \bool_new:c{knowledge_#1_syntax_bool} + \package_if_loaded:nTF{#1} + {\bool_set_true:c{knowledge_#1_active_bool} + \bool_set_true:c{knowledge_#1_syntax_bool}} + {\bool_set_false:c{knowledge_#1_active_bool} + \bool_set_false:c{knowledge_#1_syntax_bool}} +} +\knowledge_option_aci_test_loaded:n{hyperref} +\knowledge_option_aci_test_loaded:n{xcolor} +\knowledge_option_aci_test_loaded:n{makeidx} +\cs_new:Nn\knowledge_option_aci_define:n{ + \keys_define:nn{ knowledge~package~options } { + #1 .choice: , + #1 / active .code:n = { + \bool_set_true:c{knowledge_#1_active_bool} + \bool_set_true:c{knowledge_#1_syntax_bool}}, + #1 / compatibility .code:n = { + \bool_set_false:c{knowledge_#1_active_bool} + \bool_set_true:c{knowledge_#1_syntax_bool}}, + #1 / inactive .code:n = { + \bool_set_false:c{knowledge_#1_active_bool} + \bool_set_false:c{knowledge_#1_syntax_bool}}, + #1 .default:n = {active} + }} +\cs_new:Nn\knowledge_option_bool_new:nN{ + \keys_define:nn{ knowledge~package~options } { + #1 .choice: , + #1 / true .code:n = { \bool_gset_true:N#2 }, + #1 / false .code:n = { \bool_gset_false:N#2 }, + #1 .default:n = {true} + } +} +\cs_new:Nn\knowledge_option_bool_new:n + {\bool_new:c{knowledge_option_#1_bool} + \exp_args:Nnc\knowledge_option_bool_new:nN{#1}{knowledge_option_#1_bool}} +\cs_new:Nn\knowledge_option_aci_autoload:nn{ + \bool_if:cTF{knowledge_#1_active_bool} + {\package_if_loaded:nTF{#1}{} + {\RequirePackage[#2]{#1}}}{} +} +\knowledge_option_bool_new:n{scope} +\knowledge_option_aci_define:n{hyperref} +\knowledge_option_aci_define:n{xcolor} +\knowledge_option_aci_define:n{makeidx} +\ProcessKeysOptions{knowledge~package~options} +\tl_if_exist:NTF\knowledgepackagemode + {}{\tl_set:Nn\knowledgepackagemode{}} + +\tl_if_empty:NTF\knowledgepackagemode + {\tl_if_empty:NTF\knowledge_option_mode_tl + {\tl_set:Nn\knowledge_option_mode_tl{composition}} + {}} + {\tl_if_empty:NTF\knowledge_option_mode_tl + {\tl_set_eq:NN\knowledge_option_mode_tl\knowledgepackagemode} + {\knowledge_info:n{Knowledge~mode~overriden~by~user.} + \tl_set_eq:NN\knowledge_option_mode_tl\knowledgepackagemode + }} + +\bool_new:N\knowledge_option_composition_bool +\bool_set_false:N\knowledge_option_composition_bool +\bool_new:N\knowledge_option_electronic_bool +\bool_set_false:N\knowledge_option_electronic_bool +\bool_new:N\knowledge_option_paper_bool +\bool_set_false:N\knowledge_option_paper_bool + +\keys_define:nn{ knowledge~package~modes }{ + paper .code:n = { + \bool_set_true:N\knowledge_option_paper_bool + \bool_set_false:N\knowledge_configuration_visibleAP_bool + }, + electronic .code:n = { + \bool_set_true:N\knowledge_option_electronic_bool + \bool_set_false:N\knowledge_configuration_visibleAP_bool + }, + composition .code:n = { + \bool_set_true:N\knowledge_option_composition_bool + \bool_set_true:N\knowledge_configuration_visibleAP_bool + }, + final .code:n = { \knowledge_warning:x{Mode~`final`~is~deprecated,~ + and~should~be~replaced~by~mode~`paper`.} + \tl_set:Nn\knowledge_option_mode_tl{paper} + \keys_set:nn{knowledge~package~modes}{paper}}, + unknown .code:n = + {\knowledge_warning:x{Unknown~mode~`\l_keys_key_tl`.} + \tl_set:Nn\knowledge_option_mode_tl{ composition } + \keys_set:nV{ knowledge~package~modes }{ composition }} +} +\keys_set:nV{ knowledge~package~modes }\knowledge_option_mode_tl +\knowledge_option_aci_autoload:nn{ hyperref }{hidelinks} +\knowledge_option_aci_autoload:nn{ xcolor }{} +\knowledge_option_aci_autoload:nn{ makeidx }{} +\tl_gset:Nn\scope_tl{SC@PE:} +\tl_gset:Nn\scopept_tl{K@UX:} +\seq_new:N\scope_instances_stack_seq +\tl_new:N\scope_top_instance_tl +\tl_new:N\scope_top_area_tl +\cs_new:Nn\scope_area_create:n + {\group_begin: + \tl_set:Nx\self{\scope_tl.area[#1]} + % + \scope_category_add_area:nn{all}{#1} + % + \tl_gset:cn{\self.name_tl}{#1} + \seq_new:c{\self.category_seq} + \seq_gpush:cn{\self.category_seq}{all} + \seq_gpush:cn{\self.category_seq}{#1} + \bool_gset_false:c{\self.autoclose_bool} + \bool_gset_true:c{\self.multiple_bool} + \bool_gset_true:c{\self.attractsknowledge_bool} + \bool_gset_true:c{\self.acceptsknowledge_bool} + \tl_gset:cn{\self.pushcode_tl}{} + \tl_gset:cn{\self.popcode_tl}{} + \tl_gset:cn{\self.forces_tl}{} + \seq_new:c{\self.mandatorybase_seq} + \int_new:c{\self.count_int} + \int_gset:cn{\self.count_int}{0} + \int_new:c{\self.nesting_int} + \int_gset:cn{\self.nesting_int}{0} + % + \scope_category_if_exist:nTF{#1} + {}{\scope_category_create:n{#1} + \seq_gpush:cn{\scope_tl.category[#1].areas_seq}{#1}} + \group_end: +} +\cs_new:Npn\scope_area_if_exist:nTF#1 + {\tl_if_exist:cTF{\scope_tl.area[#1].name_tl}} +\cs_new:Npn\scope_area_if_in_scope:nTF#1 + {\int_compare:nNnTF + {\use:c{\scope_tl.area[#1].nesting_int}}>0} +\msg_new:nnn{scope}{area~exists}{Area~already~exists~'#1'.} +\msg_new:nnn{scope}{area~not~exist}{Area~does~not~exist~'#1'.} +\NewDocumentCommand\ScopeConfigure{mm} + {\scope_area_set:nn{#1}{#2}} +\cs_new:Nn\scope_area_set:nn + {\clist_map_inline:nn{#1} + {\scope_area_set_i:nn{##1}{#2}}} +\cs_new:Nn\scope_area_set_i:nn { + \scope_area_if_exist:nTF{#1} + {}{\scope_area_create:n{#1}} + \group_begin: + \tl_set:Nx\scope_area_tl{#1} + \tl_set:Nx\self{\scope_tl.area[\scope_area_tl]} + \keys_set:nn{ scope~area~set }{#2} + \group_end:} +\keys_define:nn{ scope~area~set } { + category .code:n = + {\clist_map_inline:nn{#1} + {\scope_category_ensure:n{##1} + \seq_gpush:cV + {\scope_tl.category[##1].areas_seq}\scope_area_tl + }}, + autoclose .choice:, + autoclose / false .code:n = + {\bool_gset_false:c{\self.autoclose_bool}}, + autoclose / true .code:n = + {\bool_gset_true:c{\self.autoclose_bool}}, + parents .code:n = + {\seq_gset_from_clist:cn{\self.mandatorybase_seq}{#1}}, + push~code .code:n = + {\tl_gput_right:cn{\self.pushcode_tl}{#1}}, + pop~code .code:n = + {\tl_gput_right:cn{\self.popcode_tl}{#1}}, + occurrences .choice:, + occurrences / once .code:n = + {\bool_gset_false:c{\self.multiple_bool} + \bool_gset_false:c{\self.recursive_bool}}, + occurrences / multiple .code:n = { + \bool_gset_true:c{\self.multiple_bool} + \bool_gset_false:c{\self.recursive_bool}}, + occurrences / recursive .code:n = { + \bool_gset_true:c{\self.multiple_bool} + \bool_gset_true:c{\self.recursive_bool}}, + knowledge .choice:, + knowledge / none .code:n = { + \bool_gset_false:c{\self.acceptsknowledge_bool} + \bool_gset_false:c{\self.attractsknowledge_bool}}, + knowledge / accepts .code:n = { + \bool_gset_true:c{\self.acceptsknowledge_bool} + \bool_gset_false:c{\self.attractsknowledge_bool}}, + knowledge / attracts .code:n = { + \bool_gset_true:c{\self.acceptsknowledge_bool} + \bool_gset_true:c{\self.attractsknowledge_bool}}, + forces .code:n = + {\tl_gset:cn{\self.forces_tl}{#1}} +} +\cs_new:Npn\scope_category_if_exist:nTF#1 + {\tl_if_exist:cTF{\scope_tl.category[#1].name_tl}} +\cs_new:Nn\scope_category_ensure:n + {\scope_category_if_exist:nTF + {#1}{}{\scope_category_create:n{#1}}} +\cs_new:Nn\scope_category_create:n + {\tl_gset:cn{\scope_tl.category[#1].name_tl}{#1} + \seq_new:c{\scope_tl.category[#1].areas_seq}} +\cs_new:Nn\scope_category_add_area:nn + {\scope_category_ensure:n{#1} + \seq_gpush:cn{\scope_tl.category[#1].areas_seq}{#2}} +\cs_new:Nn\scope_category_use:n + {\seq_use:cn{\scope_tl.category[#1].areas_seq},} +\cs_new:Nn\scope_category_show:n + {\seq_show:c{\scope_tl.category[#1].areas_seq}} +\cs_new:Npn\scope_instance_if_exist:nTF#1 + {\tl_if_exist:cTF{\scope_tl.instance[#1].area_tl}} +\cs_new:Npn\scopept_instance_if_exist:nTF#1 + {\tl_if_exist:cTF{\scopept_tl.instance[#1].area_tl}} +\cs_new:Npn\scopept_label_if_exist:nTF#1 + {\tl_if_exist:cTF{\scopept_tl.label[#1].instance_tl}} +\tl_new:N\scope_pushed_area_tl +\tl_new:N\scope_popped_area_tl +\msg_new:nnn{scope}{empty~pop} + {Attempt~to~pop~an~empty~area~stack.} +\msg_new:nnn{scope}{no~pushing~here} + {Not~allowed~to~open~'\scope_pushed_area_tl'~here.~ + Current~stack~is~<\seq_use:Nn\scope_instances_stack_seq{::}>.} +\msg_new:nnn{scope}{no~popping} + {Not~allowed~to~close~'\scope_popped_area_tl'.} +\msg_new:nnn{scope}{no~popping~here} + {Not~allowed~to~close~'\scope_popped_area_tl'~here~(at~'\scope_top_area_tl').} +\cs_new:Nn\scope_area_pop:n { + \tl_gset:Nn\scope_popped_area_tl{#1} + \bool_if:cTF{\scope_tl.area[\scope_popped_area_tl].autoclose_bool} + {\msg_error:nn{scope}{no~popping}} + {\scope_area_pop_i:}} +\cs_new:Nn\scope_area_pop_i: { + \tl_if_eq:NNTF\scope_top_area_tl\scope_popped_area_tl + {\scope_internal_pop:} + {\bool_if:cTF{\scope_tl.area[\scope_top_area_tl].autoclose_bool} + {\scope_internal_pop: + \scope_area_pop_i:} + {\msg_error:nn{scope}{no~popping~here}}}} +\cs_new:Nn\scope_internal_pop: { + \use:c{\scope_tl.area[\scope_top_area_tl].popcode_tl} + \seq_gpop:NNTF\scope_instances_stack_seq\scope_top_instance_tl + {\int_gdecr:c{\scope_tl.area[\scope_top_area_tl].nesting_int} + \exp_args:NV\knowledge_pop_visible_instances_to:n\scope_top_instance_tl + \seq_get:NN\scope_instances_stack_seq\scope_top_instance_tl + \tl_gset_eq:NN\scope_top_instance_tl\scope_top_instance_tl + \tl_gset:Nx\scope_top_area_tl + {\tl_use:c{\scope_tl.instance[\scope_top_instance_tl].area_tl}}} + {\msg_error:nnn{scope}{empty~pop}{}} + } +\cs_new:Nn\scope_area_push:n { + \tl_gset:Nn\scope_pushed_area_tl{#1} + \scope_area_push_i:n{#1}} +\cs_new:Nn\scope_area_push_i:n { + \tl_if_empty:cTF{\scope_tl.area[#1].forces_tl} + {} + {\exp_args:Nx\scope_area_if_in_scope:nTF + {\tl_use:c{\scope_tl.area[#1].forces_tl}} + {} + {\exp_args:Nx\scope_area_push_i:n + {\tl_use:c{\scope_tl.area[#1].forces_tl}}}} + \scope_area_push_ii:n{#1} +} +\cs_new:Npn\scope_if_area_in_areaclist:nnTF#1 + {\exp_args:NnV\clist_if_in:nnTF{#1}\scope_top_area_tl} + +\cs_new:Nn\scope_category_expand:n + {\clist_use:x{ + \clist_map:nN{#1}{ + \seq_use:c{\scope_tl.category[#1].areas_seq},}}} + +\cs_new:Nn\scope_categories_expand:n + {\clist_map_function:nN{#1}\scope_category_expand:n} + +\cs_new:Nn\scope_if_area_in_categoryclist:nnTF + {\group_begin: + \tl_set:Nx\l_tmpa_tl + {\clist_map_function:nN{#2}\scope_category_areas_use:n} + \bool_set_false:N\l_tmpa_bool + \clist_map_inline:nn{#2} + {\scope_category_areas_if_in:nnTF{##1}{#1} + {\bool_set_true:N\l_tmpa_bool\seq_map_break:}{}} + \bool_if:NTF\l_tmpa_bool + {\group_end:#3} + {\group_end:#4} + } + +\cs_new:Npn\scope_category_if_area_in:nnTF#1#2 + {\exp_args:Nnx\seq_if_in:cnTF + {\scope_tl.category[#1].areas_seq}{#2}} + +\cs_new:Nn\scope_categoryseq_if_area_in:NnTF + { \seq_if_empty:NTF#1 + {#3} + {\group_begin: + \bool_set_false:N\l_tmpa_bool + \seq_map_inline:Nn#1 + {\seq_if_in:cnTF{\scope_tl.category[##1].areas_seq}{#2} + {\bool_set_true:N\l_tmpa_bool\seq_map_break:}{}} + \bool_if:NTF\l_tmpa_bool + {\group_end:#3} + {\group_end:#4} + }} + +\cs_new:Npn\scope_area_mandatorybase_if_area_in:nnTF#1 + {\exp_args:Nc\scope_categoryseq_if_area_in:NnTF + {\scope_tl.area[#1].mandatorybase_seq}} + +\cs_new:Nn\scope_categoryseq_pop_to:N + {\exp_args:NNx\scope_categoryseq_if_area_in:NnTF#1{\scope_top_area_tl} + {}{\scope_auto_pop:\scope_categoryseq_pop_to:N#1}} + +\cs_new:Nn\scope_categoryseq_pop_to:n + {\group_begin: + \seq_set_from_clist:Nn\l_tmpa_seq{#1} + \scope_categoryseq_pop_to:N\l_tmpa_seq + \group_end:} + +\cs_new:Nn\scope_area_push_ii:n { + \seq_if_empty:cTF{\scope_tl.area[#1].mandatorybase_seq} + {\scope_internal_push:n{#1}} + {\exp_args:Nnx\use:n + {\scope_area_mandatorybase_if_area_in:nnTF{#1}} + {\scope_top_area_tl} + {\scope_internal_push:n{#1}} + {\scope_auto_pop: + \scope_area_push_ii:n{#1}}} + } +\cs_new:Nn\scope_internal_push:n { + \tl_gset:Nn\scope_top_area_tl{#1} + \int_gincr:c{\scope_tl.area[\scope_top_area_tl].nesting_int} + \int_gincr:c{\scope_tl.area[\scope_top_area_tl].count_int} + % storing the previous top instance + \tl_set_eq:NN\l_tmpa_tl\scope_top_instance_tl + %naming the new instance + \bool_if:cTF{\scope_tl.area[\scope_top_area_tl].multiple_bool} + {\tl_gset:Nx\scope_top_instance_tl + {\scope_top_area_tl-\int_to_arabic:n{\int_use:c{\scope_tl.area[\scope_top_area_tl].count_int}}}} + {\tl_gset_eq:NN\scope_top_instance_tl\scope_top_area_tl} + % + \exp_args:Nx\knowledge_push_visible_instance:n{\scope_top_instance_tl} + \seq_push:Nx\scope_instances_stack_seq{\scope_top_instance_tl} + % + \tl_gset:cx + {\scope_tl.instance[\scope_top_instance_tl].area_tl} + {\scope_top_area_tl} + \tl_gset:cx + {\scope_tl.instance[\scope_top_instance_tl].parent_tl} + {\l_tmpa_tl} + % + \seq_if_exist:cTF{\scopept_tl.instance[\l_tmpa_tl].context_seq} + {\seq_set_eq:Nc\l_tmpa_seq{\scopept_tl.instance[\l_tmpa_tl].context_seq}} + {\seq_clear_new:N\l_tmpa_seq} + \exp_args:NNx\seq_gpush:Nn + \l_tmpa_seq{\scope_top_instance_tl} + \seq_gset_eq:cN + {\scopept_tl.instance[\scope_top_instance_tl].context_seq} + \l_tmpa_seq + % + \KAuxWriteX + {\KAuxScopeNewInstance{\scope_top_area_tl}{\scope_top_instance_tl}{\l_tmpa_tl}} + % + \tl_use:c{\scope_tl.area[\scope_top_area_tl].pushcode_tl} +} +\cs_new:Nn\scope_auto_pop: { + \bool_if:cTF{\scope_tl.area[\scope_top_area_tl].autoclose_bool} + {\scope_internal_pop:} + {\msg_error:nn{scope}{no~pushing~here}} + } +\cs_new:Nn\scope_get_attractive_instance:N +{\tl_set:Nn#1{base} + \seq_map_inline:Nn\scope_instances_stack_seq + {\bool_if:cTF + {\scope_tl.area[\tl_use:c{\scope_tl.instance[##1].area_tl}].attractsknowledge_bool} + {\tl_set:Nn#1{##1}\seq_map_break:}{}} +} +\bool_new:N\scopept_map_break_bool +\cs_new:Nn\scopept_map_break: + {\bool_set_true:N\scopept_map_break_bool} + +\cs_new:Nn\scopept_map_instance_ancestors:nN + {\bool_set_false:N\scopept_map_break_bool + \scope_map_instance_ancestors_i:nN{#1}#2 + } +\cs_new:Nn\scopept_map_instance_ancestors_i:nN +{ \tl_if_empty:nTF{#1} + {} + {\scopept_instance_if_exist:nTF{#1}{ + #2{#1} + \bool_if:NTF\scopept_map_break_bool + {} + {\exp_args:Nx\scopept_map_instance_ancestors_i:nN + {\scopept_instance_parent_at:Nn\tl_use:N{#1}}#2}} + {}}} +\cs_new:Nn\scopept_map_instances_seq_ancestors:NN + {\seq_map_inline:Nn#1 + {\scopept_map_instance_ancestors_i:nN{##1}#2 + \bool_if:NTF\scopept_map_break_bool:{\seq_map_break:}{}} +} +\NewDocumentCommand\scopeLabel{m} + { \kl_hide_begin: + \scope_get_attractive_instance:N\l_tmpb_tl + \KAuxWriteX*{\exp_not:n{\KAuxScopeLabel{#1}}{\l_tmpb_tl}} + \kl_hide_end: + \cs_if_exist:NTF\LaTeXlabel\LaTeXlabel\use_none:n{#1}} +\let\label\scopeLabel +\NewKAuxCommand\KAuxScopeNewInstance{mmm} + {Package~scope:~Declares~a~new~instance~of~a~scope.} +\DeclareKAuxPhaseCommand\KAuxScopeNewInstance{init} + {\tl_gset:cn{\scopept_tl.instance[#2].area_tl}{#1} + \tl_gset:cn{\scopept_tl.instance[#2].parent_tl}{#3}} +\NewKAuxCommand\KAuxScopeLabel{mm} + {Package~scope:~Links~a~label~to~the~scope~of~its~definition.} +\DeclareKAuxPhaseCommand\KAuxScopeLabel{init} + {\tl_gset:cn{\scopept_tl.label[#1].instance_tl}{#2}} +\cs_new:Npn\scopept_label_instance_if_exist:nTF#1 + {\tl_if_exist:cTF{\scopept_tl.label[#1].instance_tl}} +\cs_new:Nn\scopept_label_instance_use:n + {\tl_use:c{\scopept_tl.label[#1].instance_tl}} +\NewDocumentCommand\ScopeHackEnvironments{} + { %\ScopeActivate + \scope_area_push:n{document} + \kutils_secure_latex_command:N\begin + \global\let\SUPERbegin\begin + \global\def\begin##1 + {\scope_area_if_exist:nTF{##1} + {\scope_area_push:n{##1}}{} + \SUPERbegin{##1}} + \kutils_secure_latex_command:N\end + \global\let\SUPERend\end + \global\def\end##1 + {\SUPERend{##1} + \scope_area_if_exist:nTF{##1} + {\scope_area_pop:n{##1}} + {}} + \kutils_secure_latex_command:N\label + \let\label\scopeLabel +} +\NewDocumentCommand\ScopeActivate{}{ + \scope_internal_push:n{base} + \cs_gset_eq:NN\ScopeActivate\relax +} +\AtBeginDocument{\ScopeActivate} +\scope_area_set:nn{knowledge~context~internal} +{ + occurrences = recursive, + autoclose = false, + parents= {base,all}, + knowledge=attracts +} +\scope_area_set:nn{knowledge~import~internal} +{ + occurrences = recursive, + autoclose = false, + parents= {base,all}, + knowledge = accepts +} +\NewDocumentEnvironment{knowledge~import}{m} + {\ScopeActivate\scope_area_push:n{knowledge~import~internal} + \clist_map_inline:nn{#1}{\knowledgeimport{##1}}} + {\scope_area_pop:n{knowledge~import~internal}} +\NewDocumentEnvironment{knowledge~context}{m} + {\ScopeActivate\scope_area_push:n{knowledge~context~internal} + \scopeLabel{#1}} + {\scope_area_pop:n{knowledge~context~internal}} +\NewDocumentCommand\knowledgescopingenvironment{>{\SplitList{,}} m} + { \cs_set:Nn\l_tmpa_cs:n + {\scope_area_set:nn{##1} + {autoclose=false, + occurrences=recursive, + knowledge=attracts, + parents=all}} + \ProcessList{#1}\l_tmpa_cs:n +} +\AtBeginDocument{\ScopeHackEnvironments} +\AtEndDocument{\scope_area_pop:n{document}} +\cs_new:Nn\knowledge_scope_default:{ + \scope_area_set:nn{base} + {occurrences = once, + autoclose = false} + \scope_area_set:nn{document} + {autoclose = false, + occurrences = once, + parents = base} + \scope_area_set:nn{body} + {autoclose = true, + occurrences = once, + parents = document} + \scope_area_set:nn + {base,document}{knowledge=accepts} + \scope_area_set:nn + {base,document}{knowledge=attracts} + \scope_area_set:nn + {body}{knowledge=none} + % + \newenvironment{scope} + {\mode_if_preamble:TF{\scope_area_push:n{scope}}{}} + {\mode_if_preamble:TF{\scope_area_pop:n{scope}}{}} + \knowledgescopingenvironment{scope} +} +\knowledge_scope_default: +\KAuxBefore{\KAuxProcess{init}} +\KAuxInit{} +\KAuxAfter{\KnowledgeDiagnoseOutput} +\iow_new:N\knowledge_diagnosefile_iow +\cs_new:Nn\knowledge_diagnose:n + {\iow_now:Nn\knowledge_diagnosefile_iow{#1}} +\cs_generate_variant:Nn\knowledge_diagnose:n{x} + +\NewDocumentCommand\KnowledgeDiagnoseOutput{}{ + \iow_open:Nn\knowledge_diagnosefile_iow{\c_job_name_tl.diagnose} + % compute first the list of warnings and important information + \KAuxProcess{diagnose~digest} + % + \knowledge_diagnose:n{***********} + \knowledge_diagnose:n{*~Summary~*} + \knowledge_diagnose:n{***********} + \knowledge_diagnose:n{} + \knowledge_diagnose:x{\int_use:N\kl_digest_unknownknowledge_int\space undefined~knowledge(s).} + \knowledge_diagnose:x{\int_use:N\kl_digest_autoreftwiceintro_int\space autoreference(s)~are~introduced~twice.} + \knowledge_diagnose:x{\int_use:N\kl_digest_autorefnointro_int\space autoreference(s)~are~used~but~not~introduced.} + \knowledge_diagnose:n{} + \knowledge_diagnose:x{\int_use:N\kl_digest_autorefused_int\space autoreference(s)~are~properly~used.} + \knowledge_diagnose:x{\int_use:N\kl_digest_autorefunused_int\space autoreference(s)~are~defined~but~not~used.} + \knowledge_diagnose:n{} + \knowledge_diagnose:n{} + % + \int_compare:nNnT\kl_digest_unknownknowledge_int>0{ + \knowledge_diagnose:n{************************} + \knowledge_diagnose:n{*~Undefined~knowledges~*} + \knowledge_diagnose:n{************************} + \knowledge_diagnose:n{} + \KAuxProcess{diagnose-unknown-suggest} + \knowledge_diagnose:n{} + \knowledge_diagnose:n{}} + % + \int_compare:nNnT\kl_digest_autoreftwiceintro_int>0{ + \knowledge_diagnose:n{****************************} + \knowledge_diagnose:n{*~Autoref~introduced~twice~*} + \knowledge_diagnose:n{****************************} + \knowledge_diagnose:n{} + \KAuxProcess{autoref~introduced~twice} + \knowledge_diagnose:n{} + \knowledge_diagnose:n{}} + % + \int_compare:nNnT\kl_digest_autorefnointro_int>0{ + \knowledge_diagnose:n{******************************} + \knowledge_diagnose:n{*~Autoref~used~without~intro~*} + \knowledge_diagnose:n{******************************} + \knowledge_diagnose:n{} + \KAuxProcess{autoref~not~introduced} + \knowledge_diagnose:n{} + \knowledge_diagnose:n{}} + % + \iffalse + \knowledge_diagnose:n{***********************} + \knowledge_diagnose:n{*~Exported~knowledges~*} + \knowledge_diagnose:n{***********************} + \knowledge_diagnose:n{} + \KAuxProcess{diagnose-export} + \knowledge_diagnose:n{} + \fi% + \iow_close:N\knowledge_diagnosefile_iow +} +\tl_set:Nn\knowledge_knowledge_default_namespace_tl {default} +\makeatother +\cell_new_type:nnn{knowledge}{nnnn}{KL@#2@#3@\detokenize{#4}_#1} +\cell_new_type:nnn{knowledge}{nnn}{\knowledge_id:nnnn{}{#1}{#2}{#3}} +\cs_generate_variant:Nn\knowledge_id:nnn{nnV,nVV,nVn} +\cs_generate_variant:Nn\knowledge_at:Nnnn{NnnV} +\cs_new:Npn\knowledge_at:c{\exp_args:Nc\knowledge_at:N} +\cs_new:Nn\knowledge_sets_to:nnn + {\cs_set:Nx\knowledge_at:N + {##1\exp_not:c{\knowledge_id:nnn{#1}{#2}{#3}}}} +\tuple_new:n{ktuple} +\NewDocumentCommand\NewKnowledgeParamBool{smm}{ + \ktuple_new_bool_index:n{#2} + \use:c{ktuple_#2_expands_to:TF} + {\bool_set_true:N#3}{\bool_set_false:N#3} + % + \keys_define:nn { knowledgenow~directives }{ + #2 .choice:, + #2 / false .code:n = + { \knowledge_at:c{ktuple_#2_gset_false:N}}, + #2 / true .code:n = + { \knowledge_at:c{ktuple_#2_gset_true:N} }, + #2 / default .code:n = + { \knowledge_at:c{ktuple_#2_gdel:N}}, + #2 .default:n = {true} + } + \IfBooleanTF{#1}{\KnowledgeTransferBool{#2}}{} +} +\NewDocumentCommand\KnowledgeTransferBool{m}{ + \clist_map_inline:nn{ #1 }{ + \keys_define:nn { knowledge~directives }{ + ##1 .choice:, + ##1 / false .code:n = { \knowledge_delay_directive:n{##1= false}}, + ##1 / true .code:n = { \knowledge_delay_directive:n{##1= true}}, + ##1 / default .code:n = { \knowledge_delay_directive:n{##1= default}}, + ##1 .default:n = true + }} +} +\NewDocumentCommand\NewKnowledgeParamTl{smm}{ + \ktuple_new_tl_index:n{#2} + \use:c{ktuple_#2_expands_to:n} + {\tl_set:Nn#3{##1}} + % + \keys_define:nn { knowledgenow~directives }{ + #2 .code:n = + { \knowledge_at:c{ktuple_#2_gset:Nn}{##1} }, + #2~X .code:n = + { \knowledge_at:c{ktuple_#2_gset:Nx}{##1} }, + no~#2 .code:n = + { \knowledge_at:c{ktuple_#2_gdel:N} }} + \IfBooleanTF{#1}{\KnowledgeTransferTl{#2}}{} +} +\NewDocumentCommand\KnowledgeTransferTl{m} + {\keys_define:nn { knowledge~directives } + {#1 .code:n = {\knowledge_delay_directive:n{#1={##1}}}}} +\NewDocumentCommand\NewKnowledgeParamCode{mm}{ + \ktuple_new_tl_index:n{#1} + \use:c{ktuple_#1_expands_to:n} + {\tl_set:Nn#2{##1}} + % + \keys_define:nn { knowledgenow~directives }{ + #1 .code:n = + { \knowledge_at:c + {ktuple_#1_gset:Nn}{##1} }, + #1+ .code:n = + { \knowledge_at:c + {ktuple_#1_gput_right:Nn}{##1} }, + +#1 .code:n = + { \knowledge_at:c + {ktuple_#1_gput_left:Nn}{##1} } +}} +\NewDocumentCommand\NewKnowledgeParamPackageError{mm} +{ \clist_map_inline:nn{#1}{ + \keys_define:nn { knowledge~directives }{ + ##1 .code:n = { + \msg_error:nnnn{ knowledge }{ package~required }{##1}{#2}} + }}} +\msg_new:nnn{ knowledge }{ package~required } + {In~order~to~use~directive~'#1',~please~load~package~or~use~option~'#2'.} +\tl_new:N\knowledge_current_instance_tl +\tl_gset:Nn\knowledge_current_instance_tl{base} +\seq_new:N\knowledge_visible_instances_seq +\cs_new:Nn\knowledge_push_visible_instance:n + {\seq_gpush:Nn\knowledge_visible_instances_seq{#1}} +\cs_new:Npn\knowledge_pop_visible_instance: + {\seq_gpop:NN\knowledge_visible_instances_seq\g_tmpa_tl} +\cs_new:Nn\knowledge_pop_visible_instances_to:n + {\seq_gpop:NNTF\knowledge_visible_instances_seq\g_tmpa_tl + {\exp_args:NV\tl_if_eq:nnTF\g_tmpa_tl{#1} + {} + {\knowledge_pop_visible_instances_to:n{#1}}} + {\INTERNAL_ERROR_EMPTY_POP_VISIBLE}} +\cs_new:Nn\knowledge_show_visible_instances: + {\tl_show:x + {Visible~instances~<\seq_use:Nn\knowledge_visible_instances_seq{,}>}} +\cs_new:Nn\knowledge_import_instance:n + {\seq_if_in:NnTF\knowledge_visible_instances_seq{#1} + {}{\knowledge_push_visible_instance:n{#1}}} +\NewDocumentCommand\knowledgeimport{m} + {\kl_hide_begin: + \scopept_label_instance_if_exist:nTF{#1} + {\exp_args:Nx\knowledge_import_instance:n{\scopept_label_instance_use:n{#1}}} + {} + \kl_hide_end: +} +\cs_if_exist:NTF\knowledge_track_instance:n{} + {\cs_new:Nn\knowledge_track_instance:n{base}} +\keys_define:nn { knowledge~directives } { + namespace .code:n = { \tl_set:Nn\knowledge_knowledge_namespace_tl{#1} }, + force .choice:, + force / false .code:n = {\bool_set_false:N\knowledge_knowledge_force_bool}, + force / true .code:n = {\bool_set_true:N\knowledge_knowledge_force_bool}, + force .default:n = false, + clear .choice:, + clear / false .code:n = {\bool_set_false:N\knowledge_knowledge_clear_bool}, + clear / true .code:n = {\bool_set_true:N\knowledge_knowledge_clear_bool}, + clear .default:n = false, + export .choice:, + export / false .code:n = {\bool_set_false:N\knowledge_knowledge_export_bool}, + export / true .code:n = {\bool_set_true:N\knowledge_knowledge_export_bool}, + export .default:n = false, + instance .code:n = + { \tl_set:Nn\knowledge_knowledge_instance_tl{#1} }, + scope .code:n = + { \tl_set:Nx\knowledge_knowledge_instance_tl{\knowledge_track_instance:n{#1}}}, + synonym .code:n = + { \exp_args:Nnx\keys_set:nn { knowledge~directives } + {link={\exp_not:o\knowledge_knowledge_synonym_tl}}} +} +\msg_new:nnn{ knowledge }{ knowledge~exists } + { The~knowledge~'#1'~in~scope~'#2'~(namespace~'#3')~already~exists. } +\NewKAuxCommand\KAuxKnowledge{mmmm} + {Package~knowledge:~Declares~a~knowledge.~ + Takes~the~{namespace}{instance}{knowledge}{directives}.} +\DeclareKAuxPhaseCommand\KAuxKnowledge{init} + {\knowledge_set_now:nnnn{#1}{#2}{#3}{#4}} +\NewKAuxCommand\KAuxExport{mmmm} + {Package~knowledge:~undefined~so~far.} +\cs_new:Nn\knowledge_set_now:nnnn + {\knowledge_sets_to:nnn{#1}{#2}{#3} + \tl_set:Nn\knowledge_set_now_k_tl{{#1}{#2}{#3}} + \knowledge_at:N\ktuple_if_exist:NTF + {\bool_if:NTF\knowledge_knowledgestyle_bool + {\knowledge_at:N\ktuple_gclear:N} + {\tl_show:n{knowledge~'#3'~(namespace=#1,~scope=#2)~is~redefined.}}} + {\knowledge_at:N\ktuple_new:N} + \keys_set:nn { knowledgenow~directives } { #4 } +} +\cs_generate_variant:Nn\knowledge_set_now:nnnn{nnVn} +\NewDocumentCommand\knowledge{} + {\KAuxWriteLocation\knowledge_II} +\NewDocumentCommand\knowledge_II{m >{\SplitList{|}}o m } +{ \kl_hide_begin: + \group_begin: + \tl_set_eq:NN\knowledge_namespace_tl + \knowledge_knowledge_default_namespace_tl + % + \bool_gset_false:N\knowledge_knowledge_is_synonym_bool + % + \use:x{ + \exp_not:n{\knowledge_knowledge_process:nn{#1}} + {\exp_not:V\kl_knowledgedefault_tl,\exp_not:n{#3}}} + % + % if synonym, then the synonym name is unchanged + \bool_if:NF\knowledge_knowledge_is_synonym_bool + {\tl_gset:Nn\knowledge_knowledge_synonym_tl{#1}} + % + \IfNoValueTF{#2}{}{ + \cs_set:Nn\l_tmpa_cs:n + {\knowledge_knowledge_process:nn{##1}{link={#1}}} + \ProcessList{#2}\l_tmpa_cs:n + } + \group_end: + \kl_hide_end: +} +\bool_new:N\knowledge_knowledge_is_synonym_bool +\tl_new:N\knowledge_knowledge_synonym_tl +\bool_new:N\knowledge_knowledgestyle_bool +\NewDocumentCommand\knowledgestyle{ s m m } +{ \kl_hide_begin: + \group_begin: + \tl_set:Nn\knowledge_namespace_tl{style} + % + \bool_set_true:N\knowledge_knowledgestyle_bool + % + \knowledge_knowledge_process:nn{#2}{#3} + \group_end: + \kl_hide_end: +} +\cs_new:Nn\knowledge_knowledge_process:nn +{ \bool_set_false:N\knowledge_knowledge_now_bool + \bool_set_false:N\knowledge_knowledge_clear_bool + \bool_set_false:N\knowledge_knowledge_force_bool + \bool_set_false:N\knowledge_knowledge_export_bool + % + \tl_set:Nn\knowledge_key_tl{#1} + % + \tl_set_eq:NN\knowledge_knowledge_namespace_tl\knowledge_namespace_tl + \scope_get_attractive_instance:N\knowledge_knowledge_instance_tl + % + \tl_set:Nn\knowledge_directives_tl{} + % + \keys_set:nn { knowledge~directives } { #2 } + % + \mode_if_preamble:TF + {\bool_set_true:N\knowledge_knowledge_now_bool} + {} + \bool_if:NTF\knowledge_knowledge_now_bool + {\use:x{ + \exp_not:N\knowledge_set_now:nnnn + {\knowledge_knowledge_namespace_tl} + {\knowledge_knowledge_instance_tl} + {\exp_not:V\knowledge_key_tl} + {\exp_not:V\knowledge_directives_tl}} + } { + \KAuxWriteX*{ + \exp_not:N\KAuxKnowledge + {\knowledge_knowledge_namespace_tl} + {\knowledge_knowledge_instance_tl} + {\exp_not:V\knowledge_key_tl} + {\exp_not:V\knowledge_directives_tl}} + } + \bool_if:NT\knowledge_knowledge_export_bool + {\KAuxWriteX*{ + \exp_not:N\KAuxExport + {\knowledge_knowledge_namespace_tl} + {\knowledge_knowledge_instance_tl} + {\exp_not:V\knowledge_key_tl} + {\exp_not:V\knowledge_directives_tl}} + } +} +\cs_new:Nn\knowledge_delay_directive:n + {\tl_if_empty:NTF\knowledge_directives_tl + {\tl_set:Nn\knowledge_directives_tl{#1}} + {\tl_put_right:Nn\knowledge_directives_tl{,#1}}} +\cs_generate_variant:Nn\knowledge_delay_directive:n{x} +\NewDocumentCommand\knowledgedirective{mom}{ + \kl_hide_begin: + \cs_new:cn + {knowledgedirective_#1:n} + {\keys_set:nn{ knowledge~directives }{#3}} + \keys_define:nn{ knowledge~directives } + {#1 .code:n = {\use:c{knowledgedirective_#1:n}{##1}}} + \IfNoValueF{#2} + {\keys_define:nn{ knowledge~directives }{#1 .default:n = {#2}}} + \kl_hide_end: +} +\tl_new:N\kl_knowledgedefault_tl +\NewDocumentCommand\knowledgedefault{sm}{ + \kl_hide_begin: + \IfBooleanTF{#1} + {\tl_put_right:Nn\kl_knowledgedefault_tl{,#2}} + {\tl_set:Nn\kl_knowledgedefault_tl{#2}} + \kl_hide_end: +} +\int_const:Nn\knowledge_kl_max_recursion_int{40} +\int_new:N\knowledge_kl_recursion_int +\cs_new:Nn\kl_base:nn{ + \tl_set:Nn\knowledge_kl_text_tl{#2} + \IfNoValueTF{#1} + {\tl_set:Nn\knowledge_kl_base_key_tl{#2}} + {\tl_set:Nn\knowledge_kl_base_key_tl{#1}} + % + \tl_set_eq:NN\knowledge_kl_key_tl\knowledge_kl_base_key_tl + % + \int_set_eq:NN\knowledge_kl_recursion_int\knowledge_kl_max_recursion_int + % + \knowledge_kl_find: +} +\cs_new:Nn\knowledge_kl_find: +{ + \int_decr:N\knowledge_kl_recursion_int + \tl_clear:N\knowledge_kl_link_tl + \tl_clear:N\knowledge_kl_style_tl + \tl_clear:N\knowledge_kl_intro_style_tl + \int_compare:nNnTF\knowledge_kl_recursion_int=0 + {\knowledge_kl_error_recursion:} + {\knowledge_kl_find_in_scope:VNTF + \knowledge_kl_key_tl\knowledge_kl_instance_tl + {\exp_args:Nc\knowledge_kl_exec:N + {\knowledge_id:nnV + \knowledge_kl_namespace_tl + \knowledge_kl_instance_tl + \knowledge_kl_key_tl}} + {\knowledge_kl_error_unknown:} + } +} +\cs_new:Npn\knowledge_kl_find_in_scope:nNTF{ + \exp_args:NV\knowledge_kl_find_in_scope:nnNTF + \knowledge_kl_namespace_tl +} +\cs_new:Nn\knowledge_kl_find_in_scope:nnNTF{ + \group_begin: + \tl_set:Nn\l_tmpa_tl{#1} + \tl_set:Nn\l_tmpb_tl{#2} + \bool_gset_false:N\g_tmpa_bool + \seq_map_function:NN + \knowledge_visible_instances_seq + \knowledge_kl_find_in_scope_test:n + \group_end: + \bool_if:NTF\g_tmpa_bool + {\tl_set_eq:NN#3\g_tmpa_tl #4} + {#5} +} +\cs_new:Nn\knowledge_kl_find_in_scope_test:n{ + \exp_args:Nc\ktuple_if_exist:NTF + {\knowledge_id:nnV{\l_tmpa_tl}{#1}\l_tmpb_tl} + {\bool_gset_true:N\g_tmpa_bool + \tl_gset:Nn\g_tmpa_tl{#1} + \seq_map_break:}{}} +\cs_generate_variant:Nn\knowledge_kl_find_in_scope:nnNTF{nVNTF} +\cs_generate_variant:Nn\knowledge_kl_find_in_scope:nNTF{VNTF} +\cs_new:Nn\knowledge_kl_use_style:n{ + \knowledge_kl_find_in_scope:nnNTF + {style} + {#1} + \l_tmpa_tl + {\use:c{\knowledge_id:nVn{style}\l_tmpa_tl{#1}}} + {\tl_show:n{ERROR-UNKNOWN-STYLE:~#1}} +} +\cs_generate_variant:Nn\knowledge_kl_use_style:n {x} + +\cs_new:Nn\knowledge_kl_exec:N{ + #1 + \tl_set:Nn\knowledge_kl_resource_tl{#1} + \tl_if_empty:xTF\knowledge_kl_used_style_tl + {} + {\knowledge_kl_use_style:x + {\knowledge_kl_used_style_tl}} + \tl_if_exist_ne:NTF\knowledge_kl_link_tl{ + \knowledge_kl_update:N#1 + \tl_set_eq:NN + \knowledge_kl_key_tl + \knowledge_kl_link_tl + \tl_set:Nn\knowledge_kl_link_tl{} + \knowledge_kl_find: + }{ + \knowledge_kl_update:N#1 + \knowledge_kl_display_code: +}} +\NewKAuxCommand\KAuxErrorKnowledgeUnknown{mmmm} + {Package~'knowledge':~A~knowledge~is~not~defined.~ + {namespace}{scope}{undefined~knowledge}{base~knowledge}} + {} + +\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose-unknown-suggest} + {\knowledge_diagnose:n + {\knowledge{#3}{}}} + +\cs_new:Nn\knowledge_kl_error_unknown: + {\KAuxWriteX{ + \KAuxErrorKnowledgeUnknown + {\knowledge_kl_namespace_tl} + {} + {\exp_args:NV\detokenize\knowledge_kl_key_tl} + {\exp_args:NV\detokenize\knowledge_kl_base_key_tl} + } + \knowledge_kl_use_style:n{unknown} + \knowledge_set_now:nnVn + {default}{base} + \knowledge_kl_key_tl + {style={unknown~(cont)}} + \msg_warning:nnxxx{ knowledge }{ knowledge~unknown } + {\exp_not:V\knowledge_kl_key_tl} + {\exp_not:V\knowledge_kl_namespace_tl} + {\seq_use:Nn\knowledge_visible_instances_seq{~|~}} + \knowledge_kl_display_code: +} + +\msg_new:nnn{ knowledge }{ knowledge~unknown } + {The~knowledge~'#1'~(namespace~'#2')~could~not~be~found~in~scopes~<~#3~>.} +\NewKAuxCommand\KAuxErrorKnowledgeRecursive{mmmm} + {Package~'knowledge':~A~knowledge~has~recursive~definition.~ + {namespace}{scope}{undefined~knowledge}{base~knowledge}} + {} + +\msg_new:nnn{ knowledge }{ knowledge~recursion } + { The~knowledges~are~probably~cyclic,~starting~from~'#1'~(namespace~'#2'),~ + currently~at~'#3'.} + +\cs_new:Nn\knowledge_kl_error_recursion: { + \msg_error:nnxxx{ knowledge }{ knowledge~recursion } + {\exp_not:V\knowledge_kl_base_key_tl} + {\exp_not:V\knowledge_kl_namespace_tl} + {\exp_not:V\knowledge_kl_key_tl} + \knowledge_kl_error_display:n{recursive~knowledge} +} + +\cs_new:Nn\knowledge_kl_error_display:n + {\textcolor{orange}{\exp_args:NV\detokenize\knowledge_kl_text_tl}} +\NewDocumentCommand\intro{s}{ + \cs_gset_eq:NN\knowledge_kl_init:\knowledge_intro_init: + \IfBooleanF{#1}\kl +} +\NewDocumentCommand\reintro{s}{ + \cs_gset_eq:NN\knowledge_kl_init:\knowledge_reintro_init: + \IfBooleanF{#1}\kl +} +\NewDocumentCommand\phantomintro{m}{ + \cs_gset_eq:NN\knowledge_kl_init:\knowledge_phantomintro_init: + \kl[{#1}]{} +} +\let\nointro\phantomintro +\cs_new:Nn\knowledge_intro_init: + {\tl_set:Nn + \knowledge_kl_command_tl{intro} + \cs_set_eq:NN + \knowledge_kl_update:N + \knowledge_intro_update:N + \cs_set_eq:NN + \knowledge_kl_display_code_preprocess: + \knowledge_intro_display_code_preprocess: + \tl_set:Nn + \knowledge_kl_used_style_tl + {\knowledge_kl_intro_style_tl} + } +\cs_new:Nn\knowledge_phantomintro_init: + {\tl_set:Nn + \knowledge_kl_command_tl{phantomintro} + \cs_set_eq:NN + \knowledge_kl_update:N + \knowledge_intro_update:N + \cs_set_eq:NN + \knowledge_kl_display_code_preprocess: + \knowledge_intro_display_code_preprocess: + \tl_set:Nn + \knowledge_kl_used_style_tl + {\knowledge_kl_intro_style_tl} + \cs_set_eq:NN + \knowledge_kl_display_code: + \knowledge_phantomintro_display_code: + } +\cs_new:Nn\knowledge_reintro_init: + {\tl_set:Nn + \knowledge_kl_command_tl + {reintro} + \tl_set:Nn + \knowledge_kl_used_style_tl + {\knowledge_kl_intro_style_tl} + } +\cs_new:Nn\knowledge_intro_update:N + {\ktuple_countintro_gincr:N#1} + +\tl_set:Nn\knowledge_kl_intro_style_tl + {intro} +\cs_new:Npn\knowledge_intro_display_code_preprocess: + {\tl_if_exist_ne:NTF\knowledge_kl_resource_tl + {\expandafter\ktuple_countintro_get_int:NN + \knowledge_kl_resource_tl\l_tmpa_int + \tl_set:Nx\l_tmpa_tl + {\int_compare:nNnTF\l_tmpa_int=1{}{\int_to_alph:n\l_tmpa_int}}} + {\tl_set:Nn\l_tmpa_tl{}} + \tl_if_exist_ne:NTF\kl_autoref_tl + {\exp_args:Nx\label{\expandafter\noexpand\kl_autoref_tl\l_tmpa_tl}} + {}} +\tl_new:N\knowledge_kl_style_tl +\tl_set:Nn\knowledge_kl_used_style_tl{\knowledge_kl_style_tl} +\cs_new:Nn\knowledge_defaultkl_init:{} +\cs_gset:Nn\knowledge_defaultkl_update:N + {\ktuple_countuse_gincr:N#1} +\tl_set:Nn\knowledge_defaultkl_namespace_tl{default} +\NewDocumentCommand\kl{om}{\kl_kl_inner:nn{#1}{#2}} +\cs_new:Nn\kl_kl_inner:nn +{\group_begin: + \knowledge_kl_init: + \cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init: + \kl_base:nn{#1}{#2} + \group_end: + \knowledge_display_sequence: +} +\tl_set:Nn\knowledge_variablekl_namespace_tl{variable} +\bool_new:N\kl_already_met_bool +\ktuple_new_bool_index:n{already_met_bool} +\ktuple_already_met_bool_expands_to:TF + {\bool_gset_true:N\kl_already_met_bool} + {\bool_gset_false:N\kl_already_met_bool} + +\NewDocumentCommand\introvar{om} + {\IfNoValueTF{#1} + {\introvar:nn{#2}{#2}} + {\introvar:nn{#1}{#2}}} + +\cs_new:Nn\introvar:nn + {\group_begin: + \scope_get_attractive_instance:N + \knowledge_knowledge_instance_tl + \knowledge_sets_to:nnn + \knowledge_variablekl_namespace_tl + \knowledge_knowledge_instance_tl + {#1} + \knowledge_at:N\ktuple_ensure:N + \knowledge_at:N\ktuple_already_met_bool_if:NTF + {\WARNING_VARIABLE_INTRODUCED_TWICE_IN_SAME_SCOPE + \group_end: + \textcolor{orange}{#2}} + {\knowledge_at:N\ktuple_already_met_bool_gset_true:N + \knowledge[\knowledge_variablekl_namespace_tl]{#1}{autorefhere} + \group_end: + #2} +} + +\NewDocumentCommand\klvar{om} + {\group_begin: + \tl_set:Nn\knowledge_kl_command_tl{\klvar} + \tl_set_eq:NN\knowledge_kl_namespace_tl\knowledge_variablekl_namespace_tl + \cs_set_eq:NN\knowledge_kl_display_code:\knowledge_variablekl_display_code: + \kl_base:nn{#1}{#2} + \group_end: +} + +\cs_new:Nn\knowledge_variablekl_display_code: + {\bool_if:NTF\knowledge_hyperref_active_bool + {\tl_if_exist:NTF\kl_autoref_tl + {\kl_hyperref_silentlabel:nn\kl_autoref_tl\knowledge_kl_text_tl} + {\textcolor{purple}{\knowledge_kl_text_tl}}} + {\knowledge_kl_text_tl}} +\NewKnowledgeParamBool*{protect~link}\kl_protect_link_bool +\NewKnowledgeParamBool*{emphasize}\kl_emphasize_bool +\NewKnowledgeParamBool*{underline}\kl_underline_bool +\NewKnowledgeParamBool*{boldface}\kl_boldface_bool +\NewKnowledgeParamBool*{md}\kl_md_bool +\NewKnowledgeParamBool*{fbox}\kl_fbox_bool +\NewKnowledgeParamBool*{typewriter}\kl_typewriter_bool +\NewKnowledgeParamBool*{ensuremath}\kl_ensuremath_bool +\NewKnowledgeParamBool*{mathord}\kl_mathord_bool +\NewKnowledgeParamBool*{mathop}\kl_mathop_bool +\NewKnowledgeParamBool*{mathbin}\kl_mathbin_bool +\NewKnowledgeParamBool*{mathrel}\kl_mathrel_bool +\NewKnowledgeParamBool*{mathopen}\kl_mathopen_bool +\NewKnowledgeParamBool*{mathclose}\kl_mathclose_bool +\NewKnowledgeParamBool*{mathpunct}\kl_mathpunct_bool +\NewKnowledgeParamBool*{ensuretext}\kl_ensuretext_bool +\NewKnowledgeParamBool*{italic}\kl_italic_bool +\NewKnowledgeParamBool*{up}\kl_up_bool +\NewKnowledgeParamBool*{lowercase}\kl_lowercase_bool +\NewKnowledgeParamBool*{uppercase}\kl_uppercase_bool +\NewKnowledgeParamTl*{text}\kowledge_kl_forced_text_tl +\NewKnowledgeParamTl*{link}\knowledge_kl_link_tl +\NewKnowledgeParamTl*{wrap}\knowledge_kl_wrap_tl +\NewKnowledgeParamTl*{style}\knowledge_kl_style_tl +\NewKnowledgeParamTl*{intro~style}\knowledge_kl_intro_style_tl +\NewKnowledgeParamCode{displaycode}\kl_display_code: +\ktuple_new_int_index:n{countuse} +\ktuple_countuse_expands_to:n{} +\ktuple_new_int_index:n{countintro} +\ktuple_countintro_expands_to:n{} +\int_new:N\knowledge_autoref_count + +\keys_define:nn{ knowledge~directives }{ + autoref .code:n = { + \keys_set:nn{ knowledge~directives } + { intro~style=intro } + \int_gincr:N\knowledge_autoref_count + \knowledge_delay_directive:x + {autoref = {autoref-\int_use:N\knowledge_autoref_count}}}, + autorefhere .code:n = { + \int_gincr:N\knowledge_autoref_count + \exp_args:Nx\label{autoref-\int_use:N\knowledge_autoref_count} + \knowledge_delay_directive:x + {autoref = {autoref-\int_use:N\knowledge_autoref_count}}}} + +\ktuple_new_tl_index:n{autoref} +\use:c{ktuple_autoref_expands_to:n} + {\tl_set:Nn\kl_autoref_tl{#1} } +\keys_define:nn { knowledgenow~directives } { +autoref .code:n = + { \knowledge_at:c{ktuple_autoref_gset:Nn}{#1} + \KAuxWriteX* + {\exp_not:N\KAuxAutoref\exp_not:V\knowledge_set_now_k_tl}} +} +\int_new:N\kl_countuse_int +\int_new:N\kl_countintro_int +\NewKAuxCommand\KAuxAutoref{mmm} + {Package~knowledge:~Declares~an~autoref~knowledge.~ + Arguments~{namespace}{instance}{knowledge}.} + +\int_new:N\kl_digest_autorefused_int +\int_new:N\kl_digest_autorefnointro_int +\int_new:N\kl_digest_autoreftwiceintro_int +\int_new:N\kl_digest_autorefunused_int +\int_new:N\kl_digest_unknownknowledge_int + +\DeclareKAuxPhaseCommand\KAuxErrorKnowledgeUnknown{diagnose~digest} + {\int_gincr:N\kl_digest_unknownknowledge_int} + +\DeclareKAuxPhaseCommand\KAuxAutoref{diagnose~digest} + {\group_begin: + \knowledge_sets_to:nnn{#1}{#2}{#3} + \knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int + \knowledge_at:N\ktuple_countintro_get_int:NN\kl_countintro_int + \int_compare:nNnT\kl_countintro_int=1 + {\int_gincr:N\kl_digest_autorefused_int} + \int_compare:nNnT\kl_countintro_int=0 + {\int_compare:nNnTF\kl_countuse_int=0 + {\int_gincr:N\kl_digest_autorefunused_int} + {\int_gincr:N\kl_digest_autorefnointro_int}} + \int_compare:nNnT\kl_countintro_int>1 + {\int_gincr:N\kl_digest_autoreftwiceintro_int} + \group_end:} + +\DeclareKAuxPhaseCommand\KAuxAutoref{autoref~not~introduced} + {\group_begin: + \knowledge_sets_to:nnn{#1}{#2}{#3} + \knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int + \knowledge_at:N\ktuple_countintro_get_int:NN\kl_countintro_int + \int_compare:nNnT\kl_countuse_int>0 + {\int_compare:nNnT\kl_countintro_int=0 + {\knowledge_diagnose:n{\nointro{#1}{#2}{#3}}}} + \group_end:} +\DeclareKAuxPhaseCommand\KAuxAutoref{autoref~introduced~twice} + {\group_begin: + \knowledge_sets_to:nnn{#1}{#2}{#3} + \knowledge_at:N\ktuple_countuse_get_int:NN\kl_countuse_int + \knowledge_at:N\ktuple_countintro_get_int:NN\kl_countintro_int + \int_compare:nNnT\kl_countintro_int>1 + {\knowledge_diagnose:n{{#1}{#2}{#3}}} + \group_end:} +\cs_new:Nn\knowledge_kl_display_sequence:n + {\knowledge_kl_display_sequence:w#1\display_end:} +\cs_new:Npn\knowledge_kl_display_sequence:w#1#2\display_end: + {\tl_if_empty:nTF{#2}{#1} + {#1{\knowledge_kl_display_sequence:w #2 \display_end:}}} +\cs_new:Nn\knowledge_phantomintro_display_code: + {\knowledge_intro_display_code_preprocess: + \cs_gset:Npx\knowledge_display_sequence:{ + \knowledge_kl_display_sequence:n{ + \knowledge_kl_display_code_index:n + \knowledge_invisible_display_code_text: + }}} +\cs_new:Nn\knowledge_invisible_display_code_text:{} +\cs_new:Nn\knowledge_defaultkl_display_code:{ + \knowledge_kl_display_code_preprocess: + \cs_gset:Npx\knowledge_display_sequence:{ + \knowledge_kl_display_sequence:n{ + \knowledge_kl_display_code_index:n + \knowledge_defaultkl_display_code_fbox:n + \knowledge_defaultkl_display_code_emphasize:n + \knowledge_defaultkl_display_code_ensuremath:n + \knowledge_defaultkl_display_code_ensuretext:n + \knowledge_defaultkl_display_code_mathord:n + \knowledge_defaultkl_display_code_mathop:n + \knowledge_defaultkl_display_code_typewriter:n + \knowledge_defaultkl_display_code_sc:n + \knowledge_defaultkl_display_code_italic:n + \knowledge_defaultkl_display_code_up:n + \knowledge_defaultkl_display_code_boldface:n + \knowledge_defaultkl_display_code_md:n + \knowledge_defaultkl_display_code_ref:n + \knowledge_defaultkl_display_code_url:n + \knowledge_defaultkl_display_code_color:n + \knowledge_defaultkl_display_code_colorbox:n + \knowledge_defaultkl_display_code_underline:n + \knowledge_defaultkl_code_nestingprotect:n + \knowledge_defaultkl_display_code_text:}} +} +\cs_new:Nn\knowledge_kl_display_code_index:n{#1} + +\cs_new:Nn\knowledge_defaultkl_display_code_fbox:n + {\bool_if:NTF\kl_fbox_bool{\exp_not:N\fbox{#1}}{#1}} + +\cs_new:Npn\knowledge_kl_display_code_preprocess: + {} + +\cs_new:Nn\knowledge_defaultkl_display_code_ensuremath:n + {\bool_if:NTF\kl_ensuremath_bool{\exp_not:N\ensuremath}\use:n{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_ensuretext:n + {\bool_if:NTF\kl_ensuretext_bool{\mode_if_math:TF{\exp_not:N\text}\use:n}\use:n{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathord:n{ + \bool_if:NTF\kl_mathord_bool + {\mode_if_math:TF{\exp_not:N\mathord}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathop:n{ + \bool_if:NTF\kl_mathop_bool + {\mode_if_math:TF{\exp_not:N\mathop}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathbin:n{ + \bool_if:NTF\kl_mathbin_bool + {\mode_if_math:TF{\exp_not:N\mathbin}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathrel:n{ + \bool_if:NTF\kl_mathrel_bool + {\mode_if_math:TF{\exp_not:N\mathrel}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathopen:n{ + \bool_if:NTF\kl_mathopen_bool + {\mode_if_math:TF{\exp_not:N\mathopen}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathclose:n{ + \bool_if:NTF\kl_mathclose_bool + {\mode_if_math:TF{\exp_not:N\mathclose}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_mathpunct:n{ + \bool_if:NTF\kl_mathpunct_bool + {\mode_if_math:TF{\exp_not:N\mathpunct}\use:n{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_emphasize:n{ + \bool_if:NTF\kl_emphasize_bool + {\mode_if_math:TF\use:n{\exp_not:N\emph}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_underline:n{ + \bool_if:NTF\kl_underline_bool + {\mode_if_math:TF{#1} + {\exp_not:N\underline{\exp_not:N\smash{#1}}}} + {#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_typewriter:n{ + \bool_if:NTF\kl_typewriter_bool + {\mode_if_math:TF{\exp_not:N\mathtt}{\exp_not:N\texttt}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_italic:n{ + \bool_if:NTF\kl_italic_bool + {\mode_if_math:TF{\exp_not:N\mathit}{\exp_not:N\textit}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_sc:n{ + \bool_if:NTF\kl_cs_bool + {\mode_if_math:TF{\exp_not:N\mathsc}{\exp_not:N\textsc}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_md:n{ + \bool_if:NTF\kl_md_bool + {\mode_if_math:TF{\exp_not:N\mathmd}{\exp_not:N\textmd}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_up:n{ + \bool_if:NTF\kl_up_bool + {\mode_if_math:TF{\exp_not:N\mathup}{\exp_not:N\textup}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_boldface:n{ + \bool_if:NTF\kl_boldface_bool + {\mode_if_math:TF{\exp_not:N\mathbf}{\exp_not:N\textbf}{#1}}{#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_ref:n{ + \bool_if:NTF\knowledge_hyperref_active_bool + {\tl_if_exist:NTF\kl_ref_tl + {\exp_not:N\kl_hyperlink_label:nn{\exp_not:V\kl_ref_tl}{#1}} + {\tl_if_exist:NTF\kl_autoref_tl + {\exp_not:N\kl_hyperlink_silentlabel:nn{\exp_not:V\kl_autoref_tl}{#1}} + {#1}}} + {#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_url:n{ + \bool_if:NTF\knowledge_hyperref_active_bool + {\tl_if_exist:NTF\kl_url_tl{\exp_not:N\kl_hyperlink_url:nn{\exp_not:V\kl_url_tl}{#1}}{#1}} + {#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_color:n{ + \bool_if:NTF\knowledge_xcolor_active_bool + {\tl_if_exist:NTF\kl_color_tl + {\exp_not:N\textcolor{\kl_color_tl}{#1}}{#1}} + {#1}} +\cs_new:Nn\knowledge_defaultkl_display_code_colorbox:n{ + \bool_if:NTF\knowledge_xcolor_active_bool + {\tl_if_exist:NTF\kl_colorbox_tl + {\exp_not:N\colorbox{\kl_colorbox_tl}{#1}}{#1}} + {#1}} +\cs_new:Nn\knowledge_defaultkl_code_nestingprotect:n{ + \bool_if:NTF\kl_protect_link_bool + {\exp_not:N\kl_kl_nesting_incr:#1\exp_not:N\kl_kl_nesting_decr:}{#1} + } +\cs_new:Nn\knowledge_defaultkl_code_wrap:n{ + \tl_if_exist:NTF\knowledge_kl_wrap_tl + {\exp_not:V\knowledge_kl_wrap_tl{#1}}{#1}} + +\cs_new:Nn\knowledge_defaultkl_display_code_text:{ + \knowledge_defaultkl_code_wrap:n{ + \tl_if_exist:NTF\kowledge_kl_forced_text_tl + {\exp_not:V\kowledge_kl_forced_text_tl} + {\exp_not:V\knowledge_kl_text_tl} + } +} +\NewDocumentCommand\AP{} + {\bool_if:NT\knowledge_hyperref_active_bool + {\strut\vadjust{\knowledge_AP_internal:}}} +\NewDocumentCommand\itemAP{o}{ + \IfNoValueTF{#1} + {\item\AP} + {\item[\knowledge_itemAP: #1]}} +\int_new:N\kl_hyperref_kl_nesting_count_int +\bool_new:N\kl_hyperref_active_here_bool +\bool_set_true:N\kl_hyperref_active_here_bool +\cs_new:Npn\kl_if_hyperlinks_active_here:TF + {\bool_if:NTF\knowledge_hyperlinks_active_bool + {\bool_if:NTF\kl_hyperref_active_here_bool} + \use_ii:nn} +\cs_new:Nn\kl_kl_nesting_incr: + {\int_gincr:N\kl_hyperref_kl_nesting_count_int + \bool_gset:Nn\kl_hyperref_active_here_bool + {\int_compare_p:nNn\kl_hyperref_kl_nesting_count_int=0}} +\cs_new:Nn\kl_kl_nesting_decr: + {\int_gdecr:N\kl_hyperref_kl_nesting_count_int + \bool_gset:Nn\kl_hyperref_active_here_bool + {\int_compare_p:nNn\kl_hyperref_kl_nesting_count_int=0}} +\cs_new:Npn\kl_hyperlink_label:nn#1 + {\kl_if_hyperlinks_active_here:TF{\hyperref[{#1}]}{\use:n}} +\cs_new:Npn\kl_hyperlink_url:nn + {\kl_if_hyperlinks_active_here:TF\href\use_ii:nn} +\cs_new:Nn\kl_hyperlink_silentlabel:nn + {\kl_if_hyperref_exist:nTF{#1} + {\kl_hyperlink_label:nn{#1}{#2}} + {#2}} +\cs_new:Npn\kl_if_hyperref_exist:nTF#1 + {\expandafter\ifx\csname r@#1\endcsname\relax + \expandafter\use_ii:nn\else + \expandafter\use_i:nn\fi} +\cs_new:Nn\knowledge_AP_internal:{% + \vbox to 0pt{ + \kern-\dp\strutbox + \smash{\llap{\knowledge_AP_mark:\kern0.5em}} + \vss}} +\cs_new:Nn\knowledge_AP_mark:{% + \setlength\unitlength{1em} + \begin{picture}(0,0) + \put(0,1){ + \bool_if:NT\knowledge_hyperref_active_bool + {\put(-0.05,-1.04){\phantomsection}} + \bool_if:NT\knowledge_configuration_visibleAP_bool + {\bool_if:NTF\knowledge_xcolor_active_bool + {\textcolor{red}}{\use:n} + {\line(0,-1){0.5}\line(1,0){0.5}}}} + \end{picture}{}} +\cs_new:Nn\knowledge_itemAP:{ + \hbox_overlap_left:n + {\knowledge_AP_mark:\hspace{1em}} + } +\ExplSyntaxOff +\def\makequotationactive + {\catcode`"13\relax} +\def\makequotationletter + {\catcode`"12\relax} + +\let\quotationmark" + +\makequotationactive +\makeatletter +\NewDocumentCommand\klactivequotationmark{} + {\@ifnextchar"% + \klactivequotationmarkdouble + \klactivequotationmarksimple} +\def \introabsorbquote + {\@ifnextchar"\@gobble\kl@errordoublequotemissing} + +\makeatother + +\edef\klactivequotationmarksimple#1"% + {\noexpand\klquotationparseinternal#1\noexpand @% + \csname klparse_novalue_tl\endcsname\noexpand @% + \csname klparse_novalue_tl\endcsname\noexpand @% + \noexpand\klendmarker} +\edef\klactivequotationmarkdouble"#1"% + {\noexpand\introquotationparseinternal#1\noexpand @% + \csname klparse_novalue_tl\endcsname\noexpand @% + \csname klparse_novalue_tl\endcsname\noexpand @% + \noexpand\klendmarker + \noexpand\introabsorbquote} + +\def\klquotationparseinternal#1@#2@#3@#4\klendmarker + {\IfNoValueTF{#2}{\kl{#1}}{\kl[{#2}]{#1}}} +\def\introquotationparseinternal#1@#2@#3@#4\klendmarker + {\IfNoValueTF{#2}{\intro{#1}}{\intro[{#2}]{#1}}} + +\def\klactivatequotation + {\makequotationactive + \let"\klactivequotationmark} +\def\kldeactivatequotation + {\makequotationletter} + +\kldeactivatequotation +\ExplSyntaxOn +\cs_new:Nn\kl_protect_environment_quotation:n + {\clist_map_inline:nn{#1} + {\scope_area_set:nn{#1} + { push~code={\knowledgeconfigure{quotation=false}}, + pop~code={\knowledgeconfigure{quotation=true}}}} + } +\cs_new:Nn\klparse_absorb_modifiers: + {\tl_set_eq:NN\klparse_primes_tl\c_empty_tl + \bool_if:NTF\klparse_load_primes_bool + \klparse_absorb_modifiers_pses: + \klparse_absorb_modifiers_ses: + } + +\cs_new:Nn\klparse_absorb_modifiers_pses: + {\klparse_ifnextchar:NTF' + {\tl_put_right:Nn\klparse_primes_tl' + \use_i:nn\klparse_absorb_modifiers_pses:} + \klparse_absorb_modifiers_ses: + } + +\cs_new:Nn\klparse_absorb_modifiers_ses: + {\bool_if:NTF\klparse_load_subscript_bool + {\klparse_absorb_subscript:Nn\klparse_subscript_tl\klparse_absorb_modifiers_es:} + {\tl_set_eq:NN\klparse_subscript_tl\klparse_novalue_tl + \klparse_absorb_modifiers_es:} + } + +\cs_new:Nn\klparse_absorb_modifiers_es: + {\bool_if:NTF\klparse_load_supscript_bool + {\tl_if_empty:NTF\klparse_primes_tl + {\klparse_absorb_supscript:Nn\klparse_supscript_tl + \klparse_absorb_modifiers_ts:} + {\tl_set_eq:NN\klparse_supscript_tl\klparse_novalue_tl + \klparse_absorb_modifiers_exec:}} + {\tl_set_eq:NN\klparse_supscript_tl\klparse_novalue_tl + \klparse_absorb_modifiers_exec:} + } + +\cs_new:Nn\klparse_absorb_modifiers_ts: + {\bool_if:NTF\klparse_load_subscript_bool{ + \klparse_if_novalue:NTF\klparse_subscript_tl + {\klparse_absorb_subscript:Nn\klparse_subscript_tl\klparse_absorb_modifiers_exec:} + \klparse_absorb_modifiers_exec:} + {\klparse_absorb_modifiers_exec:} + } +\ExplSyntaxOff +\def\absorbsupscriptNn{\absorbopt ^} +\def\absorbsubscriptNn{\absorbopt _} +\ExplSyntaxOn +\cs_set_eq:NN\klparse_absorb_supscript:Nn\absorbsupscriptNn +\cs_set_eq:NN\klparse_absorb_subscript:Nn\absorbsubscriptNn + +\cs_new:Npn\absorbopt#1#2#3 + {\klparse_ifnextchar:NTF #1 + {\klparse_absorbopt_ii:NnNn #2 {#3}} + {\tl_set_eq:NN #2 \klparse_novalue_tl #3}} + +\cs_new:Nn\klparse_absorbopt_ii:NnNn + {\tl_set:Nn #1 {#4} #2 } +\cs_set_eq:NN\klparse_if_load_subscript:TF\use_i:nn +\cs_set_eq:NN\klparse_if_load_supscript:TF\use_i:nn +\cs_set_eq:NN\klparse_if_load_primes:TF\use_i:nn +\cs_new:Nn\knowledge_directives_require_aci_package:nn + {\bool_if:cTF{knowledge_#2_syntax_bool}{}{ + \NewKnowledgeParamPackageError{#1}{#2}}} +\NewKnowledgeParamTl*{color}\kl_color_tl +\NewKnowledgeParamTl*{colorbox}\kl_colorbox_tl + +\knowledge_directives_require_aci_package:nn + {color,colorbox}{xcolor} +\NewKnowledgeParamTl*{url}\kl_url_tl +\NewKnowledgeParamTl*{ref}\kl_ref_tl + +\knowledge_directives_require_aci_package:nn + {url,ref,autoref}{hyperref} +\bool_if:NT\knowledge_hyperref_active_bool{ + \DeclareExpandableDocumentCommand\knowledge_fake_kl{om}{#2} + \DeclareExpandableDocumentCommand\knowledge_fake_intro{som}{#3} + \DeclareExpandableDocumentCommand\knowledge_fake_reintro{som}{#3} + + \pdfstringdefDisableCommands{% + \let\kl\knowledge_fake_kl + \let\intro\knowledge_fake_intro + \let\reintro\knowledge_fake_reintro + } +} +\bool_if:NT\knowledge_makeidx_active_bool{ + \makeindex + + \cs_gset:Npn\knowledge_kl_display_code_index:n + {\knowledge_defaultkl_display_code_index:n} + + \cs_new:Npn\knowledge_defaultkl_display_code_index:n + {\tl_if_exist:NT\kl_index_tl + {\exp_not:N\index + {{\tl_if_exist_ne:NTF\kl_index_parent_key_tl + {\exp_not:V\kl_index_parent_key_tl!}{} + \tl_if_exist_ne:NTF\kl_index_key_tl + {\exp_not:V\kl_index_key_tl@}{} + \expandafter\detokenize\expandafter{\kl_index_tl} + }}}} +} + +\NewKnowledgeParamTl{index}\kl_index_tl +\keys_define:nn { knowledge~directives } +{ index .code:n = { + \tl_if_empty:nTF{#1} + {\knowledge_delay_directive:x{index={\exp_not:V\knowledge_key_tl}}} + {\knowledge_delay_directive:n{index={#1}}}}, + index .default:n = {} +} + +\NewKnowledgeParamTl*{index~style}\kl_index_style_tl +\NewKnowledgeParamTl*{index~parent~key}\kl_index_parent_tl +\NewKnowledgeParamTl*{index~key}\kl_index_key_tl +\cs_gset_eq:NN\knowledge_kl_init:\knowledge_defaultkl_init: +\tl_gset_eq:NN \knowledge_kl_namespace_tl\knowledge_defaultkl_namespace_tl +\cs_gset_eq:NN\knowledge_kl_display_code:\knowledge_defaultkl_display_code: +\cs_gset_eq:NN\knowledge_kl_update:N\knowledge_defaultkl_update:N +\tl_gset:Nn\knowledge_kl_command_tl{\kl} +\newcommand\robustdisplay[1] + {\expandafter\tl_trim_spaces:n\expandafter{\detokenize{#1}}} +\newcommand\robustdisplaybracket[1] + {[\robustdisplay{#1}]} +\cs_set_eq:NN\knowledge_error_display:n\use:n + +\bool_if:NTF\knowledge_xcolor_active_bool{ + \knowledgestyle{intro}{emphasize} + \knowledgestyle{unknown}{wrap=\knowledge_error_display:n,color=red} + \knowledgestyle{unknown~(cont)}{wrap=\knowledge_error_display:n,color=gray} + \knowledgestyle{autoref~not~introduced}{wrap=\knowledge_error_display,color=orange} + \knowledgestyle{autoref~not~introduced~(cont)}{wrap=\knowledge_error_display:n,color=gray} + \knowledgestyle{autoref~reintroduced}{wrap=\knowledge_error_display:n,color=red} + \knowledgestyle{autoref~reintroduced~(cont)}{wrap=\knowledge_error_display:n,color=red} +}{ + \knowledgestyle{intro}{emphasize} + \knowledgestyle{unknown}{wrap=\knowledge_error_display:n} + \knowledgestyle{unknown~(cont)}{wrap=\knowledge_error_display:n} + \knowledgestyle{autoref~not~introduced}{wrap=\knowledge_error_display:n} + \knowledgestyle{autoref~not~introduced~(cont)}{wrap=\knowledge_error_display:n} + \knowledgestyle{autoref~reintroduced}{wrap=\knowledge_error_display:n} + \knowledgestyle{autoref~reintroduced~(cont)}{wrap=\knowledge_error_display:n} +} +\ExplSyntaxOff\makeatletter +\newcommand\knowledgeFixHyperrefTwocolumn{ + \RequirePackage{etoolbox} + \newcount\c@additionalboxlevel + \setcounter{additionalboxlevel}{0} + \newcount\c@maxboxlevel + \setcounter{maxboxlevel}{1} + \patchcmd\@combinedblfloats{\box\@outputbox}{% + \stepcounter{additionalboxlevel}% + \box\@outputbox + }{}{\errmessage{\noexpand\@combinedblfloats could not be patched}} + % + \AtBeginShipout{% + \ifnum\value{additionalboxlevel}>\value{maxboxlevel}% + \typeout{Warning: maxboxlevel might be too small, increase to % + \the\value{additionalboxlevel}% + }% + \fi + \@whilenum\value{additionalboxlevel}<\value{maxboxlevel}\do{% + \typeout{* Additional boxing of page `\thepage'}% + \setbox\AtBeginShipoutBox=\hbox{\copy\AtBeginShipoutBox}% + \stepcounter{additionalboxlevel}% + }% + \setcounter{additionalboxlevel}{0}% + } +} +\ExplSyntaxOn +\makeatother +\bool_if:NF\knowledge_option_composition_bool + {\bool_if:NF\knowledge_option_paper_bool} + {\bool_gset_true:N\knowledge_option_composition_bool} +\bool_if:NT\knowledge_option_composition_bool + {\bool_if:NT\knowledge_option_paper_bool} + {\bool_gset_false:N\knowledge_option_composition_bool} + +\DeclareExpandableDocumentCommand\IfKnowledgeCompositionModeTF{} + {\bool_if:NTF\knowledge_option_composition_bool} +\newif\ifKnowledgeCompositionMode +\IfKnowledgeCompositionModeTF + \KnowledgeCompositionModetrue + \KnowledgeCompositionModefalse + +\DeclareExpandableDocumentCommand\IfKnowledgeElectronicModeTF{} + {\bool_if:NTF\knowledge_option_electronic_bool} +\newif\ifKnowledgeElectronicMode +\IfKnowledgeElectronicModeTF + \KnowledgeElectronicModetrue + \KnowledgeElectronicModefalse + +\DeclareExpandableDocumentCommand\IfKnowledgePaperModeTF{} + {\bool_if:NTF\knowledge_option_paper_bool} +\newif\ifKnowledgePaperMode +\IfKnowledgePaperModeTF + \KnowledgePaperModetrue + \KnowledgePaperModefalse + +\DeclareExpandableDocumentCommand\IfXcolorTF{} + {\bool_if:NTF\knowledge_xcolor_active_bool} +\newif\ifXcolor +\IfXcolorTF + \Xcolortrue + \Xcolorfalse +\ExplSyntaxOff +\newrobustcmd\KnowledgeConfigureNotion[1][blue]{ + \knowledgedirective{notion} + {autoref,style=notion,intro style=intro notion} + \ifKnowledgePaperMode + \knowledgestyle{notion}{} + \knowledgestyle{intro notion}{emphasize} + \knowledgestyle{unknown}{} + \knowledgestyle{unknown (cont)}{} + \fi + \ifKnowledgeCompositionMode + \ifXcolor + \knowledgestyle{notion}{color={#1!70!black}} + \knowledgestyle{intro notion}{emphasize,color={#1}} + \knowledgestyle{unknown}{color=brown} + \knowledgestyle{unknown (cont)}{color=brown} + \else + \knowledgestyle{notion}{underline} + \knowledgestyle{intro notion}{emphasize, underline} + \knowledgestyle{unknown}{} + \knowledgestyle{unknown (cont)}{} + \fi + \fi + \ifKnowledgeElectronicMode + \ifXcolor + \definecolor{klDarkBlue}{rgb}{0,0,0.7} + \knowledgestyle{notion}{color={#1!70!black}} + \knowledgestyle{intro notion}{emphasize,color={#1}} + \knowledgestyle{unknown}{} + \knowledgestyle{unknown (cont)}{} + \else + \knowledgestyle{notion}{underline} + \knowledgestyle{intro notion}{emphasize, underline} + \knowledgestyle{unknown}{} + \knowledgestyle{unknown (cont)}{} + \fi + \fi +} +\ExplSyntaxOn +\exp_args:NNV\ExplSyntaxOff\knowledgeconfigure\knowledge_configuration_pending_tl +\ScopeActivate + +\NeedsTeXFormat{LaTeX2e}[1999/12/01] +\ProvidesPackage{scopearticle} + [2016/02/26 v2.0 first codes of the new version] +\ExplSyntaxOn +\knowledge_begin_module_if:N\knowledge_option_scope_bool +\scope_area_set:nn{base} +{ + occurrences = once, + autoclose = false +} +\scope_area_set:nn{document} +{ + autoclose = false, + occurrences = once, + parents = base +} +\scope_area_set:nn{body} +{ + autoclose = true, + occurrences = once, + parents = document, + } +\scope_area_set:nn + {part, section,subsection,subsubsection, + paragraph,subparagraph,subsubparagraph} + { category=structure, + autoclose = true, + occurrences = multiple, + knowledge=accepts + } +\scope_area_set:nn + {base,document,section,subsection,subsubsection, + paragraph,subparagraph,subsubparagraph} + {knowledge=accepts} +\scope_area_set:nn + {base,document} + {knowledge=attracts} +\scope_area_set:nn + {body} + {knowledge=none} + +\scope_area_set:nn{part}{parents = {body}, forces = body } +\scope_area_set:nn{section}{parents = {body,part}, forces = body } +\scope_area_set:nn{subsection}{parents = section } +\scope_area_set:nn{subsubsection}{parents = subsection } +\scope_area_set:nn{paragraph}{parents = {document,section,subsection,subsubsection} } +\scope_area_set:nn{subparagraph}{parents = {paragraph} } +\scope_area_set:nn{subsubparagraph}{parents = {subparagraph} } +\scope_area_set:nn{abstract} + {autoclose=false, + occurrences=once, + parents={body,structure}, + forces=body, + knowledge=none +} +\OverloadCommand\section{som} + {\scope_area_push:n{section} + \XparseArgs\SUPERsection{som}{#1}{#2}{#3}} +\OverloadCommand\subsection{som} + {\scope_area_push:n{subsection} + \XparseArgs\SUPERsubsection{som}{#1}{#2}{#3}} +\OverloadCommand\subsubsection{som} + {\scope_area_push:n{subsubsection} + \XparseArgs\SUPERsubsubsection{som}{#1}{#2}{#3}} +\OverloadCommand\paragraph{som} + {\scope_area_push:n{paragraph} + \XparseArgs\SUPERparagraph{som}{#1}{#2}{#3}} +\OverloadCommand\subparagraph{som} + {\scope_area_push:n{subparagraph} + \XparseArgs\SUPERsubparagraph{som}{#1}{#2}{#3}} +\OverloadCommand\subsubparagraph{som} + {\scope_area_push:n{subsubparagraph} + \XparseArgs\SUPERsubsubparagraph{som}{#1}{#2}{#3}} +\cs_new:Nn\scope_area_environment_new:nn + {\scope_area_set:nn{#1}{ + parents = all, + autoclose = false, + occurrences = multiple, + knowledge = attracts, + #2 + }} + +\OverloadCommand\newtheorem{m} + {\scope_area_environment_new:nn + {#1} + {category=theorem-like} + \SUPERnewtheorem{#1}} + +\OverloadCommand\newenvironment{m} + {\scope_area_environment_new:nn + {#1} + {category=environment} + \SUPERnewenvironment{#1}} +\OverloadCommand\NewDocumentEnvironment{m} + {\scope_area_environment_new:nn + {#1} + {category=environment} + \SUPERNewDocumentEnvironment{#1}} +\scope_area_set:nn + {itemize,enumerate,description} + {category=itemize-like} + + +\scope_area_set:nn{item} + {autoclose=true, + parents = itemize-like} + +\OverloadCommand\item{o} + {%\scope_categoryseq_pop_to:n{itemize-like} + %\scope_category_if_area_in:nnTF{trivlist}\scope_top_area_tl + % {} + % {\scope_area_push:n{item}} + \XparseArgs\SUPERitem{o}{#1}} + + +\scope_area_set:nn{emph,textit,texttt,textbf}{ + autoclose = false, + occurrences = multiple, + forces = body + } +\knowledge_end_module: +\ExplSyntaxOff +\endinput +%% +%% End of file `knowledge.sty'. diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index d5394b63b56..cefb8063226 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -340,7 +340,7 @@ my @TLP_working = qw( jura juraabbrev jurabib juramisc jurarsp js-misc jvlisting kantlipsum karnaugh karnaugh-map karnaughmap kastrup kdgdocs kerkis kerntest keycommand keyfloat keyreader keystroke keyval2e keyvaltable kix kixfont - knitting knittingpattern knuth knuth-lib knuth-local + knitting knittingpattern knowledge knuth knuth-lib knuth-local koma-moderncvclassic koma-script koma-script-examples koma-script-sfs komacv kotex-oblivoir kotex-plain kotex-utf kotex-utils kpfonts ksfh_nat ksp-thesis diff --git a/Master/tlpkg/libexec/ctan2tds b/Master/tlpkg/libexec/ctan2tds index 001df07151a..16cf44ef6c3 100755 --- a/Master/tlpkg/libexec/ctan2tds +++ b/Master/tlpkg/libexec/ctan2tds @@ -2994,6 +2994,7 @@ $standardclean = '\.head|\.tmp|\.dvi|\.log|\.out|\.aux|\.toc|\.lof|\.lot' 'gfsdidot' => '.pdf', # no source 'gfsneohellenic'=> '.pdf', # no source 'jknapltx' => 'ubbold.fd', # clash bbold's Ubbold.fd; sauter bbold fails + 'knowledge' => 'knowledge.pdf', # no source 'latexmk' => '(sweave_|tex4ht-)latexmkrc', # case-folding clash 'math-into-latex-4' => 'video.*zip|S.*\.pdf', # nonfree 'numericplots' => '.*\.m', # matlab diff --git a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc index 72d5652c9b4..c6a7cb4bed5 100644 --- a/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-latexextra.tlpsrc @@ -560,6 +560,7 @@ depend keystroke depend keyval2e depend keyvaltable depend kix +depend knowledge depend koma-moderncvclassic depend koma-script-sfs depend komacv diff --git a/Master/tlpkg/tlpsrc/knowledge.tlpsrc b/Master/tlpkg/tlpsrc/knowledge.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/Master/tlpkg/tlpsrc/knowledge.tlpsrc |