Debian Codegraph @

texmf-dist/source/latex/knowledge/knowledge-configuration.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2016 by Thomas Colcombet
4 % -----------------------------------
5 %
6 % This file may be distributed and/or modified under the
7 % conditions of the LaTeX Project Public License, either version 1.2 % of this license or (at your option) any later version.
8 % The latest version of this license is in:
9 %
10 % http://www.latex-project.org/lppl.txt
11 %
12 % and version 1.2 or later is part of all distributions of LaTeX
13 % version 1999/12/01 or later.
14 %
15 % \fi
16 %
17 % \iffalse
18 %
19 %<*driver>
20 \documentclass{ltxdoc}
21 \usepackage[utf8]{inputenc}
22 \usepackage[T1]{fontenc}
23 \usepackage{paralist}
24 \EnableCrossrefs
25 \CodelineIndex
26 \RecordChanges
27
28 \begin{document}
29 \DocInput{knowledge-configuration.dtx}
30 \end{document}
31 %</driver>
32 % \fi
33 %
34 % \CheckSum{0}
35 %
36 % \CharacterTable
37 % {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
38 % 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
39 % Digits \0\1\2\3\4\5\6\7\8\9
40 % Exclamation \! Double quote \" Hash (number) \#
41 % Dollar \$ Percent \% Ampersand \&
42 % Acute accent \' Left paren \( Right paren \)
43 % Asterisk \* Plus \+ Comma \,
44 % Minus \- Point \. Solidus \/
45 % Colon \: Semicolon \; Less than \<
46 % Equals \= Greater than \> Question mark \?
47 % Commercial at \@ Left bracket \[ Backslash \\
48 % Right bracket \] Circumflex \^ Underscore \_
49 % Grave accent \` Left brace \{ Vertical bar \|
50 % Right brace \} Tilde \~}
51 %
52 %
53 % \changes{v2.0}{2016/02/26}{Initial version} %
54 % \GetFileInfo{scopearticle.def} %
55 % \DoNotIndex{}
56 %
57 %
58 % \let\ifcode\iffalse
59 %
60 %
61 % \title{The \textsf{knowledge-configuration} part of the \textsf{knowledge} package}
62 % \author{Thomas Colcombet \\ \texttt{[email protected]}}
63 % \date{\today}
64 % \maketitle
65 %
66 % \begin{abstract}
67 % Some code for configuring the scope option of the package knowledge.
68 % Essentially, it contains configurations for reconstructing the tree of the structure of the document. It is to be expanded when the use requires it.
69 %
70 % 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).
71 % \end{abstract}
72 %
73 % \section{Introduction}
74 %
75 % This package is in fact part of the code used by \texttt{knowledge} when the scope option is activated.
76 % Its goal is to configure the hooks for the \texttt{article} class. It works also for similar classes.
77 %
78 % \StopEventually{\PrintIndex}
79 %
80 %
81 %
82 % This package patches the article class for making it compatible with
83 % the scope package. Essentially, it modifies all the structure and the commands
84 % that interact with the structure of an article, and weave into it the update of the
85 % scope structure.
86 %
87 %
88 % \section{Implementation}
89 %
90 % \subsection{Code preparation}
91 % \begin{macrocode}
92 \knowledge_begin_module_if:n\knowledge_option_scope_bool
93 % \end{macrocode}
94 %
95 % \section{Main structure}
96 %
97 % Note that the scopes \texttt{base}, \texttt{document}, \texttt{body} and \texttt{scope} are already configured in knowledge.sty.
98 %
99 % \subsection{Standard sectioning command}
100 %
101 %
102 % \begin{macrocode}
103 \scope_area_set:nn
104 {part, section,subsection,subsubsection,
105 paragraph,subparagraph,subsubparagraph}
106 { category=structure,
107 autoclose = true,
108 occurrences = multiple,
109 knowledge=accepts
110 }
111 \scope_area_set:nn
112 {base,document,section,subsection,subsubsection,
113 paragraph,subparagraph,subsubparagraph}
114 {knowledge=accepts}
115 \scope_area_set:nn
116 {base,document}
117 {knowledge=attracts}
118 \scope_area_set:nn
119 {body}
120 {knowledge=none}
121
122 \scope_area_set:nn{part}{parents = {body}, forces = body }
123 \scope_area_set:nn{section}{parents = {body,part}, forces = body }
124 \scope_area_set:nn{subsection}{parents = section }
125 \scope_area_set:nn{subsubsection}{parents = subsection }
126 \scope_area_set:nn{paragraph}{parents = {document,section,subsection,subsubsection} }
127 \scope_area_set:nn{subparagraph}{parents = {paragraph} }
128 \scope_area_set:nn{subsubparagraph}{parents = {subparagraph} }
129 % \end{macrocode}
130 %
131 % \begin{macrocode}
132 \scope_area_set:nn{abstract}
133 {autoclose=false,
134 occurrences=once,
135 parents={body,structure},
136 forces=body,
137 knowledge=none
138 }
139 % \end{macrocode}
140 % \subsubsection{Overloading the commands}
141 %
142 % \begin{macrocode}
143 \OverloadCommand\section{som}
144 {\scope_area_push:n{section}
145 \XparseArgs\SUPERsection{som}{#1}{#2}{#3}}
146 \OverloadCommand\subsection{som}
147 {\scope_area_push:n{subsection}
148 \XparseArgs\SUPERsubsection{som}{#1}{#2}{#3}}
149 \OverloadCommand\subsubsection{som}
150 {\scope_area_push:n{subsubsection}
151 \XparseArgs\SUPERsubsubsection{som}{#1}{#2}{#3}}
152 \OverloadCommand\paragraph{som}
153 {\scope_area_push:n{paragraph}
154 \XparseArgs\SUPERparagraph{som}{#1}{#2}{#3}}
155 \OverloadCommand\subparagraph{som}
156 {\scope_area_push:n{subparagraph}
157 \XparseArgs\SUPERsubparagraph{som}{#1}{#2}{#3}}
158 \OverloadCommand\subsubparagraph{som}
159 {\scope_area_push:n{subsubparagraph}
160 \XparseArgs\SUPERsubsubparagraph{som}{#1}{#2}{#3}}
161 % \end{macrocode}
162 %
163 % \subsection{Creation of new environments}
164 %
165 %
166 %
167 % \begin{macrocode}
168 \KnowledgeConfigureEnvironment?
169 {theorem,lemma,proposition,fact,conjecture,problem}
170 {category=theorem-like,label=accepts}
171 \KnowledgeConfigureEnvironment?
172 {remark,proof}
173 {label=accepts,knowledge=accepts}
174 \KnowledgeConfigureEnvironment?
175 {center,flushleft,flushright,minipage,quotation,quote,verbatim,verse}
176 {knowledge=accepts,label=none}
177 % \end{macrocode}
178 %
179 % Command overloading...
180 % \begin{macrocode}
181 \OverloadCommand\newtheorem{m}
182 {\KnowledgeConfigureEnvironment!{#1}{category=theorem-like,label=accepts}
183 \SUPERnewtheorem{#1}}
184 \OverloadCommand\newenvironment{m}
185 {\KnowledgeConfigureEnvironment!{#1}{label=accepts}
186 \SUPERnewenvironment{#1}}
187 \OverloadCommand\NewDocumentEnvironment{m}
188 {\KnowledgeConfigureEnvironment!{#1}{label=none}
189 \SUPERNewDocumentEnvironment{#1}}
190 % \end{macrocode}
191 %
192 %
193 % \subsection{Upgrading scope}
194 %
195 % \subsection{Itemizing}
196 % The default code for \LaTeX{} is absolutely catastrophic.
197 % In particular, trivlist is used implicitly, making impossible to
198 % simply Overload the list environements.
199 % Indeed, some of environments (like theorems) use trivlists and |\item|
200 % for their internal display. However, one does not want this to be considered
201 % as a list. Futhremore, normal lists make call to the code of trivlist too.
202 % Thus we are in the situation in which trivlists have to be patched because otherwise
203 % items could not guarantee the structure.
204 % However, trivlist should not be treates as norm lists since these are fake lists used
205 % for displaying purposes. The below code tries to patch this as cleanly as possible in order
206 % to obtain a reasonable behaviour.
207 % \begin{macrocode}
208 \scope_area_set:nn
209 {itemize,enumerate,description}
210 {category=itemize-like}
211 % {knowledge=none}
212
213 \scope_area_set:nn{item}
214 {autoclose=true,
215 parents = itemize-like}
216
217
218 \OverloadCommand\item{o}
219 {%\scope_categoryseq_pop_to:n{itemize-like}
220 %\scope_category_if_area_in:nnTF{trivlist}\scope_top_area_tl
221 % {}
222 % {\scope_area_push:n{item}}
223 \XparseArgs\SUPERitem{o}{#1}}
224
225 %\OverloadCommand\trivlist{}
226 % {\scope_area_push:n{trivlist}
227 % \SUPERtrivlist}
228
229 %\OverloadCommand\endtrivlist{}{
230 % \SUPERendtrivlist
231 % \scope_categoryseq_pop_to:n{itemize-like}
232 % \exp_args:NV\tl_if_eq:nnTF\scope_top_area_tl{trivlist}
233 % {\scope_area_pop:n{trivlist}}{}}
234 % \end{macrocode}
235 % \subsubsection{Micro areas}
236 % \begin{macrocode}
237 \scope_area_set:nn{emph,textit,texttt,textbf}{
238 autoclose = false,
239 occurrences = multiple,
240 forces = body
241 }
242 % \end{macrocode}
243 %
244 %
245 % \begin{macrocode}
246 \knowledge_end_module:
247 % \end{macrocode}
248 % \Finale
249
250
251
252