Debian Codegraph @

texmf-dist/doc/latex/knowledge/knowledge.tex

raw
1 \documentclass{ltxdoc}
2 \usepackage[utf8]{inputenc}
3 \usepackage[T1]{fontenc}
4 \usepackage{paralist}
5 \usepackage[svgnames]{xcolor}
6 \usepackage{expl3}
7 \usepackage{hyperref}
8 \usepackage{cleveref}
9 \usepackage{marginfix}
10 \usepackage[quotation,scope,silent]{knowledge}
11 \knowledgeconfigure{visible anchor points=false}
12 \knowledgeconfigure{notion,diagnose line=false}
13 \GetFileInfo{knowledge.sty}
14 \edef\knowledgeversiondate{\fileversion--\filedate}
15
16 \knowledgeconfigure{diagnose line=true}
17
18 % Depending on whether the file is included from knowledge-code.dtx
19 % or not, some configuration changes.
20 % This involves mainly the presence of the code.
21 % It also triggers the apparition of the todo list, and a top bar allowing
22 % faster navigation in the document.
23 \ExplSyntaxOn
24 \ifdefined\knowledgecode\expandafter\use_i:nn\else\expandafter\use_ii:nn\fi
25 {\def\producecode{\newpage\DocInput{knowledge-code.dtx}}
26 \cs_new_eq:cN{ifcodeTF}\use_i:nn}
27 {\def\producecode{}
28 \cs_new_eq:cN{ifcodeTF}\use_ii:nn}
29 \ExplSyntaxOff
30 % End of the parametrization.
31
32
33 \EnableCrossrefs
34 \CodelineIndex
35 \RecordChanges
36
37 \let\oldbibitem\bibitem
38 \renewrobustcmd\bibitem\oldbibitem
39
40
41
42 \expandafter\let\expandafter\item\csname switch item\endcsname
43
44 \ifcodeTF{
45 \NewDocumentCommand\textmenu{m}{#1}
46 \usepackage{eso-pic}% http://ctan.org/pkg/eso-pic
47 \AddToShipoutPictureFG{%
48 \AtPageUpperLeft{%
49 \put(\LenToUnit{0cm},\LenToUnit{-1em})
50 {%
51 \begin{tabular}[t]{p{21cm}}
52 \centering ---
53 \textmenu{\hyperref[paper:top]{top}} ---
54 \textmenu{\hyperref[section:status]{status version}} ---
55 \textmenu{\hyperref[section:toc]{toc}} ---
56 \ifcodeTF{\textmenu{\hyperref[section:todo]{todo list}} ---}
57 \textmenu{\hyperref[section:history]{history}} ---
58 \textmenu{\hyperref[section:quick start]{quick start}} ---
59 \textmenu{\hyperref[section:doc]{doc}} ---
60 \textmenu{\hyperref[section:faq]{FAQ}} ---
61 \textmenu{\hyperref[section:resources]{resources}} ---
62 \ifcodeTF{\textmenu{\hyperref[section:code]{CODE}} ---}{}
63 \end{tabular}%
64 }}}
65 }
66
67
68
69 % this is a hack. Introducing Hyphenation everywhere in a sequence of token.
70 % Otherwise the macro names tend to always exceed lines.
71 % It should be improved in order to always require at least--say--3 symbols before
72 % and after the hyphenation.
73 \ExplSyntaxOn
74 \cs_new:Nn\tl_fragilize:n
75 {\__tl_fragilize:N#1\q_stop}
76 \cs_new:Nn\__tl_fragilize:N
77 {\token_if_eq_meaning:NNTF#1\q_stop
78 {}{#1
79 \-\__tl_fragilize:N}}
80 \cs_set_eq:NN\textfragilize\tl_fragilize:n
81 \cs_new:Npn\Robustdisplay#1
82 {\exp_args:Nx\textfragilize{\robustdisplay{#1}}}
83 \ExplSyntaxOff
84
85
86 \NewDocumentCommand\ToImprove{m}{\marginpar{\textcolor{red}{To improve:} #1}}
87
88
89 \let\subsubsubsection\paragraph
90
91 \knowledge{[...]}{italic,color=gray}
92
93 \knowledge{notion}
94 | semigroup@ex1
95 | semigroups@ex1
96
97 \knowledge{notion}
98 | semigroup morphism@ex1
99
100
101 \knowledge{not implemented}{link=to be done}
102 \knowledge{to be done}{color=DarkRed}
103 \knowledge{|}{text=\vbar}
104 \knowledge{"[...]"}{italic,color=gray,md}
105
106 % Macros defined by knowledge
107 \knowledgedirective{kenvironment}{autoref,style=cs,intro style=csintro}
108
109
110
111 % directives
112 \knowledgestyle{directive}{up,md,typewriter,color=NavyBlue}
113 \knowledgestyle{directive intro}{up,md,typewriter,color=blue}
114 \knowledgedirective{directive}{autoref,style=directive,intro style=directive intro}
115
116 % options of the package
117 \knowledgestyle{option}{up,md,typewriter,color=NavyBlue}
118 \knowledgestyle{option intro}{up,md,typewriter,color=blue}
119 \knowledgedirective{option}{autoref,style=option,intro style=option intro}
120
121
122
123 \knowledgedirective{doc notion}
124 {autoref,style=doc notion,intro style=intro doc notion}
125 \knowledgestyle{doc notion}{color=DarkBlue}
126 \knowledgestyle{intro doc notion}{color=blue,emphasize}
127
128 \let\cs\undefined
129 \knowledgenewvariant\cs
130 {namespace=cs,
131 default style={autoref link,cs},
132 unknown style=cs unknown,
133 unknown style cont=cs unknown,
134 unknown warning=false,
135 unknown diagnose=true,
136 suggestion=cs,
137 PDF string={\detokenize{#1}}
138 }
139
140 %\knowledgestyle{cs}{wrap=\Robustdisplay,typewriter,up,md,color=NavyBlue}
141 %\knowledgestyle{cs unknown}{wrap=\Robustdisplay,typewriter,up,md,color=black}
142 \knowledgestyle{cs}{wrap=\detokenize,typewriter,up,md,color=NavyBlue}
143 \knowledgestyle{cs unknown}{wrap=\detokenize,typewriter,up,md,color=black}
144
145 \knowledgenewvariant\csintro
146 {namespace=cs,
147 auto knowledge={autoref,scope=document,also now},
148 default style={autoref target,csintro},
149 unknown style=csintro unknown,
150 unknown style cont=csintro unknown,
151 unknown warning=false,
152 unknown diagnose=false,
153 PDF string = {\detokenize{#1}}}
154 \knowledgestyle{csintro}{wrap=\Robustdisplay,typewriter,up,md,color=blue}
155 \knowledgestyle{csintro unknown}{wrap=\Robustdisplay,typewriter,up,md,color=black}
156
157 \knowledgenewvariant\csreintro
158 {namespace=cs,
159 default style=csintro,
160 unknown style=csintro unknown,
161 unknown style cont=csintro unknown,
162 PDF string = {\Robustdisplay{#1}}}
163
164
165
166 \knowledge{{@token}}{wrap=\Robustdisplay,up,md,typewriter,color=NavyBlue}
167
168
169
170
171
172
173 % style names
174 \knowledgedirective{notion style}{autoref,style=style,intro style=intro style}
175 \knowledgestyle{style}{typewriter,up,md,color=NavyBlue}
176 \knowledgestyle{intro style}{typewriter,up,md,color=blue}
177
178
179 \begin{scope}\label{style}
180 \knowledge{notion}{notion style}
181 \knowledge{intro notion}{notion style}
182
183 \knowledge{kl}{notion style}
184 \knowledge{kl unknown}{notion style}
185 \knowledge{kl unknown cont}{notion style}
186
187 \knowledge{intro}{notion style}
188 \knowledge{intro unknown}{notion style}
189 \knowledge{intro unknown cont}{notion style}
190 \knowledge{autoref not introduced}{notion style}
191 \knowledge{autoref reintroduced}{notion style}
192 \end{scope}
193
194
195 \knowledgedirective{kvariable}{style=cs}
196 \knowledge {experimental}{doc notion,color=gray}
197
198
199 %\ExplSyntaxOn
200 \NewDocumentCommand\robustdisplaycs{m}
201 {\expandafter\robustdisplay\csname#1\endcsname}
202
203
204
205
206 \knowledgeconfigure{quotation=false}
207 \knowledge{LaTeX}[latex|LATEX|Latex]{text=\LaTeX}
208 \knowledge{tex}[TeX|TEX]{text=\TeX}
209 \knowledge{pdflatex}{typewriter}
210
211 \knowledge"{text=\quotesymbol}
212 \knowledge{""}{text=\quotesymbol\quotesymbol}
213 \knowledgeconfigure{quotation=true}
214
215 \knowledge{AucTex}{typewriter}
216 \knowledge{smartparens}{typewriter}
217 \knowledge{Emacs}[emacs|EMACS]{typewriter}
218
219 \ExplSyntaxOff
220 \knowledgestyle{tt}{typewriter,up,md,color=NavyBlue}
221 \knowledgestyle{tt intro}{typewriter,up,md,color=blue}
222 \knowledgedirective{kcommand}{style=tt,intro style=tt intro,autoref}
223 \knowledgedirective{kquotation}{style=tt, intro style=tt intro,autoref}
224 \ExplSyntaxOn
225 \knowledge{"..."}{kquotation,text=\kl{"}$\cdots$\kl{"}}
226 \knowledge{""...""}{kquotation,text=\kl{""}$\cdots$\kl{""}}
227 \knowledge{{"...@..."}}{kquotation,text=\kl{"}$\cdots\arobas\cdots$\kl{"}}
228 \knowledge{{""...@...""}}{kquotation,text=\kl{""}$\cdots\arobas\cdots$\kl{""}}
229 \knowledge{{"...@@..."}}{kquotation,text=\kl{"}$\cdots\arobas\cdots\arobas\cdots$\kl{"}}
230 \knowledge{{""...@@...""}}{kquotation,text=\kl{""}$\cdots\arobas\cdots\arobas\cdots$\kl{""}}
231 \knowledge{{"...@...@..."}}{kquotation,text=\kl{"}$\cdots\arobas\cdots\arobas\cdots$\kl{"}}
232 \knowledge{{""...@...@...""}}{kquotation,text=\kl{""}$\cdots\arobas\cdots\arobas\cdots$\kl{""}}
233
234
235 \ExplSyntaxOn
236
237 \makeatletter
238 \let\arobas @
239 \makeatother
240 \knowledge{{@}}{kcommand,text=\arobas}
241
242
243
244 \knowledgedirective{people}{emphasize,color=DarkGray}
245 \knowledge{stackexchange}{people}
246 \knowledge{egreg}{people}
247
248 \knowledge{nesting_int}{kvariable}
249 \knowledge{count_int}{kvariable}
250 \knowledge{name_tl}{kvariable}
251 \knowledge{pushcode_tl}{kvariable}
252 \knowledge{popcode_tl}{kvariable}
253 \knowledge{autoclose_bool}{kvariable}
254 \knowledge{environment_bool}{kvariable}
255 \knowledge{recursive_bool}{kvariable}
256 \knowledge{multiple_bool}{kvariable}
257 \knowledge{acceptsknowledge_bool}{kvariable}
258 \knowledge{attractsknowledge_bool}{kvariable}
259 \knowledge{labelizable_bool}{kvariable}
260 \knowledge{scope_bool}{kvariable}
261 \knowledge{mandatorybase_seq}{kvariable}
262 \knowledge{instance.attractsknowledge_bool}{kvariable}
263
264
265 \ExplSyntaxOff
266
267 \begin{scope}\label{area}
268 \knowledge{nesting_int}{directive}
269 \knowledge{count_int}{directive}
270 \knowledge{name_tl}{directive}
271 \knowledge{pushcode_tl}{directive}
272 \knowledge{popcode_tl}{directive}
273 \knowledge{autoclose_bool}{directive}
274 \knowledge{environment_bool}{directive}
275 \knowledge{recursive_bool}{directive}
276 \knowledge{multiple_bool}{directive}
277 \knowledge{forces_tl}{directive}
278 \knowledge{acceptsknowledge_bool}{directive}
279 \knowledge{attractsknowledge_bool}{directive}
280 \knowledge{labelizable_bool}{directive}
281 \knowledge{scope_bool}{directive}
282 \knowledge{mandatorybase_seq}{directive}
283
284 \knowledge{autoclose=}{directive}
285 \knowledge{environment=}{directive}
286 \knowledge{parents=}{directive}
287 \knowledge{scope=}{directive}
288 \knowledge{label=}{directive}
289 \knowledge{push code=}{directive}
290 \knowledge{pop code=}{directive}
291 \knowledge{occurrences=}{directive}
292 \knowledge{forces=}{directive}
293 \end{scope}
294
295 \knowledge{instance.area}{kvariable}
296 \knowledge{instance.parent}{kvariable}
297
298
299
300
301 \knowledge{text=}{directive}
302 \knowledge{link=}{directive}
303 \knowledge{link scope=}{directive}
304 \knowledge{style=}{directive}
305 \knowledge{intro style=}{directive}
306 \knowledge{no index}[no index=]{directive}
307 \knowledge{wrap=}{directive}
308 \knowledge{scope=}{directive}
309 \knowledge{export=}[export]{directive}
310 \knowledge{now}{directive}
311 \knowledge{directive}
312 | automatic in command
313
314 \knowledge{protect link}{directive}
315 \knowledge{strict}{directive}
316 \knowledge{silent}{directive}
317 \knowledge{emphasize}{directive}
318 \knowledge{underline}{directive}
319 \knowledge{up}{directive}
320 \knowledge{md}{directive}
321 \knowledge{boldface}{directive}
322 \knowledge{fbox}{directive}
323 \knowledge{typewriter}{directive}
324 \knowledge{ensuretext}{directive}
325 \knowledge{ensuremath}{directive}
326 \knowledge{italic}[italic=]{directive}
327 \knowledge{smallcaps}[smallcaps=]{directive}
328 \knowledge{lowercase}{directive}
329 \knowledge{uppercase}{directive}
330 \knowledge{mathord}{directive}
331 \knowledge{mathbin}{directive}
332 \knowledge{mathop}{directive}
333 \knowledge{mathrel}{directive}
334 \knowledge{mathclose}{directive}
335 \knowledge{mathopen}{directive}
336 \knowledge{mathpunct}{directive}
337 \knowledge{synonym}{directive}
338 \knowledge{index=}{directive}
339 \knowledge{index key=}{directive}
340 \knowledge{index parent key=}{directive}
341 \knowledge{index style=}{directive}
342 \knowledge{index name=}{directive}
343 \knowledge{label scope}[label scope=]{option}
344 \knowledge{color=}{directive}
345 \knowledge{cyclic color}{directive}
346 \knowledge{colorbox=}{directive}
347 \knowledge{ref=}{directive}
348 \knowledge{url=}{directive}
349 \knowledge{autoref}{directive}
350 \knowledge{autorefhere}{directive}
351 \knowledge{namespace=}{directive}
352 \knowledge{autoref link}{directive}
353 \knowledge{autoref target}{directive}
354 \knowledge{also now}{directive}
355 \knowledge{notion}{directive}
356 \knowledge{no patch}{directive}
357 \knowledge{invisible=}[invisible]{directive}
358 \knowledge{detokenize}{directive}
359 \knowledge{remove space}{directive}
360 \begin{scope}\label{option}
361 \knowledge{hyperref}{option}
362 \knowledge{xcolor}{option}
363 \knowledge{makeidx}{option}
364 \knowledge{cleveref}{option}
365 \knowledge{scope}{option}
366 \knowledge{quotation}[quotation=]{option}
367 \knowledge{notion}{option}
368 \knowledge{cyclic colors=}{option}
369 \knowledge{imakeidx}{option}
370 \end{scope}
371
372 \knowledge{hyperref option}{link=hyperref,link scope=option}
373 \knowledge{makeidx option}{link=makeidx,link scope=option}
374 \knowledge{imakeidx option}{link=imakeidx,link scope=option}
375 \knowledge{cleveref option}{link=cleveref,link scope=option}
376 \knowledge{scope option}{link=scope,link scope=option}
377 \knowledge{xcolor option}{link=xcolor,link scope=option}
378 \knowledge{notion option}{link=notion,link scope=option}
379 \knowledge{quotation option}{link=quotation,link scope=option}
380
381
382 \knowledge{visible anchor points}[visible AP|visible AP=|visible anchor points=]{option}
383 \knowledge{anchor point shape}[anchor point shape=|AP shape=|AP shape]{option}
384 \knowledge{anchor point color}[anchor point color=|AP color=|AP color]{option}
385 \knowledge{anchor point shift}[anchor point shift=|AP shift=|AP shift]{option}
386 \knowledge{protect quotation}[protect quotation=]{option}
387 \knowledge{protect link co}{option,text=protect link}
388 \knowledge{unprotect link co}{option,text=unprotect link}
389 \knowledge{hyperlinks=}{option}
390 \knowledge{fix hyperref twocolumn}{option}
391 \knowledge{diagnose help=}[diagnose help]{option}
392 \knowledge{diagnose line=}[diagnose line]{option}
393 \knowledge{diagnose bar=}[diagnose bar]{option}
394
395
396 \knowledge{active}{option}
397 \knowledge{inactive}{option}
398 \knowledge{compatibility}{option}
399 \knowledge{auto}{option}
400
401 % options from external packages
402 \knowledgedirective{eoption}{typewriter}
403 \knowledge{svgnames}{eoption}
404 \knowledge{hidelinks}{eoption}
405 \knowledge{breaklinks}{eoption}
406
407 \knowledgedirective{package}{typewriter,color=DarkBlue}
408 \knowledge{CTAN}{color=darkgray,url={https://www.ctan.org/}}
409 \begin{scope}\label{package}
410 %\ExplSyntaxOn
411 %\def\mydebug{\tl_show:N\knowledge_knowledge_instance_tl}
412 %\ExplSyntaxOff
413 \knowledge{knowledge}{doc notion, package}
414 \knowledge{complexity}{package,url={https://www.ctan.org/pkg/complexity}}
415 \knowledge{expl3}{package,url={https://www.ctan.org/pkg/expl3}}
416 \knowledge{hyperref}{package,url={https://www.ctan.org/pkg/hyperref}}
417 \knowledge{acmart}{package,url={https://www.ctan.org/pkg/acmart}}
418 \knowledge{tikzcd}{package,url={https://www.ctan.org/pkg/tikz-cd}}
419 \knowledge{standalone}{package,url={https://www.ctan.org/pkg/standalone}}
420 \knowledge{xcolor}{package,url={https://www.ctan.org/pkg/xcolor}}
421 \knowledge{makeidx}{package,url={https://www.ctan.org/pkg/makeidx}}
422 \knowledge{imakeidx}{package,url={https://www.ctan.org/pkg/imakeidx}}
423 \knowledge{cleveref}{package,url={https://www.ctan.org/pkg/cleveref}}
424 \knowledge{etoolbox}{package,url={https://www.ctan.org/pkg/etoolbox}}
425 \knowledge{xparse}{package,url={https://www.ctan.org/pkg/xparse}}
426 \knowledge{amsmath}{package,url={https://www.ctan.org/pkg/amsmath}}
427 \knowledge{amssymb}{package,url={https://www.ctan.org/pkg/amssymb}}
428 \knowledge{mathcommand}{package,url={https://www.ctan.org/pkg/mathcommand}}
429 %\knowledge{tickzcd}{package,url={https://www.ctan.org/pkg/tickzcd}}
430 \end{scope}
431
432 \knowledge{arXiv}{package,url={https://arxiv.org/}}
433
434
435 \knowledgedirective{environment}{typewriter}
436 \begin{scope}\label{env}
437 \knowledge{scope}{kenvironment}
438 \knowledge{export}{kenvironment}
439 \knowledge{import}{kenvironment}
440 \knowledge{theorem}{environment}
441 \knowledge{tikzcd}{environment,ref=section:tikzcd}
442 \knowledge{thebibliography}{environment,ref=section:thebibliography}
443 \knowledge{document}{environment}
444 \knowledge{picture}{environment}
445 \end{scope}
446
447 \knowledge{variant directives}[variant directive|Variant directives]{doc notion}
448 \begin{scope}\label{variant}
449 \knowledge{directive}[directives|Directives]{link=variant directive}
450 \knowledge {namespace=}{directive}
451 \knowledge {default style=}{directive}
452 \knowledge {unknown style=}{directive}
453 \knowledge {unknown style cont=}{directive}
454 \knowledge {style directive=}{directive}
455 \knowledge {auto knowledge=}{directive}
456 \knowledge {unknown warning=}{directive}
457 \knowledge {unknown diagnose=}{directive}
458 \knowledge {suggestion=}{directive}
459 \knowledge {display code=}{directive}
460 \knowledge {PDF string=}{directive}
461 \knowledge {stared sequence}{doc notion}
462 \knowledge {modifier}[modifiers|Modifiers]{doc notion}
463 \end{scope}
464
465 \knowledge{align*}{typewriter}
466
467 %\knowledgedefault{index}
468 \knowledgedefault{}
469
470 \knowledge{label}{}
471
472 \knowledge{variant of \cs{\kl}}[variants of \cs{\kl}|Variants of \cs{\kl}|variants|variant]{doc notion}
473 \knowledge{scoping}[Scoping]{doc notion}
474 \knowledge{package option}[package options|Package options]{doc notion}
475 \knowledge{configuration option}[configuration options|Configuration options]{link=package option}
476 \knowledge{stack of visible scope instances}{notion}
477 \knowledge{quotation notation}{doc notion}
478 \ExplSyntaxOn
479 \def\klqn#1{{\kl[quotation~notation]{\tl_to_str:n{#1}}}}
480 \def\klbn#1{{\kl[`\vbar'-notation]{\tl_to_str:n{#1}}}}
481 \ExplSyntaxOff
482
483 \knowledge{`\vbar'-notation}{doc notion}
484 \knowledge{doc notion}
485 | jobname.kaux
486 | kaux file
487 \knowledge{undefined knowledge}[undefined knowledges|Undefined knowledges]{doc notion}
488 \knowledge{Non introduced autoref knowledge}{doc notion}
489 \knowledge{Duplicated intros}{doc notion}
490 \knowledge{doc notion}
491 | instance
492 | instances
493 | Instances
494 \knowledge{doc notion}
495 | explicit scope
496 | explicit scoping
497 | Explicit scopes
498 | explicit scopes
499 | Explicit scoping
500 \knowledge{directive}[directives|Directives]{doc notion}
501 \knowledge{area}[areas|Areas]{doc notion}
502 \knowledge{knowledge}[knowledges|Knowledges]{doc notion}
503 \knowledge{diagnose file}[diagnose|filename.diagnose]{doc notion}
504 \knowledge{.diagnose}{link=diagnose file,typewriter}
505 \knowledge{macro directive}[macro directives|Macro directives]{doc notion}
506 \knowledge{default directive}[default directives|Default directives]{doc notion}
507 \knowledge{knowledge style}[Knowledge styles|knowledge styles]{doc notion}
508 \knowledge{style}[styles|Styles|display style|display styles]{link=knowledge style}
509 \knowledge{category}[categories|Categories]{doc notion}
510 \knowledge{doc notion}
511 | scope
512 | scopes
513 | Scopes
514 \knowledge{doc notion}
515 | scopetag
516 | scopetags
517 \knowledge{namespace}[namespaces|Namespaces]{doc notion}
518 \knowledge{vertical mode}{doc notion}
519 \knowledge{debug mode}{doc notion}
520 \knowledge{knowledge macro}[Knowledge macros|knowledge macros]{doc notion}
521 \knowledge{anchor point}[anchor points|Anchor points]{doc notion}
522 \knowledge{configuration directive}[Configuration directives|configuration directives]{doc notion}
523
524 \knowledge {\knowledge namespace}{doc notion}
525 \knowledge {\knowledge knowledge name}{doc notion}
526 \knowledge {\knowledge optional scope}{doc notion}
527 \knowledge {\knowledge synonym name}{doc notion}
528 \knowledge {\knowledge synonyms}[\knowledge optional argument]{doc notion}
529 \knowledge {\knowledge directives}[knowledge directive]{doc notion}
530
531 \knowledge{option}
532 | composition mode
533 | composition
534 \knowledge {paper mode}[paper]{option}
535 \knowledge {electronic mode}[electronic]{option}
536
537 \knowledge {targeting directive}[targeting directives]{doc notion}
538 \knowledge {display directive}[display directives]{doc notion}
539 \knowledge {scope directive}[scope directives]{doc notion}
540
541 \knowledge {index key}{doc notion}
542 \knowledge {index entry}{doc notion}
543 \knowledge {main index entry}{doc notion}
544 \knowledge {table of contents}[toc]{doc notion}
545 \knowledge {knowledge name}{doc notion}
546 \knowledge {klab}{doc notion}
547 \knowledge {knowledge names}{synonym}
548 \knowledge {export file}{doc notion}
549 \knowledge {index}{doc notion}
550 \knowledge {warning styles}{doc notion}
551 \knowledge {default styles}{doc notion}
552 \knowledge {`Undefined knowledges' section}{link=undefined knowledge}
553 \knowledge {Autoref not introduced}{doc notion}
554 \knowledge {Autoref introduced twice}{doc notion}
555 \knowledge {scopept instances}{doc notion}
556 \knowledge {token list variable}{doc notion}
557 \knowledge {knowledgenow directives}{doc notion}
558 \knowledge {writing mode}[Writing modes|writing modes]{doc notion}
559
560 \knowledge {scope.sty}{link=scope option}
561
562
563 \knowledgedefault{}
564
565
566
567
568 \newtheorem{problem}{\textcolor{red}{\texttt{The problem}}}
569
570 \newenvironment{warning}{\medskip\par\noindent\textcolor{red}{\texttt{Warning!}}}{\medskip\par}
571
572 \newtheorem{remark}{Remark}
573
574 \newenvironment{hint}{\medskip\par\noindent\textbf{Hint.}}{\medskip\par}
575 \NewDocumentEnvironment{variation}{o}
576 {\medskip\par\noindent\textcolor{blue}{\texttt{Variation%
577 \IfNoValueF{#1}{ (\textcolor{DarkBlue}{#1})}%
578 .}}}{\medskip\par}
579
580
581 \newsavebox{\fminipagebox}
582
583 \NewDocumentEnvironment{cminipage}{m O{\fboxsep}}
584 {\par\kern#2\noindent\begin{lrbox}{\fminipagebox}
585 \begin{minipage}{#1}\ignorespaces}
586 {\end{minipage}\end{lrbox}%
587 \makebox[#1]{%
588 \kern\dimexpr-\fboxsep-\fboxrule\relax
589 \colorbox{Honeydew}{\usebox{\fminipagebox}}%
590 \kern\dimexpr-\fboxsep-\fboxrule\relax}\par\kern#2}
591
592 \NewDocumentEnvironment{fminipage}{m O{\fboxsep}}
593 {\par\kern#2\noindent\begin{lrbox}{\fminipagebox}
594 \begin{minipage}{#1}\ignorespaces}
595 {\end{minipage}\end{lrbox}%
596 \makebox[#1]{%
597 \kern\dimexpr-\fboxsep-\fboxrule\relax
598 \fbox{\usebox{\fminipagebox}}%
599 \kern\dimexpr-\fboxsep-\fboxrule\relax}\par\kern#2\relax}
600
601 \newenvironment{CODE}[1][12.4cm]
602 {\par
603 \noindent
604 \cminipage{#1}%
605 \tt
606 }{%
607 \endcminipage%
608 \par
609 }
610
611 \newenvironment{PDFoutput}[1][8.5cm]
612 {\begin{flushright}\begin{fminipage}{#1}}
613 {\end{fminipage}\end{flushright}\par}
614
615 \newcommand\smallcode[1]{\colorbox{Honeydew}{\texttt{#1}}}
616
617
618 \ExplSyntaxOn
619 \group_begin:
620 \catcode`| = 11%
621 \global\def\vbar{|}
622 \group_end:
623 \ExplSyntaxOff
624
625
626
627
628
629
630
631
632
633
634 \begin{document}
635 \label{paper:top}
636 \title{The \texttt{knowledge} package\\%
637 \small[\fileversion{} --- \filedate]}
638 \author{Thomas Colcombet \\ \texttt{[email protected]}}
639 \maketitle
640
641 \begin{abstract}\phantomintro(package){knowledge}%
642 The "knowledge@@package" package offers commands and notations for handling semantical notions in a document.
643 This allows to easily link the use of a notion to its definition, to add it to the index automatically, etc.
644 \end{abstract}
645
646 \ifcodeTF{\begin{quote}This version of the documentation includes a good part of the code. A casual user should \textit{a priori} not use this version of the documentation.\end{quote}}{}
647
648 \section*{Status of this version}
649 \label{section:status}
650 \begin{quote}
651 \begin{tabular}{ll}
652 \texttt{contact:}&\texttt{[email protected]}\\
653 \texttt{version:}&\texttt{\fileversion}\\
654 \texttt{date:}&\texttt{\filedate}
655 (documentation produced \today)\\
656 \texttt{license:}&\texttt{LaTeX Project Public License 1.2}\\
657 \texttt{web:}&\url{https://ctan.org/pkg/knowledge}\\
658 \texttt{CTAN:}&\url{https://www.ctan.org/pkg/knowledge}
659 \end{tabular}
660 \end{quote}
661 \newpage
662 \knowledgeconfigure{protect links}
663 \hypersetup{colorlinks=black}
664 \tableofcontents
665 \label{section:toc}
666 \knowledgeconfigure{unprotect links}
667
668 \newpage
669 \ifcodeTF{
670 \section{Todo list}
671 \label{section:todo}
672 This is essentially a list for personal referencing of what has to be done.
673 \begin{asparaitem}
674 \item deactivate quotation by default in the preamble in particular for avoiding clashes with commands such as \cs\DeclareMathDelimiter.
675 \item make knowledge compatible with beamer (request of Patrick Aiyao He), probably use hypertarget and hyperlink instead of hyperlabel and hyperref. Seems complicated because I do not know how to know if some material is going to be displayed, and this is necessary for a complete working solution.
676 I have seen Till Tantau who explained me how to test whether a material is displayed. This involves testing the counter |beamer@coveringdepth| which if higher than one when 'not displayed'.
677 |beamer@slideinframe| could also be intersting.
678 \item make quotation work properly in the titles of section...,
679 \item allow to protect quotation in commands, and not only environments (for instance xymatrix)
680 %\item remove the warnings about redefining commands
681 \item proper mathematics handling. Write a new \csintro{\NewDocumentCommand}-like macro
682 %\item detect using some trick that the previous compilation failed, and deactivate the Kaux file in this case
683 % (for the moment, removing the aux file deactivates the kaux file. This is convenient but not sufficient.)
684 %\item proper code for \cs{\nointro}.
685 \item improving the \cs{\AP} and \cs{\itemAP} commands. For the moment \cs{\AP} silently fails inside the
686 optional argument of \cs{\item}, and probably elsewhere too. See how this can be improved. I tried to use the \cs{inner_mode} test, but it also detects situations when where \cs{\AP} si allowed (like in minipage).
687 \item solve the \kl(package){amsmath} problem that \cs{\label} is deactivated in unnumbered environment, while knowledge would nevertheless like to point to the place...
688 \item Code export and import features.
689 \item Pointing inside an external pdf document.
690 \item Correct the use of parameters in a directive (see example 'highlight' below).
691 \item Make the boolean parameters in knowledges to properly handle the false case (removing the default).
692 \end{asparaitem}%
693 }{}
694
695 \newpage
696 %\newgeometry{left=3cm,bottom=0.1cm}
697 \section{History}
698 \label{section:history}
699 \small
700 \begin{compactdesc}
701 \item[2016-06-07] \verb|\knowledgemacro| is now renamed to \cs{\knowledgedirective}.
702 \item[2017-01-13] \cs{\AP} has been recoded, and is now more properly aligned in the margin. The \kl{visible anchor points} option has also been made usable without the \kl(package){xcolor} package.
703 \item[2017-01-13] The package \kl{scope option} can now be omitted. This in particular avoid clashes with the over-restriction on the structure of the document it entails. It should be improved to stop overloading the \cs{\begin} command.
704 \item[2017-01-14] The overloading of \cs{\begin} and \cs{\end} was done as protected commands, which should not be the case to be consistent with the behaviour of LaTeX (for instance, this was giving an extra line in the title in the conference mode of the class IEEEtran). Corrected: these commands are not protected anymore.
705 \item[2017-01-15] A workaround for an incompatibility between the "hyperref@@package" and the two-column mode as been added in the macro
706 \cs{\knowledgeFixHyperrefTwocolumn} (thanks to Daniela Petri\c san).
707 \item[2017-01-15] Added the \kl[\knowledge directives]{directive} \kl{synonym}.
708 \item[2017-01-15] Added the \texttt{noknowledge package} for minimizing the effects of not having "knowledge@@package" activated.
709 \item[2017-01-17] Changed the way options are handled, decoupling the package options (options of \cs{\usepackage}) from the configuration options (see \cs{\knowledgeconfigure}).
710 \item[2017-01-17] Proper treatment of `final' option and \kl[composition mode]{composition} options.
711 \item[2017-01-17] Added \cs{\IfKnowledgeFinalMode}\texttt{[TF]} commands for the user.
712 \item[2017-01-17] Added the option \kl{fix hyperref twocolumn} as a shorthand for calling \cs{\knowledgeFixHyperrefTwocolumn} (thanks to Daniela Petri\c san and Luca Reggio).
713 \item[2017-01-18] Added the configuration option \kl(option){notion} that offers a basic configuration compatible with \kl(package){xcolor} or not, and \texttt{final} and \kl{composition} modes.
714 \item[2017-01-19] Added \cs{\phantomintro} and an explanation on how to deal with \kl{align*}.
715 \item[2017-02-20] Removed the warnings of latex for unknown labels in \kl{autoref}.
716 \item[2017-02-20] Removed nasty error making \cs{\AP} not operative when anchor points were not visible.
717 \item[2017-02-21] Added the \kl{protect link} directive.
718 \item[2017-02-21] Added the \kl{hyperlinks=} configuration.
719 \item[2017-02-27] \kl{visible anchor points} is active by default now.
720 \item[2017-02-27] A simple example is now included.
721 \item[2017-02-28] Minor changes on the documentation.
722 \item[2017-02-28] Added the \kl(env){scope} environment.
723 \item[2017-02-28] Added the \kl{protect link co} and \kl{unprotect link co} \kl{configuration directives}.
724 \item[2017-02-28] Added the \cs{\knowledgeconfigureenvironment} command.
725 \item[2017-03-03] Added the \kl{breaklinks} faq (thanks to Luca Reggio for the request).
726 \item[2017-03-10] Added the \kl{"..."} and \kl{""...""} notations and the \kl(option){quotation} mode (requested by Gabriele Puppis and Andreas Krebs).
727 \item[2017-03-11] Added the \kl{"...@..."} and \kl{""...@...""} notations.
728 \item[2017-03-13] Corrected for being compatible with version of expl3 posterior to Mars 2015 (\verb|\c_sys_jobname_str| does not exist anymore). (Thanks to Jean-Éric Pin).
729 \item[2017-03-14] Corrected that the \verb|@| letter was left a letter after \cs{\knowledgeFixHyperrefTwocolumn}.
730 \item[2017-04-09] Internal change of code, for "scope" handling and for the "quotation notation": slowly going toward an extended "quotation notation" that can make the "scope" of search explicit.
731 \item[2017-04-09] Added the \kl{protect quotation} configure option, that is given a list of environments, and deactivates automatically the "quotation notation" when in there environments. This is a simple code for the moment. Typically, one can use \smallcode{\cs\knowledgeconfigure\{\kl{protect quotation}=tikzcd\}}. For the moment, it is not explained in the document.
732 \item[2017-04-19] Changed the display code such that nested knowledges behave properly: before, the introduction would be performed for the object and the subobjects.
733 \item[2017-04-20] The "electronic mode" has been added, and the `\texttt{final mode}' is now renamed into "paper mode". The \cs{\knowledgepackagemode} configuration variable is also available for easier scripting.
734 \item[2017-06-06] FAQ on deactivating the quote in "Emacs" (thanks to Sylvain Perifel).
735 \item[2017-06-08] Removed the \texttt{noknowledge} package and all references to it.
736 \item[2017-06-08] Removed the \texttt{knowledgeutils.sty} and \texttt{scopearticle.sty} which are now integrated in the main file.
737 \item[2017-06-08] The file \texttt{knowledge-example.tex} has been improved.
738 \item[2017-06-09] First release of version 1.0 on "CTAN".
739 \item[2017-06-10] Corrected the "quotation notation" to make it expandable for avoiding problems in table of contents (the @ was not working).
740 \item[2017-06-11] Corrected a bug linked to changes of expl3 on recent distributions (pointed by Murray Eisenberg). Release of v1.01 on CTAN.
741 \item[2017-06-27] Overloaded labels now perform an expansion of the argument (this was causing problems with biblatex).
742 \item[2017-06-28] Options \texttt{log-declarations} of "xparse@@package" package removed (causing clash with other packages, as pointed by Juliusz Chroboczek). Release of v1.02 on CTAN.
743 \item[2017-06-30] added the field \texttt{\robustdisplay{labelizable_bool}} to areas. Coded missing features of scoping. Now the "scope=" directive works with as parameter an enclosing "area", or a label.
744 \item [2017-06-30] Added in the source a Regression subdirectory containing files to be tested (so far only one: regression-scope.tex)
745 \item [2017-07-01] Corrected a conflict between the "scope@@option" and "makeidx@@option" option.
746 \item [2017-07-03] Scoping becomes operational.
747 \item [2017-07-04] The documentation for "notion@@style" and "intro notion@@style" are added (thanks to Fabian Reiter).
748 \item [2017-07-09] Added boolean \cs{environment_bool} field to "areas", in order to resolve an incompatibility with the package "standalone@@package" noticed by Fabian Reiter.
749 \item [2017-07-20] "Scoping" becomes fully operational, with the parenthesis notation of \cs{\kl} and \cs{\intro}. The use of scope has been recoded. Now scope links reuse implicitly the key as a link. Documentation updated.
750 \item[2017-07-26] File and line numbers added in the "kaux file". Added the option "diagnose line=" to deactivate it.
751 \item[2017-07-26] Corrections to the documentation. Version 1.03 on CTAN.
752 \item[2017-07-28] Corrected a bug of scoping in the context of synonyms. Added ctan for producing the ctan zip file.
753 \item[2017-08-06] Now passes the compliance test \texttt{check-declarations} of "expl3@@package"
754 (thanks to Marc Zeitoun)
755 \item[2017-09-12] The "hidelinks" option of "hyperref@@package" is now always activated.
756 \item[2017-09-25] Ancient version of "xparse@@package" does not have \cs{\NewExpandableDocumentCommand}. Corrected. Version 1.05 on "CTAN".
757 \item[2017-10-10] Bug in the implementation of \cs{\knowledgenewvariant} (that was invisible for older versions of "expl3@@package"). Found and corrected (thanks to Marc Zeitoun). Version 1.06 on "CTAN".
758 \item[2017-10-15] Diagnose extended (suggested by Fabian Reiter). Minor corrections. Version 1.07 on "CTAN".
759 \item[2017-10-17] Added "cyclic color" and "cyclic colors=@@option". Reorganization of the structure of the code for producing a better "CTAN" archive. Version 1.08 on "CTAN".
760 \item[2018-01-31] Added the "strict" configuration option.
761 \item[2018-02-05] Added the "smallcaps" formatting directive.
762 \item[2018-02-17] Corrected incompatibility with latest version of "expl3@@package". Version 1.10 on "CTAN".
763 \item[2018-02-21] Bug correction concerning the activation of scopes.
764 \item[2018-02-21] Documentation improvement for "Emacs" (thanks to Michaël Cadilhac).
765 \item[2018-02-24] Documentation improvement for the environment "thebibliography@@env".
766 \item[2018-05-17] Correction to be compatible with the latest version of "expl3@@package" (thanks to Leo Stefanesco).
767 \item[2018-07-26] Compatibility with utf8 symbols in labels (thanks to Yves Guiraud).
768 \item[2018-11-22] Corrected bug for "makeidx@@option" (thanks to Sylvain Schmitz). V1.14 on "CTAN".
769 \item[2019-01-27] Minor improvement of the doc, and hiding links in it. V1.15.
770 \item[2019-02-15] Correction of a placement problem with \cs\AP. V1.16.
771 \item[2019-05-23] Adding of the "`\vbar'-notation" for the \cs{\knowledge} command.
772 "Explicit scopes" are introduced. Updating of the documentation. "up" directive in math mode now silently does nothing, and \cs{\knowledgedirective} now forbids redefinitions by default (thanks to Léo Stefanesco).
773 \item[2019-07-02] Removing the `\texttt{kl}' and `\texttt{intro}' styles that prevented a proper configuration of "intro notion@@style" (thanks to Léo Stefanesco).
774 \item[2019-10-03] Update of the documentation, and V1.17.
775 \item[2019-10-27] Bug correction and added the `\textbf{patch label}' configuration directive (thanks to \href{https://becca.ooo/}{Rebecca Turner}). V1.18.
776 \item[2019-11-19] Now the labels are evaluated before being written to the "kaux file" in a \cs\KAuxNewLinkScopetagInstance\ command (bug fix). V1.19.
777 \item[2019-11-29] Help added in the "diagnose file". \textbf{bar suggestion} (still working) renamed to "diagnose bar", and activated by default. \textbf{patch label} is renamed into "label scope".
778 \item[2019-12-02] The "kaux file" is now checked for completeness before being used. This should avoid errors when the previous compilation failed.
779 \item[2019-12-03] Corrected bug in the scope access. V1.20.
780 \item[2020-01-25] Corrected bug when "knowledge@@package" is used without "hyperref@@package" (thanks to Rémi Nollet).
781 \item[2020-01-25] Corrected bug that made the kaux file not stabilize (thanks to Rémi Nollet). V1.21 on CTAN.
782 \item[2020-03-05] Now \texttt{hidelinks} and \texttt{breaklinks} are automatically activated unless the new option \kl{no patch} is activated. Doc update. V1.22 on CTAN.
783 \item[2020-04-25] Made the package compatible with 2016 versions of LaTeX. Useful when \texttt{knowledge.sty} is included with and compile in arXiv. V1.23 on CTAN.
784 \item[2020-05-02] Doc update ("acmart@@package" colors, thanks to Daniela Petri\c san).
785 \item[2020-09-22] Adding the "silent" option as suggested by Patrick Lambein-Monette. V1.24.
786 \item[2021-03-31] Correcting a bug caused by a change of semantics in "expl3@@package". V1.25.
787 \item[2021-05-25] Added the \cs\kref, \cs\kpageref, \cs\kcref, and \cs\kCref\ commands as suggested by Ziv Scully.
788 \item[2021-05-26] Corrected wrongly used default parameter in \cs\knowledgedirective.
789 \item[2021-05-27] The explicit text given in a \cs\kl-command now overrides the "text=" directive.
790 \item[2021-07-18] Adding the "no index" directive.
791 \item[2021-12-20] Adding options "anchor point shape", "anchor point color", "anchor point shift" (request of Rémi Morvan).
792 \item[2021-12-27] Bug correction for corner shape, and doc update (thanks to Rémi Morvan).
793 \item[2022-01-12] Minor changes. Removing dead link for the webpage. V1.27
794 \item[2022-02-12] Adding support of "imakeidx@@package" and the directive "index name=" (request and code change by Maximilian Keßler). V1.28
795 \item[2024-03-10] Correcting typographic bug of \cs\withkl\ and \cs\cmdkl\ when in combination with e.g. \cs\mathrel\ (suggested by Rémi Morvan). V1.29
796 \item[2025-02-20] Correcting macro bug with \cs\KnowledgeNewDocumentCommand\ (thanks to Sarah Winter). V1.30
797 \item[2025-05-09] Correcting display bug with "makeidx@@option" (thanks to Rémi Morvan). V1.31
798 \item[2026-02-24] Adding in the documentation a patch for "smartparens" in "emacs" (thanks to Quentin Aristote).
799 \item[2026-04-02] Adding optional parameter to \cs\label\ hook for compatibility with "cleveref@@package"; adding directory name to the origin of lines (asked by Dorian Lesbre).
800 \end{compactdesc}
801 \normalsize
802 %\restoregeometry
803
804
805
806 \newcommand{\filluptopage}[1]{%
807 \clearpage
808 \loop\ifnum\value{page}<#1\relax
809 \null\clearpage
810 \repeat
811 }
812 \filluptopage{4}
813
814
815 \section{Quick start}
816 \label{section:quick start}
817
818 \leavevmode
819 \AP
820 The "knowledge@@package" package offers several capabilities for handling colors, changing the display style, defining internal and external hyperlinks, producing an index, etc...
821 All these possibilities arise from defining explicitly or implicitly \kl{knowledges} associated to terms in plain english (or other languages).
822
823 We start by describing a certain number of problems/scenarii that a user may be confronted to, and show how to solve them.
824 %The hyperlinks in this document have been generated using the "knowledge@@package" package.
825 In the subsequent sections, a more detailed account of how the "package@knowledge@package" works and can be parameterized is given.
826
827 There is also a file \texttt{knowledge-example.tex} that can be used as a starting point.
828
829 \subsection{Linking to outer documents/urls, and to labels}
830
831 \medskip
832 \begin{problem}
833 I have a lot of external url's that I would like to [[very] often] have a link to, but I do not want to
834 always type the full url. I do not want to remember weird labels/internal references/macro names either.
835 \end{problem}
836 \medskip
837
838 A solution is as follows. One first loads the "knowledge@@package" package with option
839 \kl(option){hyperref}
840 using either:
841 \marginpar{\begin{hint}
842 You may use other options like \kl(option){xcolor} for allowing debugging with colors (for undefined knowledges).
843 \end{hint}}
844 \begin{CODE}[8cm]
845 \cs{\usepackage}["hyperref@@package",\kl(option){quotation}]\{"knowledge@@package"\}
846 \end{CODE}
847 \noindent or equivalently:
848 \begin{CODE}[8cm]
849 \cs\usepackage\{\kl(package){hyperref}\}\\
850 \cs\usepackage[\kl(option){quotation}\footnote{If you want to use the \kl{"..."} notation.}]\{"knowledge@@package"\}
851 \end{CODE}
852
853 Then, in the preamble (or in an external file), one uses commands of the form either:
854 \begin{CODE}
855 \cs\knowledge\{\kl{url=}\{https://en.wikipedia.org/wiki/LaTeX\}\}\par
856 \qquad\kl{|}\quad latex
857 \end{CODE}
858 This configures the text `\texttt{latex}' to be associated with the sole directive \kl{url=},
859 which means an hyperreference to this address.
860
861 Finally in the body of the paper, the sole extra command \cs{\kl} (or the \kl"-symbol if the \kl(option){quotation} option is activated) is used,
862 with as parameter a text. This text is searched for, and the directives attached to it (here "url="),
863 are used for formatting its printing\footnote{This resembles a lot a macro so far. It nevertheless differs in that: (a) if not defined, it does not make the compilation fail as a macro would, and thus does not interfere with the writing process, (b) any text can be used and not only alphabetic letters as in default \TeX, (c) you do not have to care about the space after, and (d)
864 in fact the machinery for resolving the meaning of a knowledge is much more powerful than simple macro expansion.}.
865 Hence:
866 \marginpar{\begin{hint}
867 If the knowledge is not defined, this does not make the compilation fail.
868 In fact, it is good practice to use many \cs{\kl} commands or \kl{"..."} notations while writing a text,
869 and only resolve these questions at the end (see also the \kl{diagnose file}).
870 \end{hint}}
871 \begin{CODE}[10cm]
872 This package has been written for use in \cs\kl\{latex\}.
873 \end{CODE}\noindent
874 or, if the \kl(option){quotation} option is activated,
875 \begin{CODE}[10cm]
876 This package has been written for use in \kl{"}latex\kl{"}.
877 \end{CODE}\noindent
878 yields
879 \knowledge{urllatex}{url=https://en.wikipedia.org/wiki/LaTeX,color=black}
880 \begin{PDFoutput}
881 This package has been written for use in \kl[urllatex]{latex}.
882 \end{PDFoutput}
883
884 \begin{variation}
885 But in fact, I would like `\texttt{latex}' to also be properly typeset \LaTeX{}, and in \textcolor{gray}{gray}.
886 This requires to load the package with the \kl(option){xcolor} option (for being able to use colors, obviously), or by loading the package "xcolor@@package" before, and then modify the \cs{\knowledge} command using
887 extra "directives":
888 \begin{CODE}%[10.9cm]
889 \cs\knowledge\{\kl{url=}\{https://en.wikipedia.org/wiki/LaTeX\},\par
890 \qquad~\qquad\kl{text=}\cs\LaTeX,~\kl{color=}gray\}\par
891 \qquad\kl{|}\quad latex
892 \end{CODE}
893 \noindent
894 yields with the same text
895 \knowledge{urllatexgray}{url=https://en.wikipedia.org/wiki/LaTeX, color=gray, text=\LaTeX}
896 \begin{PDFoutput}
897 This package has been written for use in \kl[urllatexgray]{LaTeX}.
898 \end{PDFoutput}
899
900 The \kl[\knowledge directives]{directives} \kl{text=} and \kl{color=} have quite obvious meaning.
901 \kl{Directives} can also control the style using \kl{emphasize}, \kl{boldface}, \kl{italic},
902 \kl{typewriter} and so on. See Section~\ref{subsection:directive list} for a complete list of "directives@knowledge directive".
903 \end{variation}
904 \begin{variation}[synonyms]
905 It happens very often that there are several ways to name a notion, because of capitalized letters, conjugacy, grammar, or simply because it is not explicitly named in the text. There are two ways to resolve this issue. The first is to use the syntax
906 \begin{center}
907 \smallcode{\cs\kl[\textit{knowledge}]\{\textit{text}\}}\qquad or\qquad\smallcode{\kl"\textit{text}\kl @\textit{knowledge}\kl"}
908 \end{center}
909 the result is that the text `\textit{text}' is displayed, but urls, colors, etc from `\textit{knowledge}' are used.
910
911 Another more systematic way to do it is to declare synonyms.
912 This obtained by adding the corresponding lines:
913 \begin{CODE}[4.35cm]
914 \cs{\knowledge}\{"url="\dots\}\\
915 \indent~\vbar~Donald Ervin Knuth\\
916 \indent~\vbar~Donald Knuth\\
917 \indent~\vbar~D. Knuth\\
918 \indent~\vbar~Knuth
919 \end{CODE}
920 \noindent would allow
921 \begin{center}
922 \smallcode{\cs\kl\{Knuth\}}~~~as well as~~~\smallcode{\cs\kl\{Donald Knuth\}},\\
923 or simply \smallcode{\kl"Knuth\kl"}~~~as well as~~~\smallcode{\kl"Donald Knuth\kl"} and so on
924 \end{center} to all point to the same web address.
925 It is even more convenient to use it for nouns that are sometimes in plural form or at the beginning of a sentence. There is also a scoping feature that helps distinguishing the same names in a different context. For instance:
926 \begin{CODE}[12.4cm]
927 \cs\knowledge\{\kl{url=}https://en.wikipedia.org/wiki/Group\_(mathematics)\}
928 \qquad\indent~~~\vbar~~group\\
929 \qquad\indent~~~\vbar~~groups\\
930 \qquad\indent~~~\vbar~~Groups\\
931 \qquad\indent~~~\vbar~~group morphism\\
932 \qquad\indent~~~\vbar~~group morphisms\\
933 \qquad\indent~~~\vbar~~Group morphisms\\
934 \qquad\indent~~~\vbar~~morphism@GROUP\\
935 \qquad\indent~~~\vbar~~morphisms@GROUP\\
936 \qquad\indent~~~\vbar~~Morphisms@GROUP
937 \end{CODE}
938 \end{variation}
939 \noindent
940 makes it possible to use the notions in many contexts:
941 \begin{CODE}
942 \kl"Groups\kl" form a category when equipped with \kl"group morphisms\kl". Consider now some \kl"morphism@@GROUP\kl" \$\cs\alpha\$ ...
943 \end{CODE}
944 In the above code all quoted parts send the reader to the same wikipedia page about groups.
945 Note in particular that \smallcode{\kl"morphism@@GROUP\kl"} simply displays `morphism' at compilation.
946 The \smallcode{GROUP} part is a "scope".
947 In another part of the document, \smallcode{\kl"morphism@@RING\kl"} can be safely used whereas using an generic \smallcode{\kl"morphism\kl"} would become quickly unmanageable.
948
949
950
951 \subsection{Linking inside a document}
952
953
954 \begin{problem}
955 I am writing a scientific document with many different definitions, typically a journal article, a PhD thesis\footnote{Reviewers should appreciate...}, or a book.
956
957 I would like all the notions to be linked inside the document for being able
958 in one click, whenever something is used, to jump to its definition. I also want to easily write an index.
959 However, I do not want it to be a hassle when writing.
960 \end{problem}
961 \medskip
962
963
964 A solution is as follows. First load the "knowledge@@package" package in the preamble:
965 \begin{CODE}[11cm]
966 \cs\usepackage[\kl(option){xcolor},\kl(option){hyperref},\kl(option){notion},\kl(option){quotation}]\{"knowledge@@package"\}
967 \end{CODE}
968 \noindent with suitable options: \kl(option){hyperref} for links,
969 \kl(option){xcolor} for colors (if required, but always advised), "quotation@@option" for using the "quotation notation" and \kl(option){notion} for automatic configuration of the "notion" "directive".
970
971 %
972 %
973 Then write the document using \cs{\intro} (or \kl{""...""} if \kl(option){quotation} is activated) when a notion is defined/introduced, and
974 \marginpar{\begin{hint} Using an \cs{\AP} command is strongly advised,
975 and allows to control more precisely where the target of hyperreferences is: at the beginning of a paragraph is better than the beginning of the section several pages before...\end{hint}}
976 \cs{\kl} (or \kl{"..."} if \kl(option){quotation} is activated) when it is used. For instance:
977 \begin{CODE}[12cm]
978 \cs\AP{}
979 A \cs\intro\{semigroup\} is an ordered pair \verb|$(S,\cdot)$| in which \verb|$S$| is a set and \verb|$\cdot$| is an
980 associative binary operator over~\verb|$S$|. A \cs\intro\{semigroup morphism\} is "[...]"\\
981 "[...]"\\
982 Consider a \cs\kl\{semigroup morphism\} between \cs\kl\{semigroups\} \verb|$S$| and \verb|$T$|. "[...]"
983 \end{CODE}
984 \noindent or when the "quotation notation" is activated:
985 \begin{CODE}[12cm]
986 \cs\AP{}
987 A \kl{""}semigroup\kl{""} is an ordered pair \verb|$(S,\cdot)$| in which \verb|$S$| is a set and \verb|$\cdot$| is an
988 associative binary operator over~\verb|$S$|.
989 \cs\AP{}
990 A \kl{""}semigroup morphism\kl{""} is "[...]"\\
991 "[...]"\\
992 Consider a \kl"semigroup morphism\kl" between \kl"semigroups\kl" \verb|$S$| and \verb|$T$|. "[...]"
993 \end{CODE}
994
995 This yields
996 \knowledgeconfigure{visible anchor points=true}%
997 \marginpar{Note that the \cs{\AP} command is made visible thanks to a red corner. This red corner is shifted left in order to fall in the margin.}
998 \begin{PDFoutput}[11cm]
999 \AP A \intro[_semigroup]{semigroup} is an ordered pair $(S,\cdot)$ in which~$S$ is a set and $\cdot$ is an
1000 associative binary operator over~$S$.
1001 \AP A \intro[_semigroup morphism]{semigroup morphism} is "[...]"\\
1002 "[...]"\\
1003 Consider a \kl[_semigroup morphism]{semigroup morphism} between \kl[_semigroups]{semigroups} $S$ and $T$. "[...]"
1004 \end{PDFoutput}
1005 \knowledgeconfigure{visible anchor points=false}%
1006 \marginpar{"Undefined knowledges" also yield warnings during the compilation. These can be avoided using the "silent" option.}%
1007 \kl{Undefined knowledges} are displayed in orange the first time, and in brown the subsequent ones (it is an important feature that the compilation does not fail: undefined knowledges should not interfere with the main activity of the writer which is writing).
1008 One can now see the list of such problems in the file `\kl{filename.diagnose}', in particular in the "`Undefined knowledges' section":
1009 \begin{verbatim}
1010 \knowledge{ignore}
1011 | semigroup
1012 | semigroups
1013 | semigroup morphism
1014 \end{verbatim}\noindent
1015 which means that the strings `\texttt{semigroup}', `\texttt{semigroups}' and `\texttt{semigroup morphism}' are used but unknown knowledges.
1016
1017 \AP
1018 To solve this, let us copy these four lines in the preamble\footnote{It is good practice to use a separate file, something like `paper-knowledge.tex'.}, replacing ignore by the \kl{notion} \kl{directive} and separating it into two blocks. We obtain:
1019 \begin{CODE}[6.7cm]
1020 \cs\knowledge\{\kl{notion}\}\\
1021 \indent~~~\klbn|~~semigroup\\
1022 \indent~~~\klbn|~~semigroups\\
1023 \cs\knowledge\{\kl{notion}\}\\
1024 \indent~~~\klbn|~~semigroup morphism
1025 \end{CODE}
1026 \noindent
1027 This informally means that `\texttt{semigroup}' and `\texttt{semigroups}' are two strings that represent the same notion, and that
1028 `\texttt{semigroup morphism}' is a different one.
1029
1030 The result is then (after two compilations):
1031 %
1032 \knowledgeconfigure{visible anchor points=true}%
1033 \marginpar{Note that the \cs{\AP} command is made visible thanks to a red corner.}
1034 \begin{PDFoutput}[11cm]
1035 \AP A \intro(ex1){semigroup} is an ordered pair $(S,\cdot)$ in which~$S$ is a set and $\cdot$ is an
1036 associative binary operator over~$S$.
1037 \AP A \intro(ex1){semigroup morphism} is "[...]"\\
1038 "[...]"\\
1039 Consider a \kl(ex1){semigroup morphism} between \kl(ex1){semigroups} $S$ and $T$. "[...]"
1040 \end{PDFoutput}
1041 \knowledgeconfigure{visible anchor points=false}%
1042 %
1043 Clicking on `semigroups' now jumps to the place where it was introduced, and very precisely at the
1044 location of the red corner depicting the presence of the \cs{\AP}-command before. The same goes for `semigroup morphism'.
1045 If now one adds the option \kl{electronic} while loading the package, then the red corners disappear as well as the undefined knowledges which become black. When using the option \kl{paper}, the links are still there, but all texts are in black.
1046
1047 A more complete example would look as follows:
1048 \begin{CODE}[6.7cm]
1049 \cs\knowledge\{\kl{notion}\}\\
1050 \indent~~~\klbn|~~semigroup\\
1051 \indent~~~\klbn|~~semigroups\\
1052 \indent~~~\klbn|~~Semigroups\\
1053 \cs\knowledge\{\kl{notion}\}\\
1054 \indent~~~\klbn|~~semigroup morphism\\
1055 \indent~~~\klbn|~~semigroup morphisms\\
1056 \indent~~~\klbn|~~morphism@SG\\
1057 \indent~~~\klbn|~~morphisms@SG
1058 \end{CODE}\noindent
1059 The most interesting part consists of the two last lines. These define `\texttt{morphism}' and `\texttt{morphisms}' to represent the same notion as `\texttt{semigroup morphism}' when in the scope `\texttt{SG}' (a convenient abbreviation chosen by the writer for meaning `semigroup'). This is particularly useful for separating morphisms of semigroups from, say, ring morphisms.
1060 Now, using \smallcode{Take a \cs\kl\{morphism\} ...} would yield an unknown knowledge. However,
1061 \smallcode{Take a \cs\kl(SG)\{morphism\} ...} or \smallcode{Take a \kl"morphism@@SG\kl" ...} would yield
1062 \begin{PDFoutput}[6cm]
1063 Take a \kl(ex1)[semigroup morphism]{morphism} ...
1064 \end{PDFoutput}\noindent
1065 which is properly linked to a semigroup morphism.
1066 One can in particular imagine that \smallcode{\kl"morphism@@RG\kl"} would instead represent ring morphisms.
1067
1068 Sometimes, one does not want to expand the knowledge base because the word is not specific. For instance
1069 \smallcode{These \cs\kl[semigroup]\{algebraic objects\} "[...]"}, or
1070 \smallcode{These \kl"algebraic objects@semigroup\kl"\} "[...]"},
1071 yields
1072 \begin{PDFoutput}[6cm]
1073 These \kl(ex1)[semigroup]{algebraic objects} "[...]"
1074 \end{PDFoutput}\noindent
1075 The term is properly linked to the definition of semigroups.
1076
1077 Another possibility is to refer to the location of the definition, using commands \cs\kref, \cs\kpageref, and even better their improvements \cs\kcref, \cs\kCref, etc (when using the "cleveref@@option" package). For instance,
1078 \begin{CODE}
1079 \kl"Semigroups\kl" are introduced in \cs\kCref\{semigroup\},\\ Page~\cs\kpageref\{semigroup\}.
1080 \end{CODE}
1081 \noindent yields:
1082 \begin{PDFoutput}[10cm]
1083 \kl(ex1)[semigroups]{Semigroups} are introduced in \kCref(ex1){semigroups},
1084 Page~\kpageref(ex1){semigroups}.
1085 \end{PDFoutput}
1086 Finally, in particular for large documents, it is good to have an "index". For this,
1087 one should load the package "makeidx@@package" before "knowledge@@package".
1088 Then use it normally: putting \cs{\makeindex} in the preamble and \cs{\printindex} at the end of the document.
1089 Finally, the \cs{knowledge} commands are adapted in a straightforward manner:
1090 \begin{CODE}[10.7cm]
1091 \cs\knowledge\{\kl{notion},"index="semigroup\}\\
1092 \indent~~~\klbn|~~semigroup\\
1093 \indent~~~\klbn|~~semigroups\\
1094 \indent~~~\klbn|~~Semigroups\\
1095 \cs\knowledge\{\kl{notion},"index="semigroup morphism\}\\
1096 \indent~~~\klbn|~~semigroup morphism\\
1097 \indent~~~\klbn|~~semigroup morphisms\\
1098 \indent~~~\klbn|~~morphism@SG\\
1099 \indent~~~\klbn|~~morphisms@SG
1100 \end{CODE}\noindent
1101 Now, the index (after running \texttt{makeindex}) contains all entries and references to the use of semigroups and semigroup morphisms.
1102
1103 See \kCref(option){makeidx} for more details on making an index.
1104 %
1105 %\subsection{Managing an index}
1106 %Though it is not its primary goal, without using its hyperlinking capabilities, the "knowledge@@package" offers convenient features for easily managing data for the construction of an index.
1107
1108 %For instance, let us imagine that one wants to write a book
1109 %
1110
1111 \subsection{Mathematics}
1112 \label{subsection:mathematics scenario}
1113
1114 The examples above show various techniques for using \kl{knowledges} for enhancing the information associated to terms. In fact, these techniques are not incompatible with mathematics. Some special syntax is even offered:
1115 \begin{CODE}[12.6cm]
1116 \cs\knowledgenewrobustcmd\cs\closure[1]\{\cs\cmdkl\{\cs\langle\}\#1\cs\cmdkl\{\cs\rangle\}\}\}\\
1117 "[...]"\\
1118 The closure of~\$X\$ under product is denoted~\$\cs\intro*\cs\closure\{X\}\$.\\
1119 "[...]"\\
1120 Consider now \$\cs\closure\{\cs\{a,b,c\cs\}\}\$.
1121 \end{CODE}\noindent
1122 \noindent
1123 would yield:
1124 \begin{PDFoutput}[8cm]
1125 \knowledgenewrobustcmd \closure[1]{\cmdkl{\langle}#1\cmdkl{\rangle}}
1126 \AP The closure of~$X$ under product is denoted $\intro*\closure X$.\\
1127 "[...]"\\
1128 Consider now $\closure{\{a,b,c\}}$.
1129 \end{PDFoutput}
1130 \begin{problem}
1131 But I want more. I want to be able to introduce variables.
1132 Even better, I would like to be able to have variables hyperlinking to the place of their introduction, knowing that the same variable name may mean different things depending on the lemma or proof we are in. Hence, I want to properly control the scope of knowledges.
1133 \end{problem}
1134
1135 \AP To be done, this requires to use \kl{scoping}. The principle of \kl{scoping} is that a knowledge can be
1136 attached to a particular context. This is particularly true when typesetting mathematics: a variable is meaningful inside a statement, and inside the proof of the statement. Furthermore, the same variable name may reappear elsewhere with a different meaning.
1137
1138 The following code gives an idea of what is possible using \kl{scoping}:
1139 \begin{CODE}
1140 \cs\knowledgeconfigureenvironment\{theorem,lemma,proof\}\{\}\par\noindent
1141 "[...]"\par\noindent
1142 \cs\begin\{lemma\}\cs\label\{theorem:main\}\par\noindent
1143 ~~~~\cs\knowledge\{n\}\{\kl{notion}\}\par\noindent
1144 ~~~~For all number~\$\cs\intro\ n\$, "[...]"\par\noindent
1145 \cs\end\{lemma\}\par\noindent
1146 "[...]"\par\noindent
1147 Here \$\cs\kl\ n\$ is an undefined knowledge.\par\noindent
1148 "[...]"\par\noindent
1149 \cs\begin\{proof\}[Proof of theorem\~\space\{theorem:main\}]\par\noindent
1150 ~~~~\cs\knowledgeimport\{theorem:main\}\par\noindent
1151 ~~~~Inside the proof, \$\cs\kl\ n\$ is hyperlinked to the theorem...\par\noindent
1152 \cs\end\{proof\}
1153 \end{CODE}
1154 More on \kl{scoping} can be found in Section~\ref{subsection:scoping}.
1155
1156 The use of "variants of \cs{\kl}" is also useful for typesetting mathematics. It allows for instance, to implicitly execute the \cs{\knowledge} command at the same time of the introduction. See~\ref{subsubsection:variants} for more detail.
1157
1158 \newpage
1159
1160 \section{Usage of the \kl(package){knowledge} package}
1161 \label{section:doc}
1162
1163 \subsection{Options and configuration}
1164 \label{subsection:loading packages}
1165
1166 Options are used to activate some capabilities.
1167 Some options have to be used when loading the "knowledge@@package" package, while some others
1168 can also be used inside the document thanks to the use of \cs{\knowledgeconfigure}.
1169 In this section, we review these ""package options"".
1170
1171 \subsubsection{Options at package loading}
1172
1173 The options that can be used in the optional parameter of \cs{\usepackage} when loading the "knowledge@@package" package belong to the following classes:
1174 \begin{compactdesc}
1175 \itemAP[Writing mode] The "paper", "electronic" or "composition" modes are possible ("composition" is by default) (see Section~\ref{subsubsection:writing modes} for more details).
1176 These modes change several rendering settings.
1177 \itemAP[Other packages] some of the options concern the loading and the use of other packages (\kl(package){hyperref}, \kl(package){xcolor}, \kl (package){makeidx}, \kl (package){imakeidx}, \kl (package){cleveref}, \dots). Note that these package can also be loaded before "knowledge@@package". This is explained in Section~\ref{subsubsection:packages-loading}.
1178 \itemAP[Configuration options] as used by the command \cs{\knowledgeconfigure} can be used when loading the package.
1179 \itemAP[Scoping] The \kl[scope option]{scope} "option@package option" makes the package aware at a fine level of the structure of the document (see Section~\ref{subsection:scoping} for explanations). This provides, for instance, the possibility to define pieces of "knowledge" that are attached to a sections of the document.
1180 \itemAP[Other] The "no patch" option prevents the "knowledge@@package" to apply some patches that are convenient by default.
1181 \end{compactdesc}
1182
1183 \subsubsection{Writing mode}
1184 \label{subsubsection:writing modes}
1185 There are three ""writing modes"" usable when loading the package "knowledge@@package":
1186 \begin{itemize}
1187 \itemAP In ""paper"" mode, the paper is rendered as for printing: in particular, no informative colors are visible. Hyperlinks are nevertheless present.
1188 \itemAP In ""electronic"" mode, the document has some colors witnessing the existence of the links for the reader to know that clicking is available.
1189 \itemAP In ""composition"" mode (the default), the document has colors helping the writing: "undefined knowledges" appear explicitly, "anchor points" are displayed, and so on.
1190 \end{itemize}
1191 Activating the modes is obtained either at load time using one of:\\
1192 \begin{tabular}[t]{ll}
1193 &\smallcode{\cs\usepackage[\kl{paper}]\{"knowledge@@package"\}}\\[2mm]
1194 or\quad&\smallcode{\cs\usepackage[\kl{electronic}]\{"knowledge@@package"\}}\\[2mm]
1195 or &\smallcode{\cs\usepackage[\kl{composition}]\{"knowledge@@package"\}}
1196 \end{tabular}\\
1197 \AP or by setting before loading the variable \csintro{\knowledgepackagemode} as in:\\
1198 \begin{tabular}[t]{ll}
1199 &\smallcode{\cs\def\cs\knowledgepackagemode\texttt\{\kl{paper}\texttt\}}
1200 \end{tabular}\\
1201 The idea is that this can be used in automatic compilation scripts. For instance, using in a terminal:
1202 \begin{CODE}[12cm]
1203 \smallcode{\texttt{pdflatex} \quotesymbol\cs\def\cs\knowledgepackagemode%
1204 \texttt\{\kl{electronic}\texttt\}\cs\input\texttt\{file.tex\texttt\}\quotesymbol}
1205 \end{CODE}
1206 \noindent would result in compiling `\texttt{file.tex}' using "knowledge@@package" in
1207 "electronic mode".
1208
1209 The following primitives are available to the user for "writing mode"-sensitive configuration:
1210 \begin{CODE}[11.4cm]
1211 \AP
1212 \csintro\IfKnowledgePaperModeTF\texttt\{true code\texttt\}\texttt\{false code\texttt\}\\
1213 \AP
1214 \csintro{\ ifKnowledgePaperMode} true code [\cs{\ else} false code] \cs{\ fi}\\
1215 \AP
1216 \csintro{\IfKnowledgeElectronicModeTF}\texttt\{true code\texttt\}\texttt\{false code\texttt\}\\
1217 \AP
1218 \csintro{\ ifKnowledgeElectronicMode} true code [\cs{\ else} false code] \cs{\ fi}\\
1219 \AP
1220 \csintro{\IfKnowledgeCompositionModeTF}\texttt\{true code\texttt\}\texttt\{false code\texttt\}\\
1221 \AP
1222 \csintro{\ ifKnowledgeCompositionMode} true code [\cs{\ else} false code] \cs{\ fi}
1223 \end{CODE}
1224
1225
1226 \subsubsection{Automatic loading of other packages}
1227 \label{subsubsection:packages-loading}
1228 A certain number of "package options" coincide with the loading of other packages.
1229 For the moment, the packages that are concerned are \kl(option){hyperref},
1230 \kl(option){xcolor}, \kl(option){makeidx}, and "imakeidx@@option".
1231
1232 For activating these functionalities, it is sufficient, either to load the package \emph{before} the "knowledge@@package" package, or to name it explicitly as an "option@package option" for "knowledge@@package".
1233 Loading separately the package is convenient for setting options for it. For instance,
1234 a typical preamble may look like:
1235 \begin{CODE}[7cm]
1236 \cs\documentclass\{article\}\\
1237 %\cs\usepackage[utf8]\{inputenc\}\\
1238 %\cs\usepackage[T1]\{fontenc\}\\
1239 \cs\usepackage[svgnames]\{\kl(package){xcolor}\}\\
1240 \cs\usepackage[\texttt{draft}]\{\kl(package){hyperref}\}\\
1241 \cs\usepackage[\kl(package){makeidx}]\{"knowledge@@package"\}
1242 \end{CODE}\noindent
1243 Such a sequence will activate the "knowledge@@package" package using the features related to \kl(package){xcolor} configured with \texttt{svgnames} option, to \kl(package){hyperref} configured with \texttt{draft} option, and to \kl(package){makeidx} with its standard configuration.
1244
1245
1246
1247 In fact, the syntax when a package is loaded as an option of "knowledge@@package" is of the form
1248 `package=choice' in which choice can take the following values:
1249 \begin{description}
1250 \itemAP[\intro{active}] The package will be loaded, and all the capabilities that it triggers are activated.
1251 This is the implicit meaning when nothing more is specified.
1252 \item[\intro{inactive}] The package is not loaded, and no capabilities are activated (even if it had been loaded previously by another |\usepackage| command).
1253 \item[\intro{compatibility}] The package is not loaded. The directives it uses do not cause any error, but have no effect.
1254 \item[\intro{auto}] If the package was loaded before, then the associated capabilities are activated. This is the default behavior when the package is not named while loading.
1255 \end{description}
1256 Currently, the packages that can be loaded are:
1257 \begin{description}
1258 \itemAP[\kl(package){hyperref}] which activates all the (auto)referencing capabilities.
1259 \item[\kl(package){xcolor}] which activates coloring commands.
1260 \item[\kl(package){makeidx} and "imakeidx@@package"] for handling the index automatically.
1261 \end{description}
1262
1263 \subsubsection{Configuring and \cs{\knowledgeconfigure}}
1264
1265 Some part of the configuration can be done outside of the \cs{\usepackage} command that loads the "knowledge@@package" package. This is done using the
1266 \cs{\knowledgeconfigure} command:
1267 \begin{center}
1268 \smallcode{\csintro\knowledgeconfigure\{\kl{configuration directives}\}}
1269 \end{center}
1270 Note that by default, the \kl{configuration directives} used by \cs{\knowledgeconfigure} can
1271 be used in the optional parameter of \cs{\usepackage} when loading the "knowledge@@package" package, but the converse is not true.
1272 ""Configuration directives"" consists of a comma separated list of elements that can take the following values:
1273
1274 \begin{description}
1275 \itemAP["diagnose bar="] (de)activates the "`\vbar'-notation" in the "diagnose file". True by default.
1276 \itemAP["diagnose help="] can be set to true or false. It activates or deactivates the help in the "diagnose file". True by default.
1277 \itemAP["diagnose line="] can be set to true or false. It activates or deactivates the line numbering in the "diagnose file". False by default.
1278 \itemAP[\kl{fix hyperref twocolumn}] triggers a hack that solves a known problem that may occur when "hyperref@@package" is used in two-columns mode.
1279 \itemAP[\kl{label scope}] enables or disables the redefined \cs{\label} command, which helps automatically define scopes (default is~\textmd{true}).
1280 \itemAP["notion@@option"] configures the "notion" "directive" which is a refined version of "autoref".
1281 \itemAP["protect quotation="] is followed by a comma separated list of environments in which the "quotation notation" will be automatically deactivated (surrounded by braces if more than one item in the list).
1282 \itemAP[\intro{protect link co} and \intro{unprotect link co}] starts and ends respectively a zone in which the "knowledge@@package" package do not create hyperlinks. These can be nested.
1283 This is typically useful around, e.g. the table of contents.
1284 \itemAP[\kl(option){quotation}] activates the "quotation notation", which allows to use \kl{"..."}, \kl{"...@..."} and \kl{"...@...@..."}
1285 instead of \cs{\kl} commands and \kl{""...""}, \kl{""...@...""} and \kl{""...@...@...""} instead of the \cs{\intro} command.
1286 \itemAP[""silent""] is a Boolean option which, when activated, switches off all warnings during the compilation, but the recap ones at the end.
1287 \itemAP[""strict""] is a Boolean option which, when activated, turns some warnings (for instance when a knowledge is redefined) into errors.
1288 \itemAP[\kl{visible anchor points}] is an option that makes visible or invisible the \kl{anchor points} of the \cs{\AP} and \cs{\itemAP} commands. Usually, this is automatically set to true when the "composition mode" is used (the default),
1289 and to false when the "paper mode" or the "electronic mode" are used.
1290 \end{description}
1291
1292
1293 \subsubsection{Other configuration option}
1294
1295 \begin{itemize}
1296 \itemAP[""no patch""] deactivates some patches which otherwise are applied automatically.
1297 Currently, the option \texttt{hidelinks} and \texttt{breaklinks} of the package \kl(package){hyperref} are automatically applied, unless "no patch" is used while loading the package. Without \texttt{hidelinks} the links in the document are surrounded by red or light blue boxes (it depends also on the pdf viewer): while this may be acceptable when links are seldom used, this becomes problematic in combination with the "knowledge@@package" package. Without \texttt{breaklinks}, links are not broken as normal text: this may corrupt the appearance of paragraphs, in particular in a multi column context.
1298 \end{itemize}
1299
1300 \subsection{What is a \kl{knowledge}?}
1301
1302 A \intro{knowledge} is often informally used in this document. Essentially, it captures what is an elementary concept in the document.
1303 Internally, a \kl{knowledge} is identified by three components:
1304 \begin{compactdesc}
1305 \itemAP[The \intro{knowledge name}] is a \kl{tex} string that has almost no limitation (but being well balanced, and containing no $\sharp$). It is the text entered by the user for defining and using the \kl{knowledge}.
1306 \itemAP[The \intro{scope}] which is a simple string identifying where the \kl{knowledge} is usable. Scopes can be created by the user, or automatically generated by the system.
1307 For instance, internally, each section will be uniquely named `\texttt{section-1}', `\texttt{section-2}', and so on (this is invisible for the user). Each \kl{knowledge} is primarily valid in
1308 exactly one such \kl{scope}. \kl{Knowledges} defined in the preamble are given the \kl{scope} `\texttt{document}'.
1309 \itemAP[The \intro{namespace}] is a simple string that is used for avoiding clashes. It is most of the time simply `\texttt{default}'. It is `\texttt{style}' for \kl{styles} (that are internally as knowledges).
1310 It is a possibility available to a developer to, when creating a new set of functionalities, use a different \kl{namespace} for avoiding clashes of names (for instance if one wants a french and an english set of knowledges that should not conflict, and would use separate sets of macros).
1311 Usually, a normal user does not see \kl{namespaces}.
1312 \end{compactdesc}
1313
1314
1315
1316 \subsection{The \cs{\knowledge} command and variations}
1317 \label{subsection:knowledge command}
1318
1319 In this section, we describe the main commands that create \kl{knowledges}.
1320 The main one is \cs{\knowledge}. It can also be used in combination with \cs{\knowledgedirective}, \cs{\knowledgestyle} and \cs{\knowledgedefault}.
1321
1322 \subsubsection{General description of the \cs{\knowledge} command}
1323 \label{subsubsection:knowledge command general}
1324 The key command for introducing knowledges is \cs{\knowledge}.
1325 There are two syntaxes. The standard one is:
1326 \begin{center}
1327 \smallcode{\csintro\knowledge\{\kl[\knowledge knowledge name]{knowledge name}\}%
1328 [\kl[\knowledge synonyms]{synonym 1}\vbar\kl[\knowledge synonyms]{synonym 2}\vbar\dots]\{\kl[\knowledge directives]{directives}\}}
1329 \end{center}
1330 \AP
1331 The second one is the ""`\vbar'-notation""\footnote{%
1332 This is a non-standard "LaTeX" syntax. The rule is that each knowledge appears in a distinguished line
1333 that starts with some spaces and a `$\vbar$', and ends at the end of the line.
1334 Detecting the end of the line requires to change the catcode of the end of line character; this is
1335 not robust for being used in an argument or a macro.
1336 }:
1337 \begin{CODE}[10cm]
1338 \csreintro\knowledge\{\kl[\knowledge directives]{directives}\}\\
1339 \indent~~~~\klbn|~\kl[\knowledge knowledge name]{knowledge name}@\kl[\knowledge optional scope]{optional scope}\\
1340 \indent~~~~\klbn|~\kl[\knowledge synonyms]{synonym 1}@\kl[\knowledge optional scope]{optional scope}\\
1341 \indent~~~~\klbn|~\kl[\knowledge synonyms]{synonym 2}@\kl[\knowledge optional scope]{optional scope}\\
1342 \indent~~~~~~~~$\cdots$
1343 \end{CODE}
1344 \AP
1345 The \intro[\knowledge knowledge name]{knowledge name} as well as the \intro[\knowledge synonyms]{synonyms} are plain text strings describing the knowledge. It may contain any combination of symbols, including accents or special characters as long as it well bracketted.
1346 This string will be used to fetch the \kl{knowledge}. Note (and this is a standard \kl{tex} behavior) that several consecutive spaces is the same as one or a line feed.
1347 \AP In the normal syntax, \reintro[\knowledge synonyms]{synonyms} are given in a `\vbar' separated list, while in the "`\vbar'-notation" each of them has to be in a distinct line. \AP In the "`\vbar'-notation", an \intro[\knowledge optional scope]{optional scope} can be given after each \kl[\knowledge knowledge name]{knowledge name}/\kl[\knowledge synonyms]{synonym}.
1348
1349 %This is a
1350 %shorthand for writing `\kl{link=}' \kl[\knowledge directives]{directives}. (Note that there is another way to %define synonyms using the \kl{synonym} directive).
1351 \AP
1352 The \intro[\knowledge directives]{directives} consists of `key=value' statements in a comma separated list.
1353 There are many \kl[\knowledge directives]{directives}. A list of them can be found in Section~\ref{subsection:directive list}. New ones can be defined using the \cs{\knowledgedirective} command.
1354
1355 \AP
1356 The principle of the \cs{\knowledge} command is to introduce a new \kl{knowledge}, ready for being used.
1357 However, what it does exactly depends a lot on the situations.
1358 First, the \kl[\knowledge directives]{directives} (a comma separated list of `key=value' commands) are parsed, and from it, the namespace and "scope" of the knowledge are determined, and it is decided if it will be defined immediately or postponed to the next compilation phase (using the \kl{kaux file}).
1359
1360 \subsubsection{Targeting and the corresponding directives}
1361
1362 The \cs{\knowledge} has to decide what to do when defining something. The basic behaviour is as follows.
1363 \begin{itemize}
1364 \item If the \cs{\knowledge} command is used in the preamble, then the \kl{knowledge} given as argument is defined immediately (the same effect can be obtained using the \kl{now} "directive"), and is accessible in the first compilation phase everywhere in the document (one extra phase is nevertheless required if \kl{autoref} or \kl{ref=} directives are used, for the "hyperref@@package" to do its job, or if "scope=" is used). This is the simplest way to use \cs\knowledge.
1365 \item Otherwise, the \kl{knowledge} is written in an external file (the \kl{jobname.kaux} file), and the \kl{knowledge} will be really usable in the next compilation phase. This is particularly useful in conjunction with the \kl{scope option}: the \kl{knowledge} will have a scope depending on where it is introduced (for instance the document, or a theorem, or a lemma). The same \kl{knowledge name} can then point to different \kl{knowledges} depending on where it is used.
1366 \item Exporting (\kl{not implemented}) furthermore writes a document containing a list of \cs{\knowledge} commands giving access to its content. This is to be imported by another document.
1367 \end{itemize}
1368
1369 The \intro{targeting directives} refine the above defined behaviour:
1370 \begin{description}
1371 \itemAP[\intro{scope=} or `@' in the "`\vbar'-notation"] When using a \kl[\knowledge directives]{directive} `\kl{scope=}name' or `@name' in the "`\vbar'-notation", the scope of the definition can be modified.
1372 \cs{\knowledge} will first check if there is an outer \kl{area} of this name (\texttt{theorem}, \texttt{section}, \dots), that accepts knowledge (only
1373 "scope@@env" environments are subject to this unless \cs{\knowledgeconfigureenvironment} is used, or
1374 the "scope@@option" "package option" is used when loading the package).
1375 If this is the case, the knowledge will be associated to the corresponding \kl{instance}. For instance, inside a theorem, by default, the scope is the theorem, but adding the directive `\kl{scope=}section', the \kl{knowledge} becomes available in the whole section.
1376
1377 If no scope is found using the above search, an "explicit scope" of the given name is used.
1378
1379 \itemAP[\intro{export=}] (\kl{not implemented}) When using this directive, the knowledge will be (furthermore) written to another file, ready for being used in another document. In particular, the knowledge (in the other document) will point to the present one. The details on how this is supposed to work is to be specified.
1380 \itemAP[\intro{namespace=}] Allows to change the \kl{namespace}. In itself, this is useless. It has to be used in conjunction with new forms of \cs\kl-like commands.
1381 \itemAP[\intro{now}] requires the \kl{knowledge} to be defined immediately. This may save one compilation phase. The drawback is that the \kl{knowledge} cannot be accessed before the \cs{\knowledge} command that has been introduced. It may help for modularity considerations. (for instance a \kl{knowledge}
1382 is used inside a proof, it makes no sense to make it available elsewhere, and it is better style to locally define it). This is implicit if the \cs{\knowledge} command happens in the preamble.
1383 \itemAP[\intro{also now}] requires the \kl{knowledge} to be defined immediately as well as delayed to the next compilation phase. This is in particular how "auto references@autoref" should be handled. See the use of \cs{\knowledgenewvariant} for more examples.
1384 \end{description}
1385
1386
1387 \subsubsection{General directives}
1388
1389 We give here the list of \intro{display directives} that are available without loading any sub packages.
1390 A certain number of Boolean directives are available without any options. These most of the time are used for typesetting the output. Each of these can be used as
1391 `\texttt{bool=true}' (or shortly just `\texttt{bool}'), `\texttt{bool=false}' or `\texttt{bool=default}'
1392 (that leaves it in the default state, or the one determined by surrounding knowledges).
1393 The general boolean \kl[\knowledge directives]{directives} are the following:
1394 \begin{description}
1395 \itemAP[\kl{autoref}] activates the ability to introduce once, use several times an instance. This is often used for defining links inside a document (see the "hyperref@@option" in \kCref*"hyperref@@option"). This can also be used for constructing the index (see the "makeidx@@option" and in "imakeidx@@option"\kCref*"makeidx@@option"). It can simply be used for referencing the number of the environment or the proper page of introduction (see \cs\kref\ and \cs\kpageref\ commands and their more powerful "cleveref@@option" in \kCref*"cleveref@@option").
1396 \itemAP[\kl{autorefhere}] puts immediately a label at the location of the definition, and makes all \cs{\kl} occurrences of this \kl{knowledge}
1397 hyperlink to this location.
1398 \itemAP[\intro{emphasize}] forces the text to be emphasized using `\cs{\emph}',
1399 \itemAP[\intro{italic}/\intro{up}] forces/unforces italic ("up" does nothing in math mode),
1400 \itemAP[\intro{boldface}/\intro{md}] forces/unforces boldface (be it in math or text mode),
1401 \itemAP[\intro{smallcaps}] forces small capitals,
1402 \itemAP[\intro{underline}] forces the text to be emphasized using `\cs{\underline}',
1403 \itemAP[\intro{fbox}] puts a box around the text,
1404 \itemAP[\intro{typewriter}] puts in typewriter font (be it in math or text mode),
1405 \itemAP[\intro{ensuretext}] guarantees that text mode is used (using the `\cs{\text}' macro, thus in a
1406 way consistent with the surrounding style),
1407 \itemAP[\intro{ensuremath}] guarantees that math mode is used,
1408 \itemAP[\reintro{mathord}, \reintro{mathop}, \reintro{mathbin}, \reintro{mathrel}, \reintro{mathopen}, \reintro{mathclose}, \reintro{mathpunct}]
1409 yield the corresponding standard \TeX{} spacing features in math mode,
1410 \begin{description}
1411 \item[\intro{mathord}] for an ordinary mathematical object,
1412 \item[\intro{mathop}] for a large operator (such as $\sum$, $\prod$, \dots),
1413 \item[\intro{mathbin}] for a binary operation (such as $+$, $-$, or $\otimes$, \dots),
1414 \item[\intro{mathrel}] for a binary relation (such as $=$, $<$, $\leq$, \dots),
1415 \item[\intro{mathopen}] for an opening bracket, parenthesis, \dots
1416 \item[\intro{mathclose}] for an closing bracket, parenthesis, \dots
1417 \item[\intro{mathpunct}] for a punctuation symbol.
1418 \end{description}
1419 \itemAP[\intro{lowercase}] puts the content in lowercase,
1420 \itemAP[\intro{uppercase}] puts the content in uppercase,
1421 \itemAP[""detokenize""] detokenizes the content, i.e., instead of executing it provides a string that displays it (this is useful for commands),
1422 \itemAP[""remove space""] removes the spaces from the text
1423 \itemAP[""invisible""] prevents the rendering of the knowledge.
1424 \end{description}
1425
1426
1427 \AP The non-boolean general \kl[\knowledge directives]{directives} are the following:
1428 \begin{compactdesc}
1429 \itemAP[\intro{text=}\textmd{\{text\}}] will execute the \LaTeX{} code `text' instead of the key used for calling \cs\kl. For instance,
1430 \smallcode{\cs\knowledge \{latex\}\{\kl{text=}\cs{\LaTeX}\}} will typeset `\LaTeX{}' properly when used. Surrounding braces can be omitted if there are no commas. Be careful when linking to such knowledges, since the substitution of meaning will happen for all the knowledges linking to it, and this may not be the expected behaviour.
1431 \itemAP[\intro{link=}\textmd{\{knowledge\}}] will continue searching the for linked \kl{knowledge}. Surrounding braces can be omitted if there are no commas.
1432 This directive is often bypassed by the use of the \kl[\knowledge optional argument]{optional argument} of \cs{\knowledge} defining synonyms or the \kl{synonym} directive.
1433 \itemAP[\intro{link scope=}\textmd{\{label\}}] will continue searching in the "scope" identified by the label. Surrounding braces can be omitted if there are no commas. If no "directive" "link=" is given, then the same key is searched for.
1434
1435 This directive is often bypassed by the use of the \kl[\knowledge optional argument]{optional argument} of \cs{\knowledge} defining synonyms or the \kl{synonym} directive.
1436 \itemAP[\intro{synonym}] defines the knowledge as a link to the previously defined knowledge (in fact, the most recently defined that was not using \kl{synonym}). For instance
1437 \begin{CODE}[11cm]
1438 \cs\knowledge\{Leslie Lamport\}\\
1439 \indent~~~~~\{\kl{ref=}\{https://fr.wikipedia.org/wiki/Leslie\_Lamport\}\}\\
1440 \cs\knowledge\{L. Lamport\}\{\kl{synonym}\}\\
1441 \cs\knowledge\{Lamport\}\{\kl{synonym}\}
1442 \end{CODE}
1443 \noindent
1444 results in the two subsequent \kl{knowledge names} to point to the first one.
1445 \itemAP[\intro{style=}\textmd{\{knowledge style\}}] will adopt the styling option of the \kl{knowledge style}. Surrounding braces can be omitted if there are no commas.
1446 \itemAP[\intro{wrap=}\textmd{\robustdisplay\token}] will execute the macro `\textmd{\robustdisplay\token}' with as argument the knowledge text before displaying it. For instance,
1447 \kl{wrap=}\cs\robustdisplay,
1448 (where \csintro{\robustdisplay} is a variant of \cs{\tl_to_str:n} removing the trailing space) is used in this document for typesetting the commands.
1449 \end{compactdesc}
1450
1451
1452 \subsubsection{\kl{Knowledge styles} and the \cs{\knowledgestyle} command}
1453 \label{subsubsection:knowledge styles}
1454
1455 \intro{Styles} are formatting pieces of information, as for \kl{knowledges}, but that can be used by other \kl{knowledges}. In some respect, this is very similar to \kl{macro directives} (see below), but the difference lies in that \kl{styles} are dynamically resolved, while \kl{macro directives} are statically resolved. \kl{Styles} in particular offer the access to some configuration features of the system.
1456 For instance, changing the \kl(style){intro} \kl{style} changes the way the \cs{\intro} command is displayed.
1457 See below for some instances.
1458
1459 \AP
1460 The central command is \cs{\knowledgestyle}, that has the following syntax:
1461 \begin{center}
1462 \smallcode{\csintro{\knowledgestyle}*\{style name\}\{\kl[\knowledge directives]{directives}\}}
1463 \end{center}
1464 The optional star \texttt* permits to overload an existing style (otherwise, this results in an error). The \kl[\knowledge directives]{directives} follow the same structure as for a normal \cs{\knowledge}
1465 command. When defined, a \kl{style} can be used in a \cs{\knowledge}
1466 command using the \kl[\knowledge directives]{directives} `\kl{style=}style name' (it will be used when a \cs{\kl} command calls for the \kl{knowledge}) or `\kl{intro style=}style name' (that will be used by \cs{\intro} commands).
1467
1468 \AP
1469 A certain number of \intro{default styles} are also offered, that in particular includes \intro{warning styles}. The list is as follows:
1470 \begin{compactdesc}
1471 \itemAP[""kl@@style""] is the default style for macros using \cs{\kl}.
1472 It can be modified dynamically using the `\kl{style=}' \kl[\knowledge directives]{directive}.
1473 \itemAP[""kl unknown@@style"" and ""kl unknown cont@@style""] are
1474 the default \kl{styles} used when an undefined \kl{knowledge} is met.
1475 \itemAP[""intro@@style"" and ] is the default style for macros using \cs{\intro}.
1476 It can be modified dynamically using the `\kl{intro style=}' \kl[\knowledge directives]{directive}.
1477 \itemAP[""intro unknown@@style"" and ""intro unknown cont@@style""]
1478 are the default \kl{styles} used when an undefined \kl{knowledge} is met.
1479 \end{compactdesc}
1480
1481 \subsubsection{New directives: the \cs{\knowledgedirective} command}
1482 \label{subsubsection:macro directives}
1483
1484 When defining \kl{knowledges}, it is often the case that the same
1485 sequence of directives are used. \intro{Macro directives} are here for simplifying this situation (see also \cs{\knowledgedefault} and \cs{\knowledgestyle}). This is achieved using the \cs{\knowledgedirective} macro:
1486 \marginpar{\begin{hint} This should not be confused with \kl{styles} which offer another way to control the display.\end{hint}}
1487 \begin{center}
1488 \smallcode{\csintro{\knowledgedirective}*\{name\}[optional parameter]\{directives\}}
1489 \end{center}
1490 After execution of the command, `name' becomes a \kl[\knowledge directives]{directive}
1491 usable in \cs{\knowledge} commands, that amounts to execute the comma separated list `directives'. The newly created \kl[\knowledge directives]{directive} may receive a value, that is accessible as \texttt{\#1} in `directives'. By default, it does not allow the redefinition of a directive. This can be forced using the optional \texttt*. The `optional parameter' gives
1492 a default value. For instance:
1493 \begin{CODE}
1494 \cs\knowledgedirective\{highlight\}[brown]\{\kl{color=}\{\#1\},\kl{emphasize},\kl{md}\}\\{}
1495 "[...]"\\{}
1496 \cs\knowledge\{notion A\}\{highlight\}\\
1497 \cs\knowledge\{notion B\}\{highlight\}\\
1498 \cs\knowledge\{notion C\}\{highlight\}\\
1499 \cs\knowledge\{important notion D\}\{highlight=red\}\\{}
1500 "[...]"\\
1501 We shall now see \cs\kl\{notion A\}, \cs\kl\{notion B\}, \cs\kl\{notion C\}, as well as the \cs\kl\{important notion D\}.
1502 \end{CODE}
1503 \noindent
1504 yields
1505 \begin{PDFoutput}
1506 \knowledgedirective{highlight}[brown]{color={#1},emphasize,md}
1507 \knowledge{notion A}{highlight}
1508 \knowledge{notion B}{highlight}
1509 \knowledge{notion C}{highlight}
1510 \knowledge{important notion D}{highlight=red}
1511 We shall now see \kl{notion A}, \kl{notion B}, \kl{notion C}, as well as the \kl{important notion D}.
1512 \end{PDFoutput}
1513
1514 \subsubsection{\cs{\knowledgestyle} versus \cs{\knowledgedirective}}
1515 \label{subsubsection:style versus macro}
1516
1517 \AP
1518 The two commands \cs{\knowledgestyle} and \cs{\knowledgedirective}
1519 offer ways to systematize the writing of knowledges. These can seem redundant.
1520 This is not the case, and for understanding it, it is necessary to understand a bit the way the \cs{\knowledge} command works.
1521
1522 \AP
1523 In general when a \cs{\knowledge} (or \cs{\knowledgestyle}) command is found, the \kl[\knowledge directives]{directives} are parsed and a new internal form of the \cs{\knowledge} command is written in the \kl{kaux file}, that will be executed during the next compilation of the document.
1524 In this phase, some first operations are performed. For instance, in an \kl{autoref} \kl[\knowledge directives]{directive}, an internal label name is constructed.
1525
1526 The postponed command is then executed during the next compilation phase (or immediately if we are in the preamble, or if the \kl{now} directive is used). The execution effectively stores the \kl{knowledge} in the system. This is only at that moment that the \kl{knowledge} becomes available to be used by \cs{\kl} and similar commands.
1527
1528 When a \cs{\kl} command (or similar) is met, it is `executed', and display informations are considered, and in particular \kl{styles} are called.
1529
1530 Somes consequences of this kind of this are as follows:
1531 \begin{itemize}
1532 \item \kl{autoref} directives should not be used in the definition of a \kl{style}, since this would mean that
1533 there would be one anchor point for all the \kl{knowledges} that use this \kl{style}. This is usually not the kind of behavior that we expect.
1534 \item configuring the default displays of the system (such as the \kl{intro style=} in particular) has to be done through the \kl{style} mechanism.
1535 \item \kl{styles} use less memory than macros.
1536 \end{itemize}
1537
1538 \subsubsection{\kl{Default directives}: the \cs{\knowledgedefault} command}
1539 \label{subsubsection:default directives}
1540
1541 It may happen that a sequence of consecutive \cs{\knowledge} commands have to share the same list of \kl[\knowledge directives]{directives}. The \kl{macro directives} can help solving this issue. The \intro{default directives} also go in this direction, using the \cs{\knowledgedefault} command:
1542 \begin{center}
1543 \smallcode{\csintro\knowledgedefault*\{\kl[\knowledge directives]{directives}\}}
1544 \end{center}
1545 When such a command is applied, then from that point, all \cs{\knowledge} commands
1546 will use the given \kl[\knowledge directives]{directives} as default. This will stop when another \cs{\knowledgedefault} command is met or the current group is closed.
1547 The optional star does not reset the \kl{default directives} but simply add new ones.
1548
1549
1550
1551
1552 \subsection{The \cs{\kl} command and variants}
1553 \label{subsection:kl command}
1554
1555 The \cs\kl\ command is used for displaying a knowledge in the text, while using the data associated to it
1556 (introducing a target link, linking to its definition, linking to an outer document, changing color, putting an entry in the index, etc).
1557
1558 \subsubsection{The standard syntax}
1559
1560 \marginpar{\begin{hint} Note that the \cs{\kl} command can often be replaced by the
1561 \kl{"..."}{} notation, activated by the "quotation@@option" option.\end{hint}}
1562
1563
1564 The \cs{\kl} command has one of the following syntaxes:
1565 \begin{center}
1566 \begin{tabular}{cc}
1567 &\smallcode{\csintro{\kl}(\kl[klab]{optional scope})[\kl[knowledge name]{optional knowledge name}]\{text\}}\\
1568 or\quad&
1569 \smallcode{\csreintro{\kl}[\kl[knowledge name]{optional knowledge name}](\kl[klab]{optional scope})\{text\}}\ .
1570 \end{tabular}
1571 \end{center}
1572 Its meaning is to search for the `optional knowledge name' if present, or for `text' otherwise. How this is exactly performed depends on the presence of the \kl[klab]{optional scope}.
1573 The search process is as follows:
1574 \begin{asparaitem}
1575 \itemAP if an \intro[klab]{optional scope} is given, the \kl{knowledge} is searched in the corresponding scope.
1576 \itemAP otherwise, the \kl{stack of visible scope instances} is processed through (starting from the inner most)
1577 until a \kl{knowledge} of name `\kl{knowledge name}' (or `text' if not optional \kl{knowledge name} has been given), of \kl{namespace} `default', and this \kl{scope} is found.
1578
1579 If the `knowledge name/text' has not been found, the \kl{style} `"kl unknown@@style"' (or similar "styles", as defined by the "unknown style=@@variant" or "unknown style cont=@@variant") is used, and the
1580 text displayed.
1581 \item Otherwise, the \kl{knowledge} is executed. If it is a \kl{link=} or \kl{synonym} defined \kl{knowledge}, the link is followed, and the process continues.
1582 \item Finally, all the definitions involved in the \kl{knowledge} are processed, following a \kl{style=} if defined, the \kl{knowledge} is updated (essentially incrementing the counter of use), and the \kl{knowledge} is displayed.
1583 \end{asparaitem}
1584 This general mechanism is used also by other commands that are "variants of \cs{\kl}" such as \cs{\intro}, \cs{\reintro}, \cs{\kref}, \cs{\kpageref}, and so on.
1585
1586
1587 \subsubsection{The "quotation notation"}
1588
1589 \phantomintro{"}\phantomintro{@}\phantomintro{quotation notation}%
1590 When activated, the ""quotation@@option"" mode activates shorthand
1591 notations for the \cs{\kl} and \cs{\intro} macros. Possible syntaxes are as follows:
1592 \begin{description}
1593 \itemAP[\smallcode{\klqn"text\klqn"}]\phantomintro{"..."}%
1594 uses the "knowledge" pointed to by `text'. Equivalent to~\texttt{\cs\kl\{text\}}.
1595 \itemAP[\smallcode{\klqn"text\klqn@knowledge\klqn"}]\phantomintro{"...@..."}%
1596 uses the "knowledge" pointed to by `knowledge' to display `text'. Equivalent to~\texttt{\cs\kl[knowledge]\{text\}}.
1597 \itemAP[\smallcode{\klqn"text\klqn{@@}scope\klqn"}]\phantomintro{"...@@..."}%
1598 uses the "knowledge" pointed to by `text' in "scope" `scope' to display `text'. Equivalent to~\texttt{\cs\kl(scope)\{text\}}.
1599 \itemAP[\smallcode{\klqn"text\klqn@knowledge\klqn@scope\klqn"}]\phantomintro{"...@...@..."}%
1600 uses the "knowledge" pointed to by `knowledge in "scope" `scope' to display `text'. Equivalent to~\texttt{\cs\kl[knowledge](scope)\{text\}}.
1601 \itemAP[\smallcode{\klqn{""}text\klqn{""}}]\phantomintro{""...""}%
1602 introduces the "knowledge" pointed to by `text'. Equivalent to~\texttt{\cs\intro\{text\}}.
1603 \itemAP[\smallcode{\klqn{""}text\klqn@knowledge\klqn{""}}]\phantomintro{""...@...""}%
1604 introduces the "knowledge" pointed to by `knowledge while displaying `text'. Equivalent to~\texttt{\cs\intro[knowledge]\{text\}}.
1605 \itemAP[\smallcode{\klqn{""}text\klqn{@@}scope\klqn{""}}]\phantomintro{""...@@...""}%
1606 introduces the "knowledge" pointed by `text' in "scope" `scope'. Equivalent to~\texttt{\cs\intro(scope)\{text\}}.
1607 \itemAP[\smallcode{\klqn{""}text\klqn@knowledge\klqn@scope\klqn{""}}]\phantomintro{""...@...@...""}%
1608 introduces the "knowledge" pointed to by `knowledge in "scope" `scope' while displaying `text'.\\
1609 Equivalent to~\texttt{\cs\intro[knowledge](scope)\{text\}}.
1610 \end{description}
1611
1612 \noindent\AP Activating the "quotation notation" is obtained using:
1613 \begin{center}
1614 \smallcode{\cs\knowledgeconfigure\{"quotation@@option"\}}\ ,
1615 \end{center}
1616 and deactivating it is obtained using:
1617 \begin{center}
1618 \smallcode{\cs\knowledgeconfigure\{"quotation@@option"=false\}}.
1619 \end{center}
1620 It can also be activated while loading the package.
1621
1622 \AP It is sometimes the case that some packages do use the quote symbol, usually in some environment
1623 (this is the case of the "tikzcd@@env" environment). The "knowledge@@package" package can be configured to deactivate always the "quotation notation" when entering the environment. This is obtained using the "configuration option" ""protect quotation="" followed by a list of environments to be protected:
1624 \begin{CODE}[12cm]
1625 \cs\knowledgeconfigure\{"protect quotation="\{env1,env2,\dots\}\}
1626 \end{CODE}
1627 Note that the braces surrounding the list of environments can be omitted if the list contains only one item.
1628
1629 There are nevertheless some situations in which one would prefer to use the original \cs{\kl} notation:
1630 \begin{itemize}
1631 \item When nesting of "knowledges" is involved, or the "knowledge" includes the symbol \kl",
1632 \item when "quotation@@option" is deactivated (or not activated) because of a conflict
1633 \item in particular, this should be avoided in macros, in particular for the math mode, since these may be used one day or another in a "tikzcd@@env" or similar environment for instance.
1634 \end{itemize}
1635
1636
1637
1638 \subsubsection{Variants}
1639
1640 Several variants of the \cs\kl-command are defined by default. The syntax for their use is the same (including "scopes", \dots).
1641 The following variants are linked to the "autoref" directive:
1642 \begin{itemize}
1643 \item \cs\intro\ is used to introduce a knowledge.
1644 \item \cs\reintro\ displays like for introducing the knowledge, but does not do it.
1645 \item \cs\rekl\ behaves like \cs\kl\ acts as a modifier and transforms \cs\intro\ into \cs\reintro.
1646 \item \cs\phantomintro\ performs the introduction, but does display anything.
1647 \itemAP \csintro\kref\ displays the number of the environment in which the introduction took place.
1648 \itemAP \csintro\kpageref\ displays the number of the page in which the knowledge introduction took place.
1649 \item \csintro\kcref, \csintro\kCref, \csintro\kcpageref, \csintro\kCpageref, \csintro\knamecref, \csintro\knameCref,
1650 \csintro\knamerefs, and \csintro\knameCrefs, display informations about the place of introduction of a "knowledge",
1651 following the semantics of the corresponding functions in the "cleveref@@package" package (see \kCref*"cleveref@@option").
1652 \end{itemize}
1653
1654 \subsubsection{Defining your own variants}
1655 \label{subsubsection:variants}
1656 \phantomintro{variant of \cs{\kl}}%
1657 It may happen for several reasons that we may want to define new variants of the \cs{\kl} macros, that essentially perform the same task, but are configured differently. Typical examples may be:
1658 \begin{itemize}
1659 \item several sets of "knowledges" may intersect but should use different "namespace",
1660 \item some "knowledges" involve macros and for this reason should be non-expanded even if the \cs{\knowledge}
1661 command is not met,
1662 \item the \cs{\knowledge} command should be called implicitly,
1663 \item activate or deactivate the warnings or messages in the "diagnose file".
1664 \end{itemize}
1665 In fact, several macros in this document are instantiation of this mechanism. This is the case for for instance for \cs{\intro}, \cs{\phantomintro}, \cs{\reintro} or \cs{\mathkl} etc...
1666
1667
1668 \AP The macro for introducing a new \reintro{variant of \cs{\kl}} is:
1669 \begin{center}
1670 \smallcode{\csintro{\knowledgenewvariant}\cs\variant\{\kl{variant directives}\}}
1671 \end{center}
1672 and is similar to the one for modifying the behavior of a "variant of \cs{\kl}":
1673 \begin{center}
1674 \smallcode{\csintro{\knowledgesetvariant}\cs\variant\{\kl{variant directives}\}}\ .
1675 \end{center}
1676 These command define/modify a/the macro \cs{\variant} that uses the same syntax as \cs{\kl}. \AP The \intro{variant directives} consist of a comma separated list of "directives@@variant" as follows:
1677 \begin{compactdesc}
1678 \itemAP[""namespace=@@variant""namespace] declares in which "namespace" (a string) the knowledges are to be searched.
1679 This means in particular that the \cs{\knowledge} concerned should be defined using the the proper "namespace=" directive.
1680 \itemAP[""default style=@@variant"", ""unknown style=@@variant"", ""unknown style cont=@@variant""\{list of "style" names\}]
1681 declares the style name to be used (1) by default when the "knowledge" is found, (2) when it is not found for the first time, and (3) the subsequent times.
1682 \itemAP[""style directive=@@variant""\{directive names list\}] defines a list (comma separated) of directives that can
1683 be used in a \cs{\knowledge} command to modify the aspect (for instance, the \cs{\intro} behavior is modified by the "intro style=" directive, while the \cs{\kl} command is configured using the "style=" directive). If the "directives" do not exist, these are created.
1684 \itemAP[""auto knowledge=@@variant""\{directives\}] declares that the use of \cs{\variant} should automatically execute a \cs{\knowledge} command, and what should be the directives it uses. See examples below.
1685 \itemAP[""unknown warning=@@variant""true/false] activates or deactivates the warnings when a "knowledge" is not found
1686 (for instance, these are deactivated in "paper mode"). True by default.
1687 \itemAP[""unknown diagnose=@@variant""true/false] activates or deactivates the corresponding messages in the "diagnose file". True by default.
1688 \itemAP[""suggestion=@@variant""\{directives\}] configures the "directives" to be suggested in the "diagnose file"
1689 when the "knowledge" is unknown.
1690 \itemAP[""PDF string=@@variant""\{code\}] gives a substitute text for "hyperref@@package" to use for producing the bookmarks. This code has to be expandable. The code may use three parameters; $\sharp1$ is the main text of the command, $\sharp 2$ is the optional parameter, and $\sharp 3$ is the scope. The macro \cs{\IfNoValueTF} of the package "xparse@@package" can be used to test if the second and third arguments are present. By default, the code is \texttt{\{$\sharp1$\}}. Note that the star syntax cannot be used in this context. It the expected result cannot be achieved using this directive, the less convenient macro \cs{\texorpdfstring} of the "hyperref@@package" package should be used.
1691 \item[""display code=@@variant""] can be used to shortcut the standard code for display. See the code for more details. Typical examples are the "variants" \cs\kref,\ \cs\kpageref\ and so on, which do not display the knowledge itself, but instead treat the underlying label associated.
1692 \end{compactdesc}
1693 \smallskip
1694
1695 \AP The second feature is to use "modifiers@@variant". These correspond to the stared version of the command.
1696 For instance, one expects `\cs{\intro}*\cs{\kl}' to reduce to `\cs{\intro}'. For this, one has to declare explicitly the reduction using:
1697 \begin{center}
1698 \smallcode{\csintro{\knowledgevariantmodifier}\{"stared sequence@@variant"\}\cs\variant}\ ,
1699 \end{center}\AP
1700 in which the ""stared sequence@@variant"" is of the form `\cs{variant1}*\cs{variant2}*\dots*\cs{variantk}'.
1701 This sequence is declared to reduce to \cs{\variant}.
1702 For instance, \smallcode{\cs{\knowledgevariantmodifier}\{\cs{\intro*}\cs\kl\}\cs\intro} declares `\cs{\intro}*\cs{\kl}' to reduce to `\cs{\intro}'.
1703
1704 \subsubsection{Examples of \kl{variants}}
1705
1706 The best way for introducing new variants is to look at examples. We provide two of them now.
1707 the first one is the configuration of the \cs{\kl} and \cs{\intro} commands as defined in the "package@knowledge@package".
1708 The second one is the code used in this documentation for displaying macros, defining the macros \cs{\cs}
1709 and \cs{\csintro}.
1710
1711 \paragraph{The configuration of \cs{\kl} and \cs{\intro}} It is also interesting to see this code since it gives more ideas on how to modify the standard behaviour of these commands correctly.
1712 \begin{CODE}
1713 \cs\knowledgestyle\{autoref link\}\{"autoref link"\}\par
1714 \cs\knowledgestyle\{autoref target\}\{"autoref target"\}\par
1715 \cs\knowledgestyle\{invisible\}\{"invisible"\}\par
1716 \cs\knowledgenewvariant\cs\kl\{\par
1717 ~~~~"namespace=@@variant"default,\par
1718 ~~~~"default style=@@variant"\{"kl@@style",autoref link\},\par
1719 ~~~~"unknown style=@@variant" "kl unknown@@style",\par
1720 ~~~~"unknown style cont=@@variant" "kl unknown cont@@style",\par
1721 ~~~~"style directive=@@variant" "style@style="\par
1722 \}\par
1723 \cs\knowledgenewvariant\cs\intro\{\par
1724 ~~~~"namespace=@@variant" default,\par
1725 ~~~~"default style=@@variant" \{"intro@@style",autoref target\},\par
1726 ~~~~"unknown style=@@variant" "intro unknown@@style",\par
1727 ~~~~"unknown style cont=@@variant" "intro unknown cont@@style",\par
1728 ~~~~"style directive=@@variant" "intro style@intro style="\par
1729 \}\par
1730 \cs\knowledgevariantmodifier\{\cs{\intro*}\cs\kl\}\cs\intro
1731 \end{CODE}
1732 Note that \cs{\reintro} and \cs{\phantomintro} are defined using similar code.
1733
1734 \paragraph{Displaying control sequences}
1735
1736 \AP The second code example is used in this document (the documentation of the package) and consists of two macros \csintro{\cs} and \csintro{\csintro} which have the
1737 following semantics:
1738 \begin{itemize}
1739 \item these correspond, and have the same syntax as, \cs{\kl} and \cs{\intro} respectively,
1740 \item these are used to display control sequences without executing them,
1741 \itemAP if \smallcode{\cs{\csintro}\{\cs[\ucommand]\command\}} is used, then it displays \csintro\command\ in color blue, and
1742 every occurrences of \smallcode{\cs\cs\{\cs\command\}} yields \cs\command\ being displayed in dark blue
1743 and linking to the introduction point,
1744 \item if \smallcode{\cs\csintro\{\cs[\ucommand]\command\}} is never used,
1745 then \smallcode{\cs\cs\{\cs[\ucommand]\command\}} simply displays \cs[\ucommand]\command\ in black,
1746 \item no \cs{\knowledge} command is necessary, and no warning is issued if a command is unknown.
1747 \end{itemize}
1748 \begin{CODE}
1749 \cs\knowledgestyle\{cs\}\par
1750 ~~~~\{"detokenize","remove space","typewriter","up","md","color="NavyBlue\}\par
1751 \cs\knowledgestyle\{cs unknown\}\par
1752 ~~~~\{"detokenize","remove space","typewriter","up","md","color="black\}\par
1753 \cs\knowledgenewvariant\cs\cs\{\par
1754 ~~~~"namespace=@@variant"cs,\par
1755 ~~~~"default style=@@variant"\{autoref link,cs\},\par
1756 ~~~~"unknown style=@@variant"cs unknown,\par
1757 ~~~~"unknown style cont=@@variant"cs unknown,\par
1758 ~~~~"unknown warning=@@variant"false,\par
1759 ~~~~"unknown diagnose=@@variant"false,\par
1760 ~~~~"suggestion=@@variant"cs\par
1761 \}\par
1762 \cs\knowledgestyle\{csintro\}\par
1763 ~~~~\{"detokenize","remove space","typewriter","up","md","color="blue\}\par
1764 \cs\knowledgestyle\{csintro unknown\}\par
1765 ~~~~\{"detokenize","remove space","typewriter","up","md","color="black\}\par
1766 \cs\knowledgenewvariant\cs\csintro\{\par
1767 ~~~~"namespace=@@variant"cs,\par
1768 ~~~~"auto knowledge=@@variant"\{"autoref","scope="document,"also now"\},\par
1769 ~~~~"default style=@@variant"\{"autoref target",csintro\},\par
1770 ~~~~"unknown style=@@variant"csintro unknown,\par
1771 ~~~~"unknown style cont=@@variant"csintro unknown,\par
1772 \}\par
1773 \cs\knowledgevariantmodifier\{\cs{\intro*}\cs\cs\}\cs\csintro\par
1774 \cs\knowledgevariantmodifier\{\cs\csintro*\cs\cs\}\cs\csintro\par
1775 \end{CODE}
1776 Several things can be noted about this code:
1777 \begin{asparaitem}
1778 \item the "directives" "detokenize" and "remove space" prevent the execution of the argument, and instead display its name, this is important since the argument is a control sequence,
1779 \item the "directives" "typewriter", "up" and "md" give a uniform aspect (no italic, no boldface) to the result in all contexts,
1780 \item the "namespace" is set to be different from the default one, avoiding possible clashes with \cs{\kl},
1781 \item when a \cs{\csintro} command is met, the corresponding \cs{\knowledge} command is automatically issued, in particular with `"scope="document' for guaranteeing the visibility of each command everywhere in the document,
1782 \item the "also now" directive is necessary for the compilation to (possibly) stabilize in
1783 two iterations, since it uses the proper \cs{\label} already at the first iteration (without "also now", it would be performed on the second one only, and with just "now", it would be visible only by the uses after the introduction).
1784 \item warnings and diagnose pieces of information are explicitly eliminated.
1785 \end{asparaitem}
1786
1787
1788
1789 \subsection{Scoping}
1790 \label{section:scopes}\label{subsection:scoping}
1791 \phantomintro{scoping}
1792
1793 \subsubsection{Principles of scoping}
1794
1795 When writing long documents, one often wants \kl{knowledges} to be isolated in some subparts. For instance, one may want a temporary definition in a proof to not leak elsewhere in the document where the same term could be used with a different meaning. Some definitions may be only meaningful in, say, the current section/part.
1796
1797 Two separate things have to be understood: how to define "knowledge" in a given "scope" (and create "scopes"), and how to access "knowledge" from a given "scope".
1798
1799 \paragraph{Accessing knowledge attached to a given scope}
1800 This can be done directly either using the parenthesis notations of \cs{\kl} and the second \klqn@ of
1801 the "quotation notation":
1802 \begin{center}
1803 \begin{tabular}{ccc}
1804 \smallcode{\cs\kl(scope name)\{knowledge\}}%
1805 &~or~&%
1806 \smallcode{\cs\kl(scope name)[knowledge]\{text\}}\\
1807 \smallcode{\klqn"knowledge\klqn{@@}scope\klqn"}%
1808 &~or~&%
1809 \smallcode{\klqn"text\klqn@knowledge\klqn@scope\klqn"}
1810 \end{tabular}
1811 \end{center}
1812 It works also for \cs{\intro} and with double quotes.
1813
1814 Another option is to import the scope locally, using:
1815 \begin{CODE}[10cm]
1816 \cs\knowledgeimport\{\textit{scope name 1,scope name 2,}\dots\}
1817 \end{CODE}
1818 After this command, the knowledges will be searched automatically in the imported scopes.
1819 The import stops at the end of the current scoping environment.
1820
1821 \paragraph{Attaching knowledge to a given scope}
1822 This can be done directly using the "scope=" "directive", for instance in:
1823 \begin{CODE}[12cm]
1824 \cs\knowledge\{knowledge\}\{"scope="\textit{scope name},\textit{directives}\}
1825 \end{CODE}
1826 \noindent
1827 or, this is obtained usint the "`\vbar'-notation" using `\klbn@'~:
1828 \begin{CODE}[8cm]
1829 \cs\knowledge\{\textit{directives}\}\\
1830 \indent~~~\klbn|~~knowledge\klbn@\textit{scope name 1}\\
1831 \indent~~~\klbn|~~synonym\klbn@\textit{scope name 2}\\
1832 \indent~~~$\vdots$~~~~~~~~~~~~$\vdots$
1833 \end{CODE}
1834
1835 \AP
1836 The other possibility is to define a knowledge inside a "scope@@env" environment:
1837 \begin{CODE}[8cm]
1838 \cs\begin\{"scope@@env"\}\cs\label\{label\}\\
1839 \indent\quad\cs\knowledge\{knowledge 1\}\{\textit{directives}\}\\
1840 \indent\qquad$\vdots$\\
1841 \cs\end\{"scope@@env"\}
1842 \end{CODE}
1843 \noindent
1844 In such a code, the knowledge defined is automatically visible in the environment,
1845 and from outside, using the scope name \texttt{label}. Indeed, the \cs{\label} is overloaded for doing automatically a \cs{\knowledgescope} command.
1846
1847 In fact, it is possible to do even more: other environments can be defined to behave like "scope@@env".
1848
1849
1850 \subsubsection{Scoping by examples}
1851
1852 ""Explicit scoping"" consists in attaching a precise scope name to a "knowledge" using the "scope=" "directive":
1853 \begin{CODE}
1854 \cs\knowledge\{thing\}\{"scope="s1,"color="red\}\\
1855 \cs\knowledge\{thing\}\{"scope="s2,"color="green\}\\
1856 \\
1857 Here, \klqn"thing\klqn" and \cs\kl\{thing\} are unknown.\\
1858 But \klqn"thing\klqn{@@}s1\klqn" and \cs\kl(s1)\{thing\} are in red,\\
1859 and \klqn"thing\klqn{@@}s2\klqn" and \cs\kl(s2)\{thing\} are in green.
1860 \end{CODE}
1861 The "`\vbar'-notation" can also be used for "explicit scoping".
1862 This is convenient, in particular for having synonyms in different scopes:
1863 \begin{CODE}
1864 \cs\knowledge\{"color="red\}\\
1865 \indent~~\klbn|~~abelian group\\
1866 \indent~~\klbn|~~abelian groups\\
1867 \indent~~\klbn|~~Abelian groups\\
1868 \indent~~\klbn|~~group\klbn@abelian\\
1869 \indent~~\klbn|~~groups\klbn@abelian\\
1870 \indent~~\klbn|~~Groups\klbn@abelian\\
1871
1872 Here, general \klqn"groups\klqn" are not defined but \klqn"groups\klqn{@@}abelian\klqn" are,\\
1873 and correspond to \klqn"abelian groups\klqn".\\
1874 \cs\begin\{"scope@@env"\}\cs\knowledgeimport\{abelian\}\\
1875 \indent~~All \klqn"groups\klqn" here are abelian.\\
1876 \cs\end\{"scope@@env"\}
1877 \end{CODE}
1878
1879
1880 "Scopes" can also be attached to areas in the code. It is convenient to use the usual \cs{\label} command to name them (though, in practive, two different naming spaces are used).
1881 \begin{CODE}
1882 \textcolor{gray}{\% We declare first in the preamble the environments that can have}\\
1883 \textcolor{gray}{\% knowledges attached to them.}\\
1884 \cs\knowledgeconfigureenvironment\{theorem,lemma,proof\}\{\}\\
1885 \\
1886 \textcolor{gray}{\% and now in the main body of the document.}\\
1887 \cs{\begin}\{theorem\}\cs\label\{theorem:main\}\\
1888 \indent~~ \cs\knowledge\{rabbit\}[rabbits]\{notion\}\\
1889 \indent~~ In every hat, there is a \cs\kl\{rabbit\},\\
1890 \indent~~ \cs\AP~in which a \cs\intro\{rabbit\} is a small animal with long ears.\\
1891 \cs{\end}\{theorem\}\\
1892 Here a \kl"rabbit\kl" is an "unknown knowledge".\\
1893 But \kl{"}rabbits\kl[quotation notation]{@@}theorem:main\kl{"} point to Theorem~\cs\ref\{theorem:main\}.\\
1894 \cs\begin\{proof\}\cs\knowledgeimport\{theorem:main\}\\
1895 \indent~~ Now, \kl"rabbit\kl" is hyperlinked to Theorem~\cs\ref\{theorem:main\}.
1896 \cs\end\{proof\}
1897 \end{CODE}
1898
1899 \subsubsection{What is the structure of \kl{scopes} in a document}
1900
1901 To start with, one needs to understand what are the possible \kl{scopes}. Scopes are aggregation of zones in the document.
1902 \begin{itemize}
1903 \itemAP By default, all the body of the document belongs to a \kl{scope} called `\texttt{document}'.
1904 The user can open new scopes using the \intro(env){scope} environment:
1905 \begin{CODE}[10cm]
1906 \cs\begin\{\kl(env){scope}\}\par
1907 ~~\cs\knowledge\{local notion\}\{\kl{color=}green\}\par
1908 ~~Here is a \cs\kl\{local notion\} that appears in green.\par
1909 \cs\end\{\kl(env){scope}\}\\
1910 But here the \cs\kl\{local notion\} is undefined.
1911 \end{CODE}
1912 Note that scoping is independent from the grouping mechanism of \LaTeX.
1913
1914 \AP The user can also declare environments such as \texttt{lemma}, \texttt{theorem},
1915 \texttt{remark} or \texttt{proof} to behave like \kl(env){scope}. This is achieved using using
1916 \cs{\knowledgeconfigureenvironment} command.
1917 \itemAP The use of the ""scope@scope option"" \kl{configuration option} goes one step further, and attaches "scopes" to sections, subsections, itemize, items, and so on. But be cautious, this feature, though working, may cause some compiling document to not compile anymore if some weird (and unnatural) nesting of scopes are used (this is the case for instance when using \cs{\bibitem} and \cs{\thebibliography}, and this has to be corrected by hand).
1918 \end{itemize}
1919
1920 \subsubsection{How is chosen the \kl{scope} of a \kl{knowledge}?}
1921
1922 In general, when a \cs{\knowledge} command is used, the system tries to figure out what should be its "scope":
1923 \begin{itemize}
1924 \item If the command occurs in the preamble, then the default \kl{scope} will be `document'.
1925 \item \AP Otherwise, the information is searched for in the ""stack of visible scope instances"" which means that the \kl{knowledge} will be defined at the level of the innermost surrounding scope that `attracts knowledges'. If the \kl{scope option} is not activated (and the user did not perform its own configuration), this is the inner most \kl(env){scope} environment (or similar environment if \cs{\knowledgeconfigureenvironment} has been used), or `document' if the declaration is not in the scope. If the \kl{scope option} is used, this will be the innermost lemma, proof, or theorem in the context.
1926 \item This default behavior can be modified using the \kl{scope=} directive. The \kl{scope=} directive can be followed with a scope level, such as `section', `subsection', 'chapter' or `itemize' (in particular in combination with the \kl{scope option}), that will be looked for in the current context and will receive the \kl{knowledge}. The \kl[\knowledge directives]{directive} can also be followed by a label name, and the active scope at the moment of this label will be used.
1927
1928 The following code (that requires the "scope option" for being functional) should be self explanatory:
1929 \begin{CODE}[11.5cm]
1930 \cs\section\{First section\}\par\noindent
1931 \cs\label\{section:first\}\par\noindent
1932 \cs\knowledge\{one\}\{\kl{scope=}section,\kl{color=}green\}\par\noindent
1933 \cs\knowledge\{two\}\{\kl{scope=}some label,\kl{color=}green\}\par\noindent
1934 ~\par\noindent
1935 \cs\begin\{\kl(env){scope}\}\cs\label\{some label\}\\
1936 \indent~~Here \cs\kl\{one\} and \cs\kl\{two\} are defined.\\
1937 \cs\end\{\kl(env){scope}\}\par\noindent
1938 Here \cs\kl\{one\} is defined but \cs\kl\{two\} isn't.\par\noindent
1939 ~\par\noindent
1940 \cs\section\{Second section\}\par\noindent
1941 Here neither \cs\kl\{one\} nor \cs\kl\{two\} is defined.
1942 However, I can still use them using \cs\kl(section:first)\{one\} and \cs\kl(some label)\{two\}
1943 (or \kl"one@@section:first\kl" and \kl"two@@some label\kl", or using the \cs{\knowledgeimport}\{section:first\}).
1944 \end{CODE}
1945 \end{itemize}
1946
1947 \subsubsection{Naming "scopes": the \cs{\knowledgeimport}, \cs{\knowledgescope} and \cs{label} commands
1948 }
1949
1950 It is often the case in a text, that one has to locally break the nesting structure of a document, and refer to a object local in an environment. For instance, a comment may refer to a variables/concept that has been locally used in the proof. The "knowledge@@package" provides suitable mechanisms for complex referencing of scopes. Let us explain this through an example:
1951 \begin{CODE}
1952 \textcolor{gray}{\% We declare first in the preamble the environments that use knowledge.}\\
1953 \cs\knowledgeconfigureenvironment\{definition\}\{knowledge=attracts\}\par\indent
1954 "[...]"\\
1955 \indent
1956 \cs\begin\{definition\}\cs\label\{somewhere\}\\
1957 \indent~~\cs\knowledge\{something\}\{notion\}\\
1958 \indent~~Here, \cs\intro\{something\} is a notion internal to the definition.
1959 \cs\end\{definition\}
1960 \end{CODE}
1961 Note here that what is important is the location of the \cs\knowledge\ command, irrespective of the location ofthe \cs\intro\ command.
1962
1963 \AP The \cs\label\ command is used to name the "scope". In fact, the real command is
1964 \begin{center}
1965 \smallcode{\csintro\knowledgescope\{scope name\}}
1966 \end{center}\noindent
1967 which associates a scope name to the surrounding environment (providing it has been declared possible to do it using
1968 \cs\knowledgeconfigureenvironment).
1969 \AP
1970 The standard \LaTeX\ command \cs\label\ is overloaded and performs implicitly a call to \cs\knowledgescope\ (this behavior can be deactivated/reactivated using the ""label scope=""\texttt{\{true,false\}} directive). The result is that the same string of characters can be used in order to name the scope, and at the same time is used as a standard \LaTeX\ label.
1971
1972 \AP Something important is missing so far: one rapidly wants to access to \kl{knowledges} that do not exist in the current \kl{scope}. For instance, a notion is used in a section of a document, and one would like to refer to it in the introduction. Another case is that of a notion or a mathematic variable that is introduced in the statement of a theorem, and should be accessible inside the proof. There are essentially two ways to access such distant \kl{knowledges}: either use the \smallcode{\cs\kl(label)\{text\}} command (or the equivalent \smallcode{\kl{"...@...@..."}} notation), or use the \cs{\knowledgeimport} command. We describe the second possibility now. The syntax is:
1973 \begin{center}
1974 \smallcode{\csintro\knowledgeimport\{label\}}
1975 \end{center}
1976 The result is that the \kl{knowledges} in the \kl{scope} identified by the label are now
1977 accessible until the closure of the current \kl{scope}.
1978
1979 For instance:
1980 \begin{CODE}[9cm]
1981 \cs\knowledgeconfigureenvironment\{theorem,proof\}\{\}\par\indent
1982 "[...]"\par\indent
1983 \cs\begin\{theorem\}\cs\label\{theorem:1\}\par\noindent
1984 ~~\cs\knowledge\verb|\alpha|\{\kl{autoref},\kl{color=}red\}\par\noindent
1985 ~~Let \$\cs\intro\verb|\alpha|\$ be an integer "[...]"\par\noindent
1986 \cs\end\{theorem\}\par\noindent
1987 "[...]"\par\indent
1988 Here \$\cs\kl\verb|\alpha|\$ is unknown.\par\noindent
1989 "[...]"\par\indent
1990 \cs\begin\{proof\}\par\noindent
1991 ~~\cs\knowledgeimport\{theorem:1\}\par\noindent
1992 ~~But now \$\cs\kl\verb|\alpha|\$ points to its definition.\par\noindent
1993 \cs\end\{proof\}
1994 \end{CODE}
1995
1996
1997
1998 \subsubsection{Managing scoping environments}
1999
2000 \AP The user can also declare an environment
2001 to behave like \kl(env){scope} using the
2002 command \cs{\knowledgeconfigureenvironment}, as well as adapt some of its characteristics using
2003 "scope directives".
2004 \begin{center}
2005 \smallcode{\csintro\knowledgeconfigureenvironment\{environments\}\{"scope directives"\}}
2006 \end{center}
2007 For instance:
2008 \begin{CODE}[12cm]
2009 \cs\knowledgeconfigureenvironment \{lemma,theorem,fact,proof\}\par
2010 ~~~~~~~~\{knowledge=attracts\}
2011 \end{CODE}
2012 \noindent
2013 will induce the corresponding environments to have internal knowledges.
2014
2015 Most of the time, it is not necessary to use "scope directives".
2016
2017 \begin{remark}
2018 Note that (in the current implementation) it is necessary to use the
2019 commands \cs{\begin} and \cs{\end}. Hence \cs{\proof}\dots\cs{\endproof} would
2020 not trigger a scoping environment while \cs{\begin{proof}}\dots\cs{\end{proof}}
2021 would.
2022 \end{remark}
2023
2024 \AP The ""scope directives"" are low level and advanced features. These should not be used in general. The list is the following:
2025 \begin{compactdesc}
2026 \itemAP[\intro(area){scope=}\texttt{true/false}] tells whether an environment should induce a scope. For the moment, this is not used (as soon as configured, it always behaves like a scope).
2027 \itemAP[\intro(area){label=}\texttt{none/accepts}] tells whether a \cs{\label} command can refer to an "instance" of this "area",
2028 \itemAP[\intro(area){environment=}\texttt{true/false}] should be set to true if the scope has to be opened whenever an environment of same name is opened using the \cs{\begin} and \cs{\end} commands of "latex".
2029 \itemAP[\intro(area){autoclose=}\texttt{true/false}] means that the closure is triggered by another event (closure of another enclosing instance, or pushing of an area that requires its closure). It should be true for "latex" environments, and false when configuring, e.g, \cs{\section} opens a "scope" and its closure should be automatic when another section begins.
2030 \itemAP[\intro(area){parents=}\{"area1@area","area2@area",\dots\}] takes a comma separated list of areas that are allowed as parent. For opening the area, some enclosing instances may be automatically closed for reaching such a parent (if their "autoclose=@@area" "directive@scope directive" is set to true). For instance, the parent of a subsection should be a section:
2031 Hence when a subsection begins, the currently opened subsection and subsubsection are closed.
2032 \itemAP[\intro(area){push code=}\texttt{\{code\}}] defines some code to be executed when the area is pushed (each time, these are added).
2033 \itemAP[\intro(area){pop code=}\texttt{\{code\}}] defines some code to be executed when the area is popped (added too).
2034 \itemAP[\intro(area){occurrences=}\texttt{once/multiple/recursive}] can be one of `\texttt{once}' if the area can only have one instance in the document, `\texttt{multiple}' if there can be several instances, but not nested, and `\texttt{recursive}', if there is no restriction.
2035 \itemAP[\intro(area){forces=}"area"] requires a specific area as an ancestor of this area. This ancestor is implicitly pushed if necessary.
2036 \end{compactdesc}
2037
2038
2039 \subsection{Error handling}
2040 \label{section:error handling}
2041
2042 By default, the "knowledge@@package" package tries to not stop the compilation unless a serious problem has been found. In particular, it is possible to write an entire document using \cs{\intro} and \cs{\kl} commands or the "quotation notation" without ever introducing a \kl{knowledge}, and only in the end provide this information. This is a feature: as opposed to normal macros, not defining a knowledge should not stop the real work, which is the writing of the document.
2043
2044 \AP
2045 Very often there is some \kl[undefined knowledge]{undefined knowledge}.
2046 Such \kl{knowledges} are displayed using the "kl unknown@@style" and "kl unknown cont@@style")
2047 \kl{styles} when issued by \cs{\kl}; using "intro unknown@@style" and "intro unknown cont@@style" when issued by \cs{\intro}.
2048 The detail of the problems are then gathered in the \kl{diagnose file}.
2049
2050
2051 \subsection{The \kl{diagnose file}}
2052 \label{subsection:diagnose file}
2053
2054 The \intro{diagnose file} is a file that is created when the "knowledge@@package" package is used
2055 (note that another file, ""jobname.kaux"" is also created by the "knowledge@@package" package, for internal use). It enormously eases the use of the package, and it is important to look into it when finalizing a document. It gathers a certain number of informations, that can be warning, code to be used, or simply information. This file has the name of the tex document with the extension \kl{.diagnose}. Its content is divided into clearly identified parts. Depending on the used options, some of these parts may appear or disappear.
2056 \begin{description}
2057 \itemAP[\intro{Undefined knowledges}] in this section are listed all the knowledges that have been unsuccessfully searched for. These are given in lines either of the form
2058 \begin{quote}
2059 \texttt{\cs{\knowledge}\{\textit{suggested directives}\}\\
2060 \indent~~~\klbn|~~undefined knowledge}\textit{[\klbn@scope]}\\
2061 \indent~~~~~~~~~~~~~~\vdots
2062 \end{quote}
2063 or of the form
2064 \begin{quote}
2065 \texttt{\cs{\knowledge}\{undefined knowledge\}\{\textit{suggested directives}\}}
2066 \end{quote}
2067 \AP Switching from one mode to another is obtained using the "configuration directive" "diagnose bar="\{true,false\} (default is true).
2068 The intent is that copying the content of this section to the document itself will solve all problems of \kl{undefined knowledges}. It is an efficient way,
2069 when one has written a document without caring so much about knowledges to copy the content of this section, and then modify it/reorganize it, in order to suit ones purposes. By default, no suggestion is offered, or "notion" is suggested if the "notion@@option" directive has been used. Suggestion can be automatically configured using the "suggestion=@@variant" "directive@@variant" of the macros \cs{\knowledgenewvariant} and \cs{\knowledgesetvariant}.
2070
2071 For instance, using:
2072 \begin{center}
2073 \smallcode{\cs\knowledgesetvariant\cs\kl\{"notion"\}}
2074 \end{center}
2075 the "directive" "notion@@option" is suggested for more directly copying the content.
2076 \itemAP[\intro{Autoref not introduced}] This section lists all \kl{knowledges} that were declared using the \kl{autoref} \kl[\knowledge directives]{directive} (this can be the case indirectly using, e.g. "notion"), but have not been introduced in the document . When a document reaches its final states, this section should be empty.
2077 Usually, one should add the corresponding \cs{\intro} or \cs{\phantomintro} command somewhere in the text.
2078 \itemAP[\intro{Autoref introduced twice}] In this section, all \kl{knowledges} that were declared using the \kl{autoref} \kl[\knowledge directives]{directive} and introduced using \cs{\intro} or \cs{\nointro}
2079 more than once are listed. When a document reaches its final states, this section should be empty. Consider using \cs{\kl} or \cs{\reintro} for solving the problem.
2080 Note that this may be caused by an \cs{\intro} used in some title (and repeated in the table of contents).
2081 \end{description}
2082
2083 \AP By default, the "diagnose file" does not give the file and the line of the messages.
2084 This can be activated using the "diagnose line" boolean option:
2085 \begin{center}
2086 \smallcode{\cs\knowledgeconfigure\{""diagnose line=""true\}}
2087 \end{center}
2088 \AP By default, the "diagnose file" gives suggestions to be used with the normal \cs\knowledge\ syntax.
2089 A "`\vbar'-notation" suggestion can be activated using:
2090 \begin{center}
2091 \smallcode{\cs\knowledgeconfigure\{""diagnose bar=""true\}}
2092 \end{center}
2093
2094 \iffalse
2095
2096 \subsection{Importing and exporting (\kl{not implemented})}
2097 \label{subsection:import-export}
2098
2099
2100 Exporting is not coded yet, and it is not even clear how it should be done.
2101
2102
2103 Exporting means outputting in the \kl{export file} some code that it is sufficient to include in another document for being able to refer to some knowledges.
2104
2105
2106 When this file is used, using for instance an \cs{\input} command, or simply copied and paste in another document, then the knowledge `Pythagorean theorem'
2107 becomes available, and points to the proper file.
2108 Hence in another document, we can use:
2109 \begin{CODE}
2110 \cs\knowledgeimport\{lesson1\}
2111 \end{CODE}
2112 that would make immediately available all the knowledge attached to \kl{scope} `lesson1'. Another possibility if this should be linked only once is to use it directly in the text:
2113 \begin{CODE}
2114
2115 \end{CODE}
2116
2117 It is useful to be able to 1) export some of the knowledges defined in a document, and 2) import them in another document. For the moment this feature is not coded.
2118 \kl{to be done}
2119
2120 \begin{itemize}
2121 \item \csintro\knowledgeexportscopename
2122 \item \csintro\knowledgeexportbase
2123 \item \csintro\knowledgeimport
2124 \end{itemize}
2125 \fi
2126
2127
2128
2129 \subsection{Other packages}
2130
2131 \subsubsection{The \kl{xcolor option}}
2132 \label{subsection:xcolor package}
2133
2134 The \intro{xcolor option} is used if one wants to change colors. It is good to always load it since it also triggers coloring for debugging. It triggers colors in the \kl{warning styles} that can be useful in debugging.
2135 It also offers two new directives:
2136 \begin{description}
2137 \itemAP[\intro{color=}] where in `\kl{color=}name', name is a color description following the syntax of the "xcolor@@package" package.
2138 \itemAP[\intro{cyclic color}] similar to `"color="', but selects the color automatically in a a cyclic list of colors. This can be convenient for debugging.
2139 The cyclic list of colors can be chosen using the "configuration directive" ""cyclic colors=@@option"":
2140 \begin{center}
2141 \smallcode{\cs\knowledgeconfigure\{"cyclic colors=@@option"\{color1,color2,\dots\}\}}
2142 \end{center}
2143 Note that no spaces are allowed between colors, and that at least two colors are required.
2144
2145 The default cyclic color list is:
2146 \begin{center}
2147 \texttt{\{red,green,blue,cyan,magenta,yellow,gray,brown,lime,\\olive,orange,pink,purple,teal,violet\}}
2148 \end{center}
2149 \itemAP[\intro{colorbox=}] surrounds the text with a colorbox of given color (following the syntax of the "xcolor@@package" package).
2150 \end{description}
2151 Loading the package before is necessary for changing
2152 the options of the "xcolor@@package" package
2153 (for instance for using \kl{svgnames}).
2154
2155 \subsubsection{The \kl{hyperref option}}
2156 \label{subsection:hyperref option}
2157
2158 \subsubsubsection{Activating the \kl{hyperref option}}
2159 \marginpar{%
2160 \begin{hint}
2161 The "hyperref@@package" surrounds by default links by boxes that are graphically heavy
2162 (this are visible in some viewers, and not in some others): this is automatically deactivated when loading
2163 the "knowledge@@package" package. Such automatic behaviour can be avoided using the \kl{no patch}
2164 option at loading.
2165 \end{hint}}
2166 The \intro{hyperref option} loads the \intro(package){hyperref}
2167 and triggers a certain number of link-related features.
2168 This is done either by the command:
2169
2170 %
2171 \begin{center}
2172 \smallcode{%
2173 \cs{\usepackage}[\kl(option){hyperref}]\{\kl(package){knowledge}\}}
2174 \end{center}
2175 \noindent or by loading the "hyperref@@package" before the "knowledge@@package" package.
2176
2177 The \kl[\knowledge directives]{directives} activated by the package are:
2178 \begin{compactdesc}
2179 \itemAP[\kl{url=}] for hyperlinking to an external document
2180 \item[\kl{ref=}] for hyperlinking inside document
2181 \item[\kl{protect link}] it a boolean for protecting from the creation of nested hyperlinks,
2182 \item[\kl{autoref}] for relating objects with their definition
2183 \item[\kl{autorefhere}] similar, and used implicitely for math
2184 \end{compactdesc}
2185
2186 \AP
2187 The package comes also with the "configuration directive" \intro{hyperlinks=} which is a boolean
2188 deactivates or reactivates the links.
2189
2190
2191
2192 \subsubsubsection{Functionnalities triggered by the \kl{hyperref option}}
2193
2194 \begin{description}
2195 \itemAP[\intro{ref=}]\texttt{\{label\}} puts an hyperlink pointing toward a label inside the document (the braces can be omitted when there is no comma).
2196 \item[\intro{protect link}] disables the inside hyperlinks,
2197 \item[\intro{url=}]\texttt{\{url address\}} puts an hyperlink to an (external) url
2198 (the braces can be omitted when there is no comma).
2199 \marginpar{\begin{hint} You may have to use \texttt{$\backslash$\~} instead of \texttt{\~} in url's addresses.\end{hint}}
2200 \end{description}
2201
2202 \subsubsubsection{The \kl{autoref} directive}
2203 \marginpar
2204 {\begin{hint} It is usually easier to use the `\kl{notion}' directive
2205 than simply the \kl{autoref} directive. Its use it already configured. \end{hint}}
2206 \phantomintro{""}
2207 The \intro{autoref} \kl[\knowledge directives]{directive} is among the most useful offered by the "knowledge@@package" package.
2208 It is very often used indirectly through directives like "notion".
2209 When set, the \kl{knowledge} should be used with both \csintro{\intro} (exactly once) --
2210 or the \kl{""...""} and \kl{""...@...""} notations (and variants) if \kl(option){quotation} is active -- and \cs{\kl} (possibly several times) -- or the \kl{"..."} notation if \kl(option){quotation} is active. The use of \cs{\kl}
2211 will hyperlink to the location of the \cs{\intro}. The syntax of \cs{\intro} is the same as
2212 for \cs{\kl}:
2213 \begin{center}
2214 \smallcode{\cs{\intro}[optional knowledge name]\{knowledge name\}}
2215 \end{center}
2216
2217 \emph{See \cs{\AP} below for improving the result.}
2218
2219 A typical use looks as follows:
2220 \marginpar{\begin{hint}
2221 Though the \cs{\intro} command can be used
2222 in the title of, e.g. sections, without any errors, this may cause
2223 a warning when a \kl{table of contents} is used: the command is
2224 executed twice, once in the \kl{table of contents}, and once in the
2225 document itself.
2226 \end{hint}}
2227 \begin{CODE}
2228 \cs\knowledge\{house\}[Houses\vbar houses]\{\kl{autoref}\}\\~
2229 "[...]"\\
2230 \cs\begin\{document\}\\~
2231 "[...]"\\
2232 In this document, we will see the very important notion of \kl{"}houses\kl{"}.\\~
2233 "[...]"\\
2234 \cs\AP\\
2235 Let us define a \kl{""}house\kl{""} to be a building that functions as a home.\\~
2236 "[...]"\\
2237 \cs\end\{document\}
2238 \end{CODE}\noindent
2239 yields
2240 \begin{PDFoutput}
2241 \knowledge{house}[Houses| houses]{autoref}%
2242 "[...]"\\
2243 In this document, we will see the very important notion of \kl{houses}.\\~
2244 "[...]"\\
2245 \AP
2246 Let us define a \intro{house} to be a building that functions as a home.
2247 \\~
2248 "[...]"
2249 \end{PDFoutput}
2250
2251 \AP
2252 The variant \csintro{\intro*} makes the next \cs{\kl} command behave like \cs{\intro}. This is useful in particular in math mode:
2253 \begin{CODE}
2254 \cs\newcommand\kl[@token]\monoid\{\cs\kl[\kl[@token]\monoid]\{\cs\mathcal M\}\}\\
2255 \cs\knowledge\kl[@token]\monoid\{autoref\}\\~
2256 "[...]"\\
2257 \cs\AP\\~
2258 Let now \$\cs{\intro*}\kl[@token]\monoid\$ be a monoid.\\~
2259 "[...]"\\
2260 Remember now who is \$\kl[@token]\monoid\$.
2261 \end{CODE}
2262 %
2263 \marginpar{\begin{hint} This does not work in \kl{align*} and similar environments.
2264 Section~\ref{section:amsmath questions} gives some solutions. \end{hint}}
2265 \begin{PDFoutput}
2266 \newcommand\moonoid{\kl[\moonoid]{\mathcal M}}
2267 \knowledge\moonoid{autoref}
2268 \AP
2269 Let now $\intro*\moonoid$ be a monoid.\\~
2270 "[...]"\\
2271 Remember now who is $\moonoid$.
2272 \end{PDFoutput}
2273
2274 \AP The \csintro{\phantomintro} version:
2275 \begin{center}
2276 \smallcode{\cs{\phantomintro}(optional label)\{knowledge\}}
2277 \end{center}
2278 takes a \kl{knowledge}, and introduces it at the current location, without displaying anything. This is behaves like an invisible intro, i.e., essentially an abbreviation for \smallcode{\cs\intro[knowledge]\{\}}.
2279 This can be used as a workaround in environment like \kl{align*} that do not allow the use of labels (see Section~\ref{section:amsmath questions}).
2280
2281
2282 \AP
2283 The \csintro{\nointro} command:
2284 \begin{center}
2285 \smallcode{\cs{\nointro}\{knowledge\}}
2286 \end{center}
2287 does not display anything and silently prevents the knowledge from issuing warnings
2288 because it is not introduced.
2289
2290 \AP
2291 The \csintro{\reintro} command:
2292 \begin{center}
2293 \smallcode{\cs{\reintro}[optional knowledge]\{knowledge\}}
2294 \end{center}
2295 is displayed as for \cs{\intro}, but without being an anchor for hyperlinks, and without counting as a real \cs\intro. It is used if there are for some reason several places that should look like an introduction (typically in the same paragraph), but count as a single target. There is a variant \csintro{\reintro*} that makes the next \cs{\kl} command behave like a \cs{\reintro} (similar to \cs{\intro*} with respect to \cs{\intro}).
2296
2297 \AP
2298 \kl{Knowledges} that use this directive can be parameterized by modifying the style "intro@@style".
2299
2300 \AP
2301 For modifying the display of \kl{knowledges} introduced by \cs{\intro},
2302 there are new directives:
2303 \begin{description}
2304 \itemAP[\intro{intro style=}] that takes the name of a \kl{style} as argument.
2305 This \kl{style} will be used when the \kl{knowledge} is used in a \cs{\intro} or \cs{\reintro} command.
2306 \itemAP[\intro{autoref target}] declares the knowledge to be the target of the autoref (this is implicit when using \cs{\intro}).
2307 \itemAP[\intro{autoref link}] requires a link to the target of the autoref to be produced (this is implicit when using \cs{\kl}).
2308 \end{description}
2309 See the use of \cs{\knowledgesetvariant} for examples of configuration.
2310 %Hence:
2311 %\begin{CODE}
2312 %%test
2313 %\end{CODE}
2314
2315 \subsubsubsection{The \kl{autorefhere} \kl[\knowledge directives]{directive}}
2316
2317 The \intro{autorefhere} directive silently introduces an \kl{anchor point} at the location of the \cs{\knowledge} command invoking it.
2318 Uses of \cs{\kl} commands will be hyperlinked to this location.
2319
2320 \AP
2321 In some sense, an \kl{autorefhere} directive can be understood as the sequence of
2322 a \kl{autoref} directive that would be immediately followed by the corresponding \cs{\intro} command. This is a bit better since using \kl{autoref} in the body of the document requires three phases of compilation (two only if in the preamble).
2323 However, the \kl{autorefhere} \kl[\knowledge directives]{directive} does only require two (as for normal labels).
2324
2325 \AP
2326 In fact, this \kl{autorefhere} directive is what is used underneath when introducing mathematical variables, and should be used for implementing similar behaviors.
2327
2328
2329 % phantomsection behaves badly in sections
2330 \let\oldphantomsection\phantomsection
2331 \RenewDocumentCommand\phantomsection{}{\oldphantomsection}
2332
2333 \subsubsubsection{Using \kl{anchor points}}
2334
2335
2336 The directives \kl{autoref} and \kl{autorefhere} use underneath the "hyperref@@package" package. This means that it puts à label at the place of the \cs{\intro} command, and then points to it. However, the semantics in this case, is to jump to the beginning of the surrounding `region'.
2337 If the \cs{\intro} happens in a `section' (but not inside a theorem-like envionment) then the \cs{\kl} command will point at the beginning of the section, possibly 10 pages above the definition itself.
2338
2339 \AP
2340 The standard solution in the \kl(package){hyperref} package
2341 is to use the \csintro{\phantomsection}. This means defining \intro{anchor points} in the document that will be the target of hyperlinks.
2342
2343 We offer here new commands for helping using this feature:
2344 \smallskip
2345 \begin{compactdesc}
2346 \itemAP[\csintro{\AP}] declares an \kl{anchor point} at the left of the current column, at the height of the current line. If the \kl{configuration option} \kl{visible anchor points} is set (and this is the case by default), a mark will show the precise location of the target. Be careful: it does not work in some situations, like for instance inside the optional argument of an \cs{\item} command (but this is ok elsewhere in an itemize environment), or inside a some macros in mathmode (e.g. fractions). In the particular case of \cs{\item}, one should use instead:
2347 \itemAP[\csintro{\itemAP}] Similar to \cs\AP, but to be used instead of an \cs\item.
2348 \end{compactdesc}
2349 \smallskip
2350
2351 Usually putting an \cs{\AP} (a standard command of the "hyperref@@package") at the beginning of every paragraph, and replacing \cs{\item} by \cs{\itemAP} in itemize-like environments is most of the time good and safe option.
2352
2353 For instance:
2354 \begin{CODE}[12.5cm]
2355 \cs\AP\\
2356 In order to describe what is a \cs\kl\{monoid\}, let us us first define
2357 a \cs\intro\{product\} to be an associative binary operator,
2358 and a \cs\intro\{unit\} to be "[...]"
2359 \bigskip
2360
2361 \cs\begin\{description\}\\
2362 \cs\itemAP[A \cs\intro\{semigroup\}] is a set equipped with a \cs\kl\{product\}.\\
2363 \cs\itemAP[A \cs\intro\{monoid\}] is a \cs\kl\{semigroup\} that has a \cs\kl\{unit\}.\\
2364 \cs\end\{description\}
2365 \end{CODE}
2366 \noindent
2367 yields
2368 \begin{PDFoutput}[10cm]
2369 \knowledgeconfigure{visible AP=true}
2370 \knowledge{semigroup2}{text=semigroup,autoref}
2371 \knowledge{monoid2}{text=monoid,autoref}
2372 \knowledge{product2}{text=product,autoref}
2373 \knowledge{unit2}{text=unit,autoref}
2374 ~~~~~~~
2375 \begin{minipage}{8.8cm}
2376 \smallskip
2377 \AP In order to describe what is a \kl{monoid2}, let us us first define
2378 a \intro{product2} to be an associative binary operator,
2379 and a \intro{unit2} to be
2380 "[...]"\par
2381 \begin{description}
2382 \itemAP[A \intro{semigroup2}] is a set equipped with a \kl{product2}.
2383 \itemAP[A \intro{monoid2}] is a \kl{semigroup2} that has a \kl{unit2}.
2384 \smallskip
2385 \end{description}
2386 \end{minipage}
2387 \end{PDFoutput}
2388 \AP
2389 One can check that the different knowledges are properly hyperlinked, and that precise targets are the one described by \cs{\AP} and \cs{\itemAP}. For helping debugging the \kl{anchor points}, these are by default made visible as (red)
2390 corners on output. When the "knowledge@@package" package is loaded with the \kl{paper} option
2391 this graphical help disappears.
2392 This can also be deactivated using:\phantomintro{visible anchor points}
2393 \begin{quote}
2394 \smallcode{\cs\knowledgeconfigure\{\kl{visible anchor points=}false\}}.
2395 \end{quote}
2396 \AP The color of "anchor points" can be changed using (in which colors are defined as in the package "xcolor@@package"):
2397 \begin{quote}
2398 \smallcode{\cs\knowledgeconfigure\{""anchor point color=""color\}}, or \\
2399 \smallcode{\cs\knowledgeconfigure\{""AP color=""color\}}.
2400 \end{quote}
2401 \AP The shape of "anchor points" can be changed using (in which shape can be one of
2402 \texttt{tiny corner}, \texttt{small corner}, \texttt{corner}, \texttt{large corner},
2403 \texttt{tiny cross}, \texttt{small cross}, \texttt{cross}, \texttt{large cross}, or some code to be used in the "picture@@env" environment):
2404 \begin{quote}
2405 \smallcode{\cs\knowledgeconfigure\{""anchor point shape=""shape\}}, or \\
2406 \smallcode{\cs\knowledgeconfigure\{""AP shape=""shape\}}.
2407 \end{quote}
2408 Finally, the "anchor points" reference point can be shifted, using:
2409 \begin{quote}
2410 \smallcode{\cs\knowledgeconfigure\{""anchor point shift=""\{$x$,$y$\}\}}, or \\
2411 \smallcode{\cs\knowledgeconfigure\{""AP shift=""\{$x$,$y$\}\}},
2412 \end{quote}\noindent
2413 in which $x$ and $y$ are by default in unit \texttt{em} (note the use of curly braces and of no parenthesis, which is mandatory).
2414
2415
2416 \subsubsection{The \kl(option){makeidx} and \kl(option){imakeidx} options}
2417 \label{subsection:makeidx option}
2418
2419 \subsubsubsection{Activating the \kl(option){makeidx} and \kl(option){makeidx} options}
2420
2421 The \intro{makeidx option} loads the \kl(package){imakeidx} package and triggers a certain number of link-related features. This is done either by the command:
2422 \begin{center}
2423 \smallcode{\cs{\usepackage}[\kl(option){makeidx}]\{\kl(package){knowledge}\}}
2424 \end{center}\noindent
2425 or by loading the \kl(package){makeidx} before the "knowledge@@package" package.
2426 The same goes for the \intro{imakeidx option}.
2427
2428 \subsubsubsection{Features}
2429
2430 When activated, it becomes possible to trigger the \cs{\index} command when a \cs{\kl} command is used.
2431 The following \kl[\knowledge directives]{directives} are to be used:
2432 \begin{description}
2433 \itemAP[\intro{index=}] is the text typeset in the index. It uses the standard syntax of the \cs{\index} command. By default, it is the knowledge name itself. You can use the full syntax of \cs{\index} in it, i.e. using `!' and `@'.
2434 \itemAP[\intro{index key=}] takes as argument the \kl{index key}: a text that is used for identifying the \kl{index entry} (usually an accent free version of it). You can use `!' in it, as long as it does not clash with "index=" in order to avoid clashes.
2435 \itemAP[\intro{index parent key=}] makes the \kl{index entry} be a subentry of the given \kl{main index entry} (a replacement of `!'). Once more, it should not clash with "index=" and "index key=".
2436 \itemAP[\intro{index style=}] is followed by a token (without the escape character) that will be used for displaying the number (e.g. "index style="\texttt{textbf}). Usually, this is to be used in order to typeset in a particular manner the knowledges in the index when introduced. By default, when introducing "notion" (or when using \cs{\KnowledgeConfigureNotion} for instance) the macros \csintro{\notionKnowledgeIndexStyle} and \csintro{\notionKnowledgeIndexIntroStyle} are defined and used. Hence, you can use for instance:
2437 \begin{CODE}[10cm]
2438 \cs\def\cs\notionKnowledgeIndexIntroStyle\#1\{\cs\fbox\{\#1\}\}
2439 \end{CODE}
2440 \itemAP[\intro{index name=}] requires to activate "imakeidx@@option", and allows to choose the index name in case of multiple indexes.
2441 \end{description}
2442 \AP
2443 The "directive" ""no index"", deactivates the index feature for a knowledge. This is meant to be used in a "style".
2444 For instance
2445 \begin{CODE}
2446 \cs\knowledgedirective\{standard\}\par\noindent~~~~~
2447 \{"autoref","style="standard,"intro style="intro standard\}\\
2448 \cs\knowledgestyle\{standard\}\{"no index"\}\\
2449 \cs\knowledgestyle\{intro standard\}\{"emphasize"\}\\
2450
2451 \cs\knowledge\{test\}\{standard,"index=" test\}
2452 \end{CODE}\noindent
2453 result in that the introductions of `test' will be gathered in the index, but not the other uses.
2454
2455 \subsubsection{The \kl{cleveref option}}
2456
2457 The \intro(option){cleveref} option loads the "cleveref@@package" package and gives access to new commands:
2458 \csintro\kcref, \csintro\kCref, \csintro\kcpageref, \csintro\kCpageref, \csintro\knamecref, \csintro\knameCref,
2459 \csintro\knamerefs, and \csintro\knameCrefs\ which are respectively equivalent to \cs\cref, \cs\Cref, \cs\cpageref, \cs\Cpageref,
2460 \cs\namecref, and \cs\nameCref\ of the "cleveref@@package" package, but applied to the label corresponding to the "knowledge" (see the documentation of "cleveref@@package" for more details).
2461 These commands are variants of \cs\kl\ and hence are subject to the same syntax.
2462
2463 For instance,
2464 \begin{CODE}
2465 \kl{"}Anchor points\kl{"} have been described in~\cs\kCref\{anchor point\},\\
2466 Page \cs\kpageref\{anchor point\}.
2467 \end{CODE}\noindent
2468 would typeset as
2469 \begin{PDFoutput}[10cm]
2470 "Anchor points" have been introduced in~\kCref{anchor point}, Page \kpageref{anchor point}.
2471 \end{PDFoutput}
2472
2473 \subsection{Dealing with math}
2474 \label{subsection:math}
2475
2476 There are essentially two ways in which one would like to use "knowledge@@package" with mathematics:
2477 \begin{description}
2478 \item[Single introduction] Some mathematical objects are introduced once and for all in the paper. In this case, all the use of the object
2479 should point to the same introduction location. This way of doing is covered intensively in the
2480 \item[Variables] The more advanced case is when one wants to track variables. For instance, a macro variable~\cs\x\ could have a different meaning in two distinct theorems. This case is more similar to variables in a programming language, that have a scope.
2481 Here the situation is slightly more complicated since a variable could be introduced in a theorem, and then used many pages later in a proof section for instance. This is doable with the package, using scoping, but is not described yet in the documentation.
2482 \end{description}
2483
2484
2485
2486
2487 \subsubsection{Defining knowledge-aware macros}
2488 \label{subsubsection:knowledgenewcommands}
2489
2490 It is possible to use the \cs\kl\ command inside , and in math mode (however, the "quotation notation" should really be avoided).
2491 Nevertheless, this may cause problematic results in various situations. For this reason, specialized tools are offered.
2492
2493 In this first section, we describe the simplest way to define macros that are linked to "knowledge".
2494 This covers almost all situations, as long as one is not interested in having the knowledge dependant of the parameters of the macro.
2495 In the subsequent sections, some more explanations are given covering the case of parameters.
2496
2497
2498 \knowledgenewcommand\floor[1]{\cmdkl{\lfloor}#1\cmdkl{\rfloor}}
2499
2500 \paragraph*{The use through an example}\AP
2501 Let us define the $\intro*\floor{x}$ command representing the
2502 floor rounding of~$x$, and use it in $\floor{1.5}$. This is achieved by first defining a macro \cs\floor\ (for instance in the preamble):
2503 \begin{CODE}
2504 \cs\knowledgenewrobustcmd\cs\floor[1]\{\cs\cmdkl\{\cs\lfloor\}\#1\cs\cmdkl\{\cs\rfloor\}\}
2505 \end{CODE}\noindent
2506 and then use it in a natural way:
2507 \begin{CODE}
2508 \cs\AP\ Let us define the \$\cs\intro*\cs\floor\ x\$ command representing the floor rounding of \$x\$,
2509 and use it in \$\cs\floor\{1.5\}\$.
2510 \end{CODE}\noindent
2511 There, we used a special command, \cs\knowledgenewrobustcmd, which is similar to the \cs\newrobustcmd\footnote{It has the same syntax as \cs\newcommand\ and should always be used instead as far as a good reason for not to do it is given.}
2512 and at the same time introduces a "knowledge" for the macro name (defined using the directive "automatic in command").
2513 It sets the contexts such that \cs\cmdkl\ implements the code for using this "knowledge". It is somehow similar to:
2514 \begin{CODE}
2515 \cs\newrobustcmd\cs\floor[1]\{\cs\kl[\cs\floor]\{\cs\lfloor\}\#1\cs\kl[\cs\floor]\{\cs\rfloor\}\}\\
2516 \cs\knowledge\{\cs\floor\}\{"automatic in command"\}
2517 \end{CODE}\noindent
2518 but is shorter to write and also corrects some bugs of this direct implementation\footnote{For instance, with this wrong implementation,
2519 \smallcode{\cs\intro*\cs\floor\ x} would display in \cs\intro\ aspect the `\cs\lfloor'\ symbol but not the `\cs\rfloor' one.}.
2520
2521 \AP As explained above, the \cs\knowledge\ command is implicit when defining such macros. The "knowledge" name is the macro name itself, and the directive used is ""automatic in command"".
2522 Hence, you can modify the behavior by redefining the directive:
2523 \begin{quote}
2524 \cs\knowledgedirective*\{"automatic in command"\}\{\dots\}
2525 \end{quote}
2526
2527
2528 \paragraph{Defining new commands}
2529 We have used \cs\knowledgenewrobustcmd\ in the above example.
2530 In fact, several commands are available for defining such knowledge-enhanced macros.
2531 Each of them corresponds to a normal command (from \LaTeX, or "xparse@@package", or "mathcommand@@package"), prefixed with `\texttt{knowledge}' or `\texttt{Knowledge}'.
2532 The behavior of these commands is identical to the original ones, and furthemore activates the ability to use \cs\cmdkl.
2533 (Note that it is forbidden for your macro to absorb anything more than the parameters described during its definition.)
2534 \AP
2535 The commands
2536 \begin{quote}
2537 \csintro\knowledgenewrobustcmd, [
2538 \csintro\knowledgerenewcommand, and \\
2539 \csintro\knowledgenewcommand\footnote{These commands are here for completeness. You should always prefer \cs\knowledgenewrobustcmd\ instead, in particular to avoid problems in sectioning commands.}],
2540 \end{quote}
2541 correspond to \cs\newrobustcmd (from "etoolbox@@package") , \cs\newcommand, \cs\renewcommand respectively.
2542 \AP
2543 The commands
2544 \begin{quote}
2545 \csintro\KnowledgeNewDocumentCommand, \\
2546 \csintro\KnowledgeRenewDocumentCommand, \\
2547 \csintro\KnowledgeProvideDocumentCommand, and \\
2548 \csintro\KnowledgeDeclareDocumentCommand
2549 \end{quote}
2550 extend the corresponding commands from the "xparse@@package" package (it offers more complete possibilities to define the signature of macros, and do it in a cleaner and more systematic way).
2551
2552 \AP Finally, the commands of the "mathcommand@@package" package (see~\Cref{subsubsection:mathcommand})
2553 are also extended (provided it has been loaded before the package "knowledge@@package"), yielding:
2554 \begin{quote}
2555 \csintro\knowledgedeclarecommand, \\
2556 \csintro\knowledgenewmathcommand, \\
2557 \csintro\knowledgenewtextcommand, \\
2558 \csintro\knowledgerenewmathcommand, \\
2559 \csintro\knowledgerenewtextcommand, \\
2560 \csintro\knowledgedeclaremathcommand, \\
2561 \csintro\knowledgedeclaretextcommand, \\
2562 \csintro\KnowledgeNewDocumentMathCommand, \\
2563 \csintro\KnowledgeNewDocumentTextCommand,\\
2564 \csintro\KnowledgeRenewDocumentMathCommand, \\
2565 \csintro\KnowledgeRenewDocumentTextCommand,\\
2566 \csintro\KnowledgeProvideDocumentMathCommand, \\
2567 \csintro\KnowledgeProvideDocumentTextCommand,\\
2568 \csintro\KnowledgeDeclareDocumentMathCommand, \\
2569 \csintro\KnowledgeDeclareDocumentTextCommand,\\
2570 \csintro\knowledgenewcommandPIE, \\
2571 \csintro\knowledgerenewcommandPIE,\\
2572 \csintro\knowledgedeclarecommandPIE, \\
2573 \csintro\knowledgenewmathcommandPIE, \\
2574 \csintro\knowledgerenewmathcommandPIE, \\
2575 \csintro\knowledgedeclaremathcommandPIE, \\
2576 \csintro\KnowledgeNewDocumentCommandPIE, \\
2577 \csintro\KnowledgeRenewDocumentCommandPIE,\\
2578 \csintro\KnowledgeDeclareDocumentCommandPIE, \\
2579 \csintro\KnowledgeProvideDocumentCommandPIE,\\
2580 \csintro\KnowledgeNewDocumentMathCommandPIE, \\
2581 \csintro\KnowledgeRenewDocumentMathCommandPIE,\\
2582 \csintro\KnowledgeDeclareDocumentMathCommandPIE, and \\
2583 \csintro\KnowledgeProvideDocumentMathCommandPIE.
2584 \end{quote}
2585
2586 \subsubsection{The combination \cs\withkl/\cs\cmdkl}
2587 \label{subsubsection:withkl}
2588
2589 In fact, inside commands like~\cs\knowledgenewrobustcmd, the command~\cs\withkl\ is used.
2590 It has to be used in combination with \cs\cmdkl:
2591 \begin{center}
2592 \smallcode{\csintro\withkl\{\cs\kl-like command\}\{\dots\csintro\cmdkl\{A\}\dots\csreintro\cmdkl\{B\}\dots\}}
2593 \end{center}
2594 Inside the right argument of \cs\withkl, \cs\cmdkl\ stands for a shorthand for the \cs\kl-like command, with the following specificities:
2595 the "modifiers@@variant" used before the \cs\withkl\ are absorbed and reinjected for each use of~\cs\cmdkl. Furthermore, all the uses of \cs\cmdkl, but the first one, get to be preceded of the \csintro\rekl* "modifier@@variant", which transformes in particular \cs\intro\ into \cs\reintro. Hence,
2596 \smallcode{\cs\intro*\cs\withkl\{\cs\kl[example]\}\{\dots\cs\cmdkl\{A\}\dots\cs\cmdkl\{B\}\dots\}}
2597 gets to be evaluated as
2598 \smallcode{\dots\cs\intro[example]\{A\}\dots\cs\reintro[example]\{B\}\dots}
2599
2600 An example of use of this technique is if we want "knowledges" aware of the parameters of a macro.
2601 Imagine that you use the norms $1$ and $2$ of a function:
2602 \begin{CODE}
2603 \cs\newrobustcmd\cs\norm[2]\par
2604 ~~~~\{\cs\withkl\{\cs\kl[\cs\norm\{\#1\}]\}\{\cs\cmdkl\{\cs\|\}\#2\cs\cmdkl\{\cs\|\}\_\{\cs\cmdkl\{\#1\}\}\}\}\\
2605 \cs\knowledge\{\cs\norm\{1\}\}\{notion\}\\
2606 \cs\knowledge\{\cs\norm\{2\}\}\{notion\}
2607 \end{CODE}\noindent
2608 Now, the norm $1$ and the norm $2$ can be defined in different places since "knowledge" is specific to each case.
2609 \begin{CODE}
2610 \cs\AP\ The norm~\$1\$ of a function~\$f\$ is denoted \$\cs\intro*\cs\norm1f\$.\\
2611 "[...]"\\
2612 \cs\AP\ The norm~\$2\$ of a function~\$f\$ is denoted \$\cs\intro*\cs\norm2f\$.\\
2613 "[...]"\\
2614 Here, \$\cs\norm 1g\$ and \$\cs\norm2h\$ link to the proper place, while\\\$\cs\norm3g\$ is an undefined knowledge.
2615 \end{CODE}
2616
2617
2618 \subsubsection{Defining macros for math: the "mathcommand@@package" package}
2619 \label{subsubsection:mathcommand}
2620
2621 Defining macros is standard in \TeX, and it should be used systematically when writing scientific documents.
2622 This is particularly true when using the "knowledge@@package" package.
2623 The standard way in \LaTeX\ for defining macros is to use \cs\newcommand. However, the resulting macro, if it has
2624 no optional parameters, is then expandable, and it is better to avoid it using instead \cs\newrobustcmd\ from the "etoolbox@@package"
2625 package (it has the same syntax). Generally speaking, the "xparse@@package" package, which gives easier syntax for describing commands, possibly with more complex parameter templates, should be preferred.
2626
2627 Another package, "mathcommand@@package", has been designed to be used in conjunction with
2628 "knowledge@@package"\footnote{Note that all the commands for defining macros also exist in a "knowledge"-compatible form (see \Cref{subsubsection:knowledgenewcommands})}.
2629 We shall use it in the advanced examples below. It allows:
2630 \begin{itemize}
2631 \item to define/redefine commands to be used in math mode only. This allows for instance to use the macro \cs\c\ for producing as usual a cedilla in text mode, and at the same time some variable $\mathbf c$ in math mode. This is achieved using for instance:
2632 \smallcode{\cs\renewmathcommand\cs\c\{\cs\mathbf\{c\}\}}.
2633 \item When redefining a command, it automatically stores the original command \cs\macro\ as \cs\LaTeXmacro. So for instance, if one wants to introduce the constant~$\pi$ in a document and have it linked, one can use:
2634 \begin{CODE}
2635 \cs\renewmathcommand\cs\pi\{\cs\kl[\cs\pi]\{\cs\LaTeXpi\}\}\\
2636 \cs\knowledge\cs\pi\{notion\}\\
2637 "[...]"\\
2638 \cs\AP\ Let \$\cs{\intro*}\cs\pi=3.1415\$.\\
2639 "[...]"\\
2640 Now \$\cs\pi\$ points to the above sentence.
2641 \end{CODE}
2642 This code works because a different name \cs\LaTeXpi\ stores the original macro. Using~\cs\pi\ instead would yield an infinite loop.
2643 Even better is to use the knowledge-aware version:
2644 \begin{CODE}
2645 \cs\knowledgerenewmathcommand\cs\pi\{\cs\cmdkl\{\cs\LaTeXpi\}\}
2646 \end{CODE}
2647 \item The package also gives access to the exponents and indices as well as primes that follow a command (see the documentation).
2648 \item It also has some facilities for disabling \LaTeX\ commands and provide suggestions of replacement (useful for remembering the macros and working with colleagues).
2649 \item Finally, it offers some commodity for redefining many variables in one command.
2650 E.g. for defining \cs\calA, \cs\calB,\dots to be shortcuts for \smallcode{\cs\cal\{A\}}, \smallcode{\cs\cal\{B\}}, \dots:
2651 \begin{CODE}
2652 \cs\LoopCommands\{ABCDEFGHIJKLMNOPQRSTUVWXYZ\}[cal\#1]\par
2653 ~~~~\quad\{\cs\newmathcommand\#2\{\cs\cal\{\#1\}\}\}
2654 \end{CODE}
2655 \end{itemize}
2656
2657 \subsubsection{Mathematical objects that are singly introduced}
2658
2659 In this case, this is essentially as in text mode.
2660 Five points have to be kept in mind:
2661 \begin{itemize}
2662 \item Do not use the "quotation notation" in math mode and in macros. Indeed,
2663 some packages, like "tikzcd@@package" use the double-quote symbol in their
2664 (math) syntax. In this context, quotes have to be deactivated, and hence macros
2665 that would use the "quotation notation" would suddenly not have the expected result.
2666 \item Do not mix the "knowledge" concerning math commands and normal text. It is in practice
2667 difficult to maintain.
2668 \item Use the control sequence of the macro itself as the "knowledge" name.
2669 This does not cause problems and is easier to maintain. This is automatically done when
2670 commands such as \cs\knowledgenewrobustcmd\ are used.
2671 \item Use the \cs{\intro*} notation for introducing macros.
2672 \item The surrounding typography may be broken when using the command \cs{\kl}, or \cs\cmdkl\ (if someone knows how to solve that, please contact me). Commands such as \cs\mathrel\ should be used to recover it.
2673 \end{itemize}
2674 These five points are illustrated in the following code:
2675 \begin{CODE}
2676 \cs\knowledgenewrobustcmd\cs\comp\{\cs\mathrel\{\cs\cmdkl\{\cs\circ\}\}\}\\
2677 "[...]"\\
2678 \cs\AP\ Composition is denoted \$\cs{\intro*}\cs\comp\$.\\
2679 "[...]"\\
2680 Now, each use of \$\cs\comp\$ points to its introduction.
2681 \end{CODE}
2682
2683 Two variation may be comfortable to use.
2684
2685 \paragraph{Disabling commands}
2686 When writing a paper, in particular with coauthors, one may be tempted to not always use the macros designed for each case.
2687 For helping to remember the macro, one can use instead (using the "mathcommand@@package" package):
2688 \begin{CODE}
2689 \csintro\disablecommand\cs\circ\\
2690 \csintro\suggestcommand\cs\circ\{Use instead \cs\comp\ for function composition.\}\\
2691 \cs\knowledgenewrobustcmd\cs\comp\{\cs\cmdkl\{\cs\LaTeXcirc\}\}\\
2692 \end{CODE}
2693 \noindent The result is that if one uses \cs\circ\ in the code, an error will be issued, and \cs\comp\ will be suggested as a replacement.
2694 Note that more than one suggestions can be attached to the macro (if several macros use the symbol~\cs\comp\ with different meanings). Note also that in the definition of \cs\comp, \cs\LaTeXcirc\ is used instead of~\cs\circ. Indeed, \cs\circ\ has been deactivated,
2695 but~\cs\LaTeXcirc\ gives access to its original meaning.
2696
2697 \paragraph{Redefining the original \TeX\ macro}
2698 Another situation is that one would like to use the \cs\circ\ control sequence for accessing our function instead of \cs\comp\ (simply because this is more convenient and easy to remember, and we know in advance that no confusion may arise).
2699 In this case, the "mathcommand@@package" package can also be of some help:
2700 \begin{CODE}
2701 \cs\knowledgerenewmathcommand\cs\circ\{\cs\mathrel\{\cs\cmdkl\{\cs\LaTeXcirc\}\}\}\\
2702 "[...]"\\
2703 \cs\AP\ Let \$g\cs{\intro*}\cs\circ\ f\$ denote the composition of functions.\\
2704 "[...]"\\
2705 Now, each use of \$\cs\circ\$ points to its introduction.
2706 \end{CODE}
2707 \noindent
2708 The effect of \cs\knowledgerenewmathcommand\ is that it sets~\cs\LaTeXcirc\ to have the same effect as the original \cs\circ\ command,
2709 and then redefines~\cs\circ.
2710
2711 \subsubsection{Context dependent variables}
2712
2713 This section is not yet written.
2714
2715 \iffalse
2716 We enter now a more advanced situation. We want to track all the variables in a mathematic document...
2717 the first thing to do is to give access to the "knowledge@@package" package to the scope of the document.
2718 The easiest way to do that is to declare in the preamble what are the environments that we want to use.
2719 \begin{CODE}
2720 \cs\knowledgeconfigureenvironment\{theorem,lemma,proof\}\{\}\par\noindent
2721 \end{CODE}}
2722
2723
2724 The "knowledge@@package" package offers several tools for dealing with mathematics. It is mostly still experimental.
2725 The essential goal is to be able to track the identity variables and to point each of them to its introduction.
2726 For obtaining this, this requires:
2727 \begin{itemize}
2728 \item to use the \kl{scoping} since in mathematical proofs the same name can be used to represent many things depending on the context, and
2729 \item offer ways to easily define macros. One key issue that make this different than standard macro definition is that one is accustomed to use subscripts, supscripts, or primes, to separate different objects. However, it would be very inconvenient to separately define macros for each variant. Hence, is is ok to say that \verb|\rx,\ry,\rz| are variables denoting real numbers (typeset $x,y,z$), but is not ok to separately have to make precise that $x_1$, $x_{i+2}$ and so on in fact represent the same object. It is aso normal that $x$ and $x'$ are different objects, but it is not the case for $f$ and $f'$ if one uses the convention that second is the derivative of the first.
2730 \end{itemize}
2731 \fi
2732
2733
2734 \subsection{Predefined configuration}
2735
2736 \subsubsection{The "notion@@option" directive}
2737
2738 \AP The configuration option~\intro(option){notion} is activated using:
2739 \begin{center}
2740 \smallcode{\cs\knowledgeconfigure\{\kl(option){notion}\}}
2741 \end{center}\noindent
2742 \AP It automatically configures a \kl[\knowledge directives]{directive} \intro{notion}
2743 which is an \kl{autoref} configured to be displayed in a configurable way:
2744 \begin{itemize}
2745 \item In \kl{paper mode}, the \cs{\intro} commands (not in math mode) are emphasized, while the \cs{\kl} commands are displayed as normal. It has the aspect of a normal paper.
2746 \item In "electronic mode" and \kl{composition mode} (with the "xcolor@@package" package), notions are furthermore typeset in blue when introduced, and in dark blue when used. Without the \kl(package){xcolor} package, underlining draw the attention to the knowledges (not in math mode).
2747 \end{itemize}
2748 The behavior of the "notion" directive is to activate "autoref", and to configure the following two "styles":
2749 \begin{itemize}
2750 \itemAP the "style" ""notion@@style"" is used for normal use,
2751 \itemAP the "style" ""intro notion@@style"" is used for introduction.
2752 \end{itemize}
2753
2754 A typical document using notion could start by the following commands:
2755 \begin{CODE}
2756 \cs\documentclass\{article\}\\
2757 \cs\usepackage\{\kl(package){xcolor}\}\\
2758 \cs\usepackage\{\kl(package){hyperref}\}\\
2759 \cs\usepackage[\kl{electronic}]\{"knowledge@@package"\}\\
2760 \cs\knowledgeconfigure\{"notion@@option"\}\\
2761 "[...]"\\
2762 \cs\knowledge\{some text\}\{notion\}
2763 \end{CODE}\noindent
2764 Then the paper is displayed in a colorful way.
2765
2766
2767
2768 \subsection{Fixes}
2769 \label{subsection:fixes}
2770
2771 In this section, we present some fixes that have been added to help the user solve problems.
2772
2773 \paragraph{Hyperref and twocolumn} It happens that the "hyperref@@package" and two-column mode together may yield a fatal error. This happens when a link spans across the boundary between two pages. This is an issue which is not related to the "knowledge@@package" package, but becomes severely more annoying when more links have to be used.
2774 A \emph{workaround} can be tried by using using
2775 \begin{center}
2776 \smallcode{\cs\knowledgeconfigure\{""fix hyperref twocolumn""\}}.
2777 \end{center}
2778 I do not know to which extend it is compatible with various classes...
2779 \newpage
2780
2781 \section{Some questions and some answers}
2782 \label{section:faq}
2783
2784
2785
2786 \subsection{How to compile?}
2787
2788 As usual with \LaTeX, a certain number of compilation phases are necessary for reaching a document in final form. The problematic point is of course the use of labels, and in particular the \cs{\intro} command. When it is used, and all the \cs{\knowledge} commands are in the preamble, then two phases are necessary. When \cs{\knowledge} commands are used in the body of the documents, then one extra phase is required, meaning three with \kl{autoref} definitions. This is also the case when "scoping" is used.
2789
2790 \subsection{Problem with \cs{\item} parameters}
2791
2792 \paragraph{The use of~\cs{\AP} inside the optional parameter of \cs{\item} does not work.} Do not use \cs{\AP} inside the optional argument of \cs{\item}, and rather use the command \cs{\itemAP}.
2793
2794 \paragraph{Argument of \cs{\kl} has an extra `\texttt\}'.} This is a problem of using optional parameters inside optional parameters such as in \smallcode{\cs\item[\cs\kl[test]\{Test\}]}. You can surround the content of the optional parameter by two level of curly braces as in \smallcode{\cs\item[\{\{\cs\kl[test]\{Test\}\}\}]}.
2795 The notation \kl{"..."} does not have this issue.
2796
2797
2798
2799
2800 \subsection{Knowledges and moving arguments (table of contents, \dots).}
2801
2802
2803
2804 \paragraph{The use of \cs{\kl} does not work in (e.g.) the table of content.} When the \kl{knowledge name} contains expandable macros, or accentuated letters, then these are not copied in the table of content as the exact same text, but are expanded/translated. Thus, when the table of content is displayed, the \cs{\kl} command complains of not knowing the \kl{knowledge}. For instance\footnote{with \texttt{\cs\usepackage[utf8]\{inputenc\}} and, for instance \texttt{\cs\usepackage[T1]\{fontenc\}} for the accents.}:
2805 \begin{center}
2806 \begin{CODE}[11cm]
2807 \cs\newcommand\robustdisplay\Ltwo\{\cs\ensuremath\{L\^{}2\}\}\\
2808 \cs\knowledge\{\robustdisplay\Ltwo-space\}[\robustdisplay\Ltwo-spaces]\{autoref\}\\
2809 \cs\knowledge\{\'etale topology\}[\'Etale topology]\par
2810 ~~~~~~~\{\kl{url=}\{https://en.wikipedia.org/wiki/\'Etale\_topology\}\}\\
2811 {"[...]"}\\
2812 \cs\begin\{document\}\\
2813 \cs\tableofcontents\\
2814 \cs\section\{On \cs\kl\{\robustdisplay\Ltwo-spaces\}\\
2815 {"[...]"}\\
2816 \cs\section\{On the \cs\kl\{\'etale topology\}\}\\
2817 {"[...]"}\\
2818 \cs\end\{document\}
2819 \end{CODE}\end{center}\noindent
2820 will result in that both \kl{knowledges} are considered unknown in the table of contents.
2821 For the first one, this is due to the expansion of~\cs\Ltwo. For the second, this is due to an implicit translation of the accentuated letter into an internal sequence of commands (for instance `\'e' is translated into the internal sequence `\verb|\IeC {\'e}|'). Some solutions are as follows:
2822 \begin{itemize}
2823 \item Make the macros non-expandable, for instance using \cs{\newrobustcmd} (of the \kl(package){etoolbox} package) or \cs{\NewDocumentCommand} (of the \kl(package){xparse} package, with a different handling of arguments) instead of \cs{\newcommand}. Hence:
2824 \begin{CODE}
2825 \cs\newrobustcmd\robustdisplay\Ltwo\{\cs\ensuremath\{L\^{}2\}\}
2826 \end{CODE}\noindent
2827 solves the first problem.
2828 \item Using an equivalent text that does not have the problem:
2829 \begin{CODE}
2830 \cs\knowledge\{$\backslash$'etale topology\}\{\kl{link=}\'etale topology\}\\
2831 {"[...]"}\\
2832 \cs\section\{On the \cs\kl\{$\backslash$'etale topology\}\}
2833 \end{CODE}
2834 \item Both problems can be solved using synonyms/links that have no problem. For instance:
2835 \begin{CODE}
2836 \cs\knowledge\{Ltwo-space\}\{\kl{link=}\robustdisplay\Ltwo-space\}\\
2837 \cs\knowledge\{etale topology\}\{\kl{link=}\'etale topology\}\\
2838 {"[...]"}\\
2839 \cs\section\{On \cs\kl[Ltwo-space]\{\robustdisplay\Ltwo-spaces\}\}\\
2840 \cs\section\{On the \cs\kl[etale topology]\{étale topology\}\}
2841 \end{CODE}
2842 \item Other solutions? None so far. I am trying to systematize the treatment of these problems.
2843 \end{itemize}
2844
2845
2846 \paragraph{Using \cs{\intro} in a section title causes introducing the knowledge twice.}
2847 Do not use \cs{\intro} in titles, but rather \cs{\reintro}. If you want the section to be the target of the \kl{knowledge}, then put after the section a \cs{\pantomintro} command.
2848 \begin{center}
2849 \begin{tabular}{ccc}
2850 %\hline
2851 \begin{CODE}[5.5cm]
2852 \cs\section\{On \cs\intro\{topology\}\}\\
2853 \end{CODE}&&
2854 \begin{CODE}[5.9cm]
2855 \cs\section\{On \cs{\reintro}\{topology\}\}\\
2856 \cs{\phantomintro}\{topology\}
2857 \end{CODE}\\
2858 \textit{Problematic code}&&
2859 \textit{A solution}
2860 \end{tabular}
2861 \end{center}
2862
2863 \subsection{Problems with "tikzcd@@package" and other issues with the "quotation notation"}
2864 \label{section:tikzcd}
2865
2866 The package "tikzcd@@package" uses (heavily) the quotes. Thus, it conflicts with the "quotation notation".
2867 Some other packages may do the same. For solving this issue, the only things to do are:
2868 \begin{itemize}
2869 \item be sure to load these packages before "knowledge@@package", or at least be sure that the "quotation notation" is not
2870 active when you do so, and
2871 \item to temporarily deactivate the "quotation notation" when in a context where the package may use the quotes.
2872 \end{itemize}
2873
2874 This can be done either explicitly using before each figure:
2875 \begin{CODE}[8.5cm]
2876 \cs\knowledgeconfigure\{"quotation@@option"=false\}
2877 \end{CODE}
2878 \noindent
2879 and after the figure:
2880 \begin{CODE}[7cm]
2881 \cs\knowledgeconfigure\{"quotation@@option"\}
2882 \end{CODE}
2883 Another possibility is to force some environment to deactivate systematically the "quotation notation" when used. For instance
2884 \begin{CODE}[10cm]
2885 \cs\knowledgeconfigure\{"protect quotation="\{"tikzcd@@env"\}\}
2886 \end{CODE}\noindent
2887 will deactivate the "quotation notation" in all the "tikzcd@@env" environments.
2888
2889 \subsection{Problems with \kl(package){amsmath}}
2890 \label{section:amsmath questions}
2891
2892 \paragraph{The \cs{\intro} command does not work in \kl{align*} or similar environments}
2893 It happens that in stared environment (i.e., unnumbered), the package \kl(package){amsmath}
2894 deactivates the labels. As a consequence the command \cs{\intro}, which internally uses {\cs\label} (at least so far), does not work. For the moment, there is no real solution, but a workaround which consists in introducing the \kl{knowledge} before
2895 the incriminated environment using \cs\phantomsection, and then use \cs{\reintro} inside the environment. Imagine for instance a command
2896 \texttt{\robustdisplay\SomeCommand}, that inside uses \texttt{\cs\kl[\robustdisplay{\Somecommand}]}, then:
2897 \begin{center}
2898 \begin{tabular}{ccc}
2899 does not work&&works\\
2900 \begin{CODE}[5cm]
2901 \cs\begin\{\kl{align*}\}\\
2902 \cs{\intro*}\texttt{\robustdisplay{\SomeCommand}}\\
2903 \cs\end\{\kl{align*}\}\\
2904 \end{CODE}
2905 &&
2906 \begin{CODE}[5cm]
2907 \cs\phantomintro\texttt{\robustdisplay{\SomeCommand}}\\
2908 \cs\begin\{\kl{align*}\}\\
2909 \cs\reintro*\texttt{\robustdisplay{\SomeCommand}}\\
2910 \cs\end\{\kl{align*}\}
2911 \end{CODE}
2912 \end{tabular}
2913 \end{center}
2914
2915 \subsection{Hyperref complains}
2916 \paragraph{A fatal error occurs in twocolumn mode.} A workaround is to use
2917 \smallcode{\cs\knowledgeconfigure\{\kl{fix hyperref twocolumn}\}}.
2918
2919 \subsection{Name clash (eg with the "complexity@@package" package)}
2920
2921 It may happen that an already defined command is redefined by the "knowledge@@package" package.
2922 This happens in particular wen used in combination with the "complexity@@package" package: both packages try to define the command \cs\AP. For "complexity@@package", this denotes a complexity class, and for "knowledge@@package", it is an "anchor point".
2923 The problem has to be resolved by hand. The two following solutions are quick hacks:
2924 \begin{center}
2925 \begin{tabular}{ccc}
2926 \begin{CODE}[5.2cm]
2927 \cs\usepackage\{\kl(package){complexity}\}\\
2928 \cs\let\cs\compAP\robustdisplay\AP\\
2929 \cs\let\robustdisplay\AP\cs\undefined\\
2930 \cs\usepackage"[...]"\{"knowledge@@package"\}
2931 \end{CODE}
2932 &&
2933 \begin{CODE}[5.2cm]
2934 \cs\usepackage"[...]"\{"knowledge@@package"\}\\
2935 \cs\let\cs\kAP\robustdisplay\AP\\
2936 \cs\let\robustdisplay\AP\cs\undefined\\
2937 \cs\usepackage\{\kl(package){complexity}\}
2938 \end{CODE}\\
2939 for using \texttt{\robustdisplay\AP}from "knowledge@@package",
2940 && for using \texttt{\robustdisplay\AP}from "complexity@@package",\\
2941 and \cs\compAP\ for "complexity@@package",
2942 && and \cs\kAP\ for "knowledge@@package".
2943 \end{tabular}
2944 \end{center}
2945
2946 \subsection{Incorrect display}
2947
2948 \subsubsection{Incorrect breaking at the end of lines (in "arXiv" for instance)}
2949
2950 It may happen that some hyperlinks generated by "knowledge@@package" are not broken properly
2951 at the end of lines. This is an issue with the \kl(package){hyperref} package. This happens in particular for files compiled by the "arXiv" system while the file on the local computer was not having any problem. A workaround is to use the \kl{breaklinks} option of \kl(package){hyperref}. If you need this for "arXiv", then you also have to force the use of \cs\pdflatex\ (because the \kl{breaklinks} option does not work if compiled via the ancestral sequence TEX$\rightarrow$DVI$\rightarrow$PS$\rightarrow$PDF). This can be obtained by adding \smallcode{\cs\pdfoutput=1} within the five first lines of the preamble.
2952
2953 The preamble thus looks like:
2954 \begin{CODE}[9cm]
2955 \cs\documentclass\{"[...]"\}\par\noindent
2956 \cs\pdfoutput=1\par\noindent
2957 "[...]"\par\noindent
2958 \cs\usepackage[\kl{breaklinks}]\{\kl(package){hyperref}\}\par\noindent
2959 "[...]"\par\noindent
2960 \cs\usepackage\{\kl(package){knowledge}\}\par\noindent
2961 "[...]"\par\noindent
2962 \end{CODE}
2963
2964 \subsection{Display errors in pdf output, in particular "arXiv"}
2965 Again, try in the preamble:
2966 \begin{CODE}[9cm]
2967 \cs\pdfoutput=1
2968 \end{CODE}
2969
2970 \subsubsection{Red boxes around links}
2971
2972 This is an annoying feature of the "hyperref@@package" package to surround all links by red boxes (that may appear or not depending on the viewer). This is very heavy in document with many links. By default, this is deactivated when using the package "knowledge@@package",
2973 unless the "no patch" option is used when loading the package. When the "no patch" option is used, the same effect can nevertheless be obtained, eg, using \smallcode{\cs\hypersetup\{hidelinks\}}.
2974
2975 \subsubsection{Incorrect color for links in "paper mode" (e.g. red in with \kl(package){acmart})}
2976
2977 Some classes, like \kl(package){acmart}, change the default color of the hyperlinks of \kl(package){hyperref}. Since "knowledge@@package" does not apply any color to the links in "paper mode", this unexpected color appears. The black color of the "paper mode" can be forced by using:
2978 \begin{CODE}
2979 \cs\IfKnowledgePaperMode\\
2980 \cs\knowledgestyle\{"kl@@style"\}\{"color="black\}\\
2981 \cs\knowledgestyle\{"notion@@style"\}\{"color="black\}\\
2982 \cs{\ fi}
2983 \end{CODE}
2984
2985 \subsubsection{Unexepected color in margin paragraph}
2986 This is a problem of the combination of the package "xcolor@@package" with \cs\marginpar: when a colored text gets to be broken into separated lines and the \cs\marginpar\ be inserted at this place, the colors leaks in to the margin text.
2987 It is independent of "knowledge@@package", but is more likely to occur when colors are often used.
2988 A correction is to force the use of the color black whenever inside a \cs{\marginpar}. For instance:
2989 \begin{CODE}
2990 \cs\let\cs\LaTeXmarginpar\cs\marginpar\\
2991 \cs\def\cs\marginpar\#1\{\cs\LaTeXmarginpar\{\cs\textcolor\{black\}\{\#1\}\}\}
2992 \end{CODE}
2993
2994 \subsection{Problems with scope}
2995
2996 \subsubsection{Problems in combination with \cs{\bibitem} and the environment "thebibliography@@env"}
2997
2998
2999 The "scope option" of the package triggers some analysis of the code, and restrains the structure of the code (in particular, this is because "scopes" have to be nested, and thus some not so well nested parts of \LaTeX{} yield errors). In particular, the "scope option" does not allow to have a \cs{\section} command inside a list.
3000 However, this is what does the environment "thebibliography@@env", yielding a scoping error.
3001
3002 A simple hack to treat this situation:
3003 \begin{CODE}[6cm]
3004 \cs\let\cs\section\cs\SUPERsection\\
3005 \cs\begin\{"thebibliography@@env"\}\\
3006 \cs\bibitem\dots\\
3007 {}"[...]"\\
3008 \cs\end\{"thebibliography@@env"\}\\
3009 \cs\let\cs\section\cs\NEWsection
3010 \end{CODE}
3011 The result is to revert to the original version of the macro \smallcode{\cs\section}, which does not make any structural test, and then reactivate the modified version of the command.
3012
3013 Another solution is to reconfigure the environment "thebibliography@@env" using in the preamble:
3014 \begin{CODE}
3015 \cs\ScopeConfigure\{"thebibliography@@env"\}\par
3016 \hspace{3cm}\{push code=\cs\let\cs\section\cs\SUPERsection,\par
3017 \hspace{3cm}~pop code=\cs\let\cs\section\cs\NEWsection\}
3018 \end{CODE}
3019
3020
3021 \subsection{Editors}
3022
3023 \newenvironment{pquote}{\begin{quote}}{\end{quote}}
3024 \knowledgeconfigure{protect quotation=pquote}
3025
3026 \subsubsection{"Emacs" editor and \kl[quotation notation]{quotes}}
3027 The "AucTex" mode in "Emacs" binds the quote symbol to other characters, cycling
3028 through \verb|``|, \quotesymbol, and \quotesymbol\quotesymbol. This is not
3029 convenient when using the "knowledge@@package" package.
3030
3031 This behavior can be deactivated temporarily using:
3032 \begin{pquote}
3033 %\texttt{M-x local-unset-key $\backslash$\quotesymbol.}
3034 \texttt{M-x local-unset-key RET \quotesymbol{} RET}
3035 \end{pquote}\noindent
3036 or definitively using:
3037 \begin{pquote}
3038 \texttt{(defun my-hook () (local-unset-key \quotesymbol$\backslash$\quotesymbol\quotesymbol))\\
3039 (add-hook 'LaTeX-mode-hook 'my-hook)}
3040 \end{pquote}
3041 % source: Sylvain Perifel, and:
3042 %(source : https://stackoverflow.com/questions/24835536/insert-regular-double-quotes-in-latex-mode-with-auctex)
3043
3044 Alternatively, this can be changed so as to cycle through \quotesymbol,
3045 \verb|``|, and \quotesymbol\quotesymbol, which is slightly more convenient than
3046 the default. This is achieved by customizing \texttt{TeX-quote-after-quote}:
3047 \begin{pquote}
3048 \texttt{M-x customize-set-variable RET TeX-quote-after-quote RET y}
3049 \end{pquote}
3050
3051 If you also use "smartparens", there are some known interaction problems with "AucTex" (see \url{https://github.com/Fuco1/smartparens/issues/1100}). A reported solution is to execute:
3052 \knowledgeconfigure{quotation=false}%
3053 \begin{verbatim}
3054 (setq TeX-quote-after-quote t)
3055 (sp-with-modes '(tex-mode plain-tex-mode latex-mode LaTeX-mode)
3056 (sp-local-pair "`" nil :actions nil)
3057 (sp-local-pair "\"" nil :actions nil)
3058 (sp-local-pair "``" nil :actions nil)
3059 (sp-local-pair "``" "''" :trigger nil :actions nil)
3060 )
3061 \end{verbatim}
3062 \knowledgeconfigure{quotation=true}%
3063
3064 \subsection{Others}
3065 If other kind of problems occur, report them to \texttt{[email protected]}.
3066 You can also do it if you found a solution. It will be added.
3067
3068
3069 \newpage
3070
3071 \section{Resources}
3072 \label{section:resources}
3073
3074 \subsection{List of commands}
3075 \begin{compactdesc}
3076 \item[\cs\AP] introduces an "anchor point".
3077 \item[\cs\intro] searches for a \kl{knowledge} and put an anchor to it (to be used with the \kl{autoref} directive).
3078 \item[\cs\kcref, \cs\kCref, \cs\kcpageref, \cs\kCpageref, \cs\knamecref, \cs\knameCref, \cs\knamecref] and \cs\knameCref\ display some information concerning the place of introduction of a "knowledge" as the \cs\cref, \cs\Cref, \cs\cpageref, \cs\Cpageref, \cs\namecref, \cs\nameCref, \cs\namecref\ and \cs\nameCref\ commands of the \kl(package){cleveref} package.
3079 \item[\cs\kl] searches for a \kl{knowledge} and displays it accordingly.
3080 \item[\cs\knowledge] defines new \kl{knowledges}.
3081 \item[\cs\knowledgeconfigure] configures the package.
3082 \item[\cs\knowledgedirective] defines a new \kl[\knowledge directives]{directive}.
3083 \item[\cs\knowledgedefault] declares the default \kl[\knowledge directives]{directives} to be automatically used in \cs{\knowledge} commands.
3084 \item[\cs\knowledgeimport] gives access to \kl{knowledges} existing in other scopes.
3085 \item[\cs\knowledgenewvariant] defines a new "variant of \cs{\kl}".
3086 \item[\cs\knowledgesetvariant] configures a "variant of \cs{\kl}".
3087 \item[\cs\knowledgestyle] defines a new \kl{style}.
3088 \item[\cs\knowledgevariantmodifier] declares a meaning of \cs{*} in "variants of \cs{\kl}".
3089 \item[\cs\kpageref] displays the page number of a reference,
3090 \item[\cs\kref] displays the number associated to a reference introduction.
3091 \item[\cs\nointro] declares that the knowledge will never be introduced (does not work properly yet).
3092 \item[\cs\phantomintro] performs an invisible \cs\intro.
3093 \item[\cs\reintro] uses the \kl{display style} of \cs{\intro} without introducing an anchor.
3094 \end{compactdesc}
3095
3096 \subsection{List of environments}
3097 \begin{compactdesc}
3098 \item[\kl(env){export}] (\kl{not implemented}) requires exportation of the content.
3099 \item[\kl(env){import}] (\kl{not implemented}) declares external resources.
3100 \item[\kl(env){scope}] Defines a \kl{scope} in which \kl{knowledges} are internal.
3101 \end{compactdesc}
3102
3103 \subsection{List of \kl{directives} (to use with \cs{\knowledge})}
3104 \label{subsection:directive list}
3105
3106
3107 \begin{compactdesc}
3108 \item["autoref"] Activates the \cs{\intro} feature.
3109 \item["autoref link"] activates an hyperlink to the target.
3110 \item["autoref target"] puts a target for a hyperlink.
3111 \item[\kl{autorefhere}] creates an \kl{anchor point} that points to the \cs{\knowledge} command (Requires the \kl{hyperref option}).
3112 \item[\kl{boldface}] Displays the knowledge in boldface.
3113 \item[\kl{color=}] Displays the \kl{knowledge} is the given color (resquires \kl(option){xcolor}).
3114 \item[\kl{colorbox=}] Displays the \kl{knowledge} in a box of the given color (requires \kl(option){xcolor}).
3115 \item[\kl{cyclic color}] Displays in a color among a cyclic list (requires \kl(option){xcolor}).
3116 \item[\kl{detokenize}] Avoids evaluation of the text.
3117 \item[\kl{emphasize}] Emphasizes the displayed output.
3118 \item[\kl{ensuretext}] Guarantees that the output will be displayed in text mode.
3119 \item[\kl{ensuremath}] Guarantees that the output will be displayed in math mode.
3120 \item[\kl{export=}] (\kl{not implemented})
3121 \item[\kl{invisible=}] no display
3122 \item[\kl{italic=}] displays in italic
3123 \item[\kl{fbox}] Surround the text with a box.
3124 \item[\kl{md}] Removes boldface typesetting.
3125 %\item[\kl{import=}] (\kl{not implemented})
3126 \item[\kl{index=}] Chooses the text to be displayed in the \kl{index=}.
3127 \item[\kl{index key=}] the key used to choose the place in the \kl{index}.
3128 \item[\kl{index name=}] the name of the \kl{index} (requires "imakeidx@@option").
3129 \item[\kl{index style=}] the \kl{style} to be used to display in the \kl{index}.
3130 \item[\kl{index parent key=}] the parent key in the \kl{index}.
3131 \item[\kl{intro style=}] Chooses the typesetting in case of an intro.
3132 \item[\kl{italic}] Typesets the output in italic.
3133 \item[\kl{link=}] Follow with the search the linked knowledge.
3134 \item[\kl{link scope=}] Follow the search in the corresponding scope, using the same key, or the one provided by \kl{link=}
3135 if present.
3136 \item[\kl{lowercase}] Put all letters of the output in lowercase.
3137 \item[\kl{mathord}, \kl{mathop}, \kl{mathbin}, \kl{mathrel}, \kl{mathopen}, \kl{mathclose}, \kl{mathpunct}] Selects a spacing behaviour in math mode.
3138 \item[\kl{no index}] avoids the indexing of the term.
3139 \item[\kl{notion}] automatic configuration for displaying and autoreferencing.
3140 \item[\kl{protect link}] Disables the hyperlinks inside the link.
3141 \item[\kl{ref=}] Links to a label inside the document.
3142 \item[\kl{scope=}] Choose the \kl{scope} of the definition.
3143 \item[\kl{smallcaps}] Forces the use of small capitals.
3144 \item[\kl{style=}] Links to a style.
3145 \item[\kl{synonym}] Is a synonym of the lastly defined \kl{knowledge}.
3146 \item[\kl{text=}] Changes the output text.
3147 \item[\kl{remove space}] removes the spaces from the input
3148 \item[\kl{typewriter}] Typeset in as with \cs{\texttt}.
3149 \item[\kl{underline}] Underlines the text.
3150 \item[\kl{up}] Removes italic typesetting.
3151 \item[\kl{uppercase}] Put all letters of the output in uppercase.
3152 \item[\kl{url=}] An url to point to (uses the "hyperref@@package").
3153 \item[\kl{wrap=}] A macro used to process the displayed text.
3154 \end{compactdesc}
3155
3156 \subsection{List of \kl{configuration directives}}
3157 \label{subsection:configuration directive list}
3158 The following directives can be used as options when loading the package, or later using \cs{\knowledgeconfigure}.
3159
3160 \begin{compactdesc}
3161 \item["anchor point color="color] changes the color of "anchor point",
3162 \item["anchor point shape="shape] changes the shape of "anchor points", in which shape can be \texttt{tiny corner}, \texttt{small corner}, \texttt{corner}, \texttt{large corner},
3163 \texttt{tiny cross}, \texttt{small cross}, \texttt{cross}, \texttt{large cross}, or some code to be execute in the "picture@@env" environment,
3164 \item["anchor point shift="\{$x$,$y$\}] shifts the "anchor point" (in \texttt{em} unit),
3165 \item["diagnose bar="\textmd{\{true,false\}}] activates the \kl{`\vbar'-notation} in the "diagnose file" (default is false)
3166 \item["composition"] switches to "composition mode",
3167 \item["cyclic colors=@@option"] fixes the cyclic list of colors used by the "directive" "cyclic color".
3168 \item["diagnose line="\textmd{\{true,false\}}] activates or deactivates the line numbering in the "diagnose file".
3169 \item["electronic"] switches to "electronic mode".
3170 \item[\kl{fix hyperref twocolumn}] fixes a known problem between "hyperref@@package"
3171 and the two column mode.
3172 \item[\kl{hyperlinks=}\textmd{\{true,false\}}] activates or deactivates the hyperlinks.
3173 \item[{{\kl{no patch}}}] deactivates the default patches made to other packages.
3174 \item[{{\kl(option){notion}}}] activates the "notion" directive.
3175 \item["paper"] switches to "paper mode".
3176 \itemAP[\kl{label scope=}\textmd{\{true,false\}}] enables or disables the redefined \cs{\label} command, which helps automatically define scopes (default is~\textmd{true}).
3177 \item[\kl{protect link co} and \kl{unprotect link co}] starts and ends respectively a zone in which the "knowledge@@package" package does not create hyperlinks.
3178 \item[\kl{protect quotation=}\textmd{\{environment list\}}] declares a list of environment in which the "quotation notation" should be deactivated.
3179 \item[{{\kl(option)[quotation]{quotation=}\textmd{\{true,false\}}}}] activates or deactivates the "quotation notation".
3180 \item["silent"] is a Boolean option which, when activated, switches off all warnings during the compilation, but the recap ones at the end.
3181 \item["strict"] is a Boolean which, when true, makes the compilation more restrictive by turning some of the warnings into errors (in particular in case of redefinition of knowledges).
3182 \item[\kl{visible anchor points=}\textmd{\{true,false\}}] makes the \kl{anchor points} either visible or invisible.
3183 \end{compactdesc}
3184 \newpage
3185
3186
3187
3188
3189
3190
3191 \subsection*{List of default \kl{styles}}
3192 \begin{compactdesc}
3193 \itemAP[\kl(style){intro}]
3194 \itemAP[\kl(style){kl unknown}, \kl(style){kl unknown cont}]
3195 \itemAP[\kl(style){intro unknown}, \kl(style){intro unknown cont}]
3196 \itemAP[\kl(style){notion}] (if "notion" is activated)
3197 \itemAP[\kl(style){intro notion}] (if "notion" is activated)
3198 \end{compactdesc}
3199
3200
3201
3202
3203 \producecode
3204 \end{document}