summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/knowledge/knowledge-configuration.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/knowledge/knowledge-configuration.dtx
Initial commit
Diffstat (limited to 'macros/latex/contrib/knowledge/knowledge-configuration.dtx')
-rw-r--r--macros/latex/contrib/knowledge/knowledge-configuration.dtx252
1 files changed, 252 insertions, 0 deletions
diff --git a/macros/latex/contrib/knowledge/knowledge-configuration.dtx b/macros/latex/contrib/knowledge/knowledge-configuration.dtx
new file mode 100644
index 0000000000..4852d1fa4e
--- /dev/null
+++ b/macros/latex/contrib/knowledge/knowledge-configuration.dtx
@@ -0,0 +1,252 @@
+% \iffalse meta-comment
+%
+% 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.
+%
+% \fi
+%
+% \iffalse
+%
+%<*driver>
+\documentclass{ltxdoc}
+\usepackage[utf8]{inputenc}
+\usepackage[T1]{fontenc}
+\usepackage{paralist}
+\EnableCrossrefs
+\CodelineIndex
+\RecordChanges
+
+\begin{document}
+\DocInput{knowledge-configuration.dtx}
+\end{document}
+%</driver>
+% \fi
+%
+% \CheckSum{0}
+%
+% \CharacterTable
+% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
+% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
+% Digits \0\1\2\3\4\5\6\7\8\9
+% Exclamation \! Double quote \" Hash (number) \#
+% Dollar \$ Percent \% Ampersand \&
+% Acute accent \' Left paren \( Right paren \)
+% Asterisk \* Plus \+ Comma \,
+% Minus \- Point \. Solidus \/
+% Colon \: Semicolon \; Less than \<
+% Equals \= Greater than \> Question mark \?
+% Commercial at \@ Left bracket \[ Backslash \\
+% Right bracket \] Circumflex \^ Underscore \_
+% Grave accent \` Left brace \{ Vertical bar \|
+% Right brace \} Tilde \~}
+%
+%
+% \changes{v2.0}{2016/02/26}{Initial version} %
+% \GetFileInfo{scopearticle.def} %
+% \DoNotIndex{}
+%
+%
+% \let\ifcode\iffalse
+%
+%
+% \title{The \textsf{knowledge-configuration} part of the \textsf{knowledge} package}
+% \author{Thomas Colcombet \\ \texttt{thomas.colcombet@irif.fr}}
+% \date{\today}
+% \maketitle
+%
+% \begin{abstract}
+% Some code for configuring the scope option of the package knowledge.
+% Essentially, it contains configurations for reconstructing the tree of the structure of the document. It is to be expanded when the use requires it.
+%
+% So far, it stands as a standalone file scopearticle.def. It should eventually be part of knowledge.sty, and be extra configurable (detect the style, and tries to automatically overload it).
+% \end{abstract}
+%
+% \section{Introduction}
+%
+% This package is in fact part of the code used by \texttt{knowledge} when the scope option is activated.
+% Its goal is to configure the hooks for the \texttt{article} class. It works also for similar classes.
+%
+% \StopEventually{\PrintIndex}
+%
+%
+%
+% This package patches the article class for making it compatible with
+% the scope package. Essentially, it modifies all the structure and the commands
+% that interact with the structure of an article, and weave into it the update of the
+% scope structure.
+%
+%
+% \section{Implementation}
+%
+% \subsection{Code preparation}
+% \begin{macrocode}
+\knowledge_begin_module_if:n\knowledge_option_scope_bool
+% \end{macrocode}
+%
+% \section{Main structure}
+%
+% Note that the scopes \texttt{base}, \texttt{document}, \texttt{body} and \texttt{scope} are already configured in knowledge.sty.
+%
+% \subsection{Standard sectioning command}
+%
+%
+% \begin{macrocode}
+\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} }
+% \end{macrocode}
+%
+% \begin{macrocode}
+\scope_area_set:nn{abstract}
+ {autoclose=false,
+ occurrences=once,
+ parents={body,structure},
+ forces=body,
+ knowledge=none
+}
+% \end{macrocode}
+% \subsubsection{Overloading the commands}
+%
+% \begin{macrocode}
+\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}}
+% \end{macrocode}
+%
+% \subsection{Creation of new environments}
+%
+%
+%
+% \begin{macrocode}
+\KnowledgeConfigureEnvironment?
+ {theorem,lemma,proposition,fact,conjecture,problem}
+ {category=theorem-like,label=accepts}
+\KnowledgeConfigureEnvironment?
+ {remark,proof}
+ {label=accepts,knowledge=accepts}
+\KnowledgeConfigureEnvironment?
+ {center,flushleft,flushright,minipage,quotation,quote,verbatim,verse}
+ {knowledge=accepts,label=none}
+% \end{macrocode}
+%
+% Command overloading...
+% \begin{macrocode}
+\OverloadCommand\newtheorem{m}
+ {\KnowledgeConfigureEnvironment!{#1}{category=theorem-like,label=accepts}
+ \SUPERnewtheorem{#1}}
+\OverloadCommand\newenvironment{m}
+ {\KnowledgeConfigureEnvironment!{#1}{label=accepts}
+ \SUPERnewenvironment{#1}}
+\OverloadCommand\NewDocumentEnvironment{m}
+ {\KnowledgeConfigureEnvironment!{#1}{label=none}
+ \SUPERNewDocumentEnvironment{#1}}
+% \end{macrocode}
+%
+%
+% \subsection{Upgrading scope}
+%
+% \subsection{Itemizing}
+% The default code for \LaTeX{} is absolutely catastrophic.
+% In particular, trivlist is used implicitly, making impossible to
+% simply Overload the list environements.
+% Indeed, some of environments (like theorems) use trivlists and |\item|
+% for their internal display. However, one does not want this to be considered
+% as a list. Futhremore, normal lists make call to the code of trivlist too.
+% Thus we are in the situation in which trivlists have to be patched because otherwise
+% items could not guarantee the structure.
+% However, trivlist should not be treates as norm lists since these are fake lists used
+% for displaying purposes. The below code tries to patch this as cleanly as possible in order
+% to obtain a reasonable behaviour.
+% \begin{macrocode}
+\scope_area_set:nn
+ {itemize,enumerate,description}
+ {category=itemize-like}
+% {knowledge=none}
+
+\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}}
+
+%\OverloadCommand\trivlist{}
+% {\scope_area_push:n{trivlist}
+% \SUPERtrivlist}
+
+%\OverloadCommand\endtrivlist{}{
+% \SUPERendtrivlist
+% \scope_categoryseq_pop_to:n{itemize-like}
+% \exp_args:NV\tl_if_eq:nnTF\scope_top_area_tl{trivlist}
+% {\scope_area_pop:n{trivlist}}{}}
+% \end{macrocode}
+% \subsubsection{Micro areas}
+% \begin{macrocode}
+\scope_area_set:nn{emph,textit,texttt,textbf}{
+ autoclose = false,
+ occurrences = multiple,
+ forces = body
+ }
+% \end{macrocode}
+%
+%
+% \begin{macrocode}
+\knowledge_end_module:
+% \end{macrocode}
+% \Finale
+
+
+
+