Debian Codegraph @

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

raw
1 \documentclass{article}
2 \usepackage[utf8]{inputenc}
3 \usepackage[T1]{fontenc}
4 % If the output is a PDF (avoids some display problems, in particular in arXiv).
5 \pdfoutput = 1
6
7 % This is the file
8 %
9 % knowledge-example.tex
10 %
11 % and is part of the LaTeX package _knowledge_.
12 % It can be used as a starting point for creating a document using the _knowledge_ package.
13 %
14 % The documentation of the _knowledge_ package can be found:
15 % - in your tex distribution, using the command
16 % texdoc knowledge
17 % - or at the address
18 %. https://ctan.org/pkg/knowledge
19 %
20 %
21 % Loading other packages before knowledge activates features.
22 % The most common use of knowledge makes use of hyperref and xcolor, and here also imakeidx:
23 \usepackage{imakeidx} % for creating an index
24 \makeindex
25 \usepackage[breaklinks,hidelinks]{hyperref}
26 \usepackage{xcolor}
27 %
28 % The package 'knowledge' has now to be loaded.
29 % The options 'paper', 'electronic' or 'composition' (by default) activate the different rendering styles:
30 % - 'paper' produce a paper to be printed: text in black and white
31 % - 'electronic' highlights links using colors: for being read on an electronic device
32 % - 'composition' (or default) highlights missing knowledges as
33 % provides other pieces of information. It should always
34 % be used but when the paper is ready.
35 %
36 \usepackage{knowledge} % default
37 %\usepackage[scope,electronic]{knowledge} % final version to be read electronically
38 %\usepackage[scope,paper]{knowledge} % final version in black and white for printing
39 %
40
41 %
42 % The 'notion' configuration is commonly used for scientific papers. Here the default
43 % base color for intro is blue, and a darkened version of is used for uses.
44 %
45 \KnowledgeConfigureNotion[blue]{notion}
46 % The styles can be further changed by redefining the related styles, eg:
47 % \knowledgestyle*{intro notion}{underline}
48 % \knowledgestyle*{notion}{}
49 %
50
51 %
52 % The 'quotation' configuration is commonly used and triggers the "..." notation.
53 \knowledgeconfigure{quotation}
54 %
55 %
56 % It is convenient now to provide a list of \knowledge command in the preamble
57 % or even better in an external file with ending with ".kl", using eg:
58 %. \input{knowledge-example.kl}
59 %
60 % The |-notation for defining knowledge looks as follows:
61 %
62 % \knowledge{directives}
63 % | main knowledge [@scope]
64 % | synonym_1 [@scope1]
65 % | synonym_2 [@scope2]
66 % | ...
67 %
68 % Note: Consider using "knowledge-clustering" (https://github.com/remimorvan/Knowledge-Clustering)
69 % for automating the process of writing the \knowledge commands.
70 %
71
72 % Here, we use the directive "notion" defined above, as well as index.
73 \knowledge{notion, index={anchor point}}
74 | anchor point
75 | anchor points
76 | Anchor points
77 \knowledge{notion, index={diagnose file}}
78 | diagnose file
79 \knowledge{notion, index={paper}, index parent key={mode}}
80 | paper mode
81 | paper@mode
82 \knowledge{notion, index={electronic}, index parent key={mode}}
83 | electronic mode
84 | electronic@mode
85 \knowledge{notion, index={composition}, index parent key={mode}}
86 | composition mode
87 | composition@mode
88 \knowledge{notion, index=knowledge}
89 | knowledge
90 | knowledges
91 | Knowledges
92 \knowledge{notion,index={directive}}
93 | directive
94 | directives
95 | Directives
96
97
98 %
99 % Let us use another display style for packages that use url links to elsewhere in the web.
100 \knowledgedirective{package}{url = {#1}, typewriter, md, color=teal}
101 %
102 \knowledge{package={https://ctan.org/pkg/knowledge}}
103 | knowledge package
104 | knowledge@package
105 \knowledge{package={https://github.com/remimorvan/Knowledge-Clustering}}
106 | knowledge-clustering
107 \knowledge{package={https://ctan.org/pkg/makeidx}}
108 | makeidx@package
109 \knowledge{package={https://ctan.org/pkg/imakeidx}}
110 | imakeidx@package
111 \knowledge{package={https://ctan.org/pkg/xcolor}}
112 | xcolor@package
113 \knowledge{package={https://en.wikipedia.org/wiki/PdfTeX}}
114 | pdflatex@example
115
116 %
117 \knowledge{url={https://fr.wikipedia.org/wiki/LaTeX},
118 text=\LaTeX, % the text is replaced when used
119 index=\LaTeX, % the aspect in the index
120 index key=latex % where it appears in the index
121 }
122 | LaTeX
123 | latex
124 | LATEX
125 | Latex
126 % Configurations can also be made contextual. For instance, the
127 % following knowledge is only accessible directly in the introduction.
128 % It can nevertheless be used from elsewhere using "pdflatex@@section:introduction",
129
130 % or \kl(section:introduction){pdflatex}. See 'scoping' in the documetation for more details.
131
132
133
134
135 % We now start a document as usual.
136 \title{Mini example for the \texttt{knowledge} package}
137 \date{}
138
139
140
141 \begin{document}
142 \maketitle
143 \begin{abstract}
144 \AP This document provides an elementary example of use of the "knowledge package" for "latex" and can be used as a starting point for creating one's own document.
145 \end{abstract}
146
147 \section{Introduction}
148 \label{section:introduction}
149
150 The package ""knowledge@@package"" is a package for "latex" that helps associating information to terms. This can be used for:
151 \begin{itemize}
152 \item managing external urls, for instance separating the file containing the addresses from their use,
153 \item managing internal references's such as linking every use of a concept to the place of its introduction (in particular avoiding the use of labels),
154 \item managing one of more indexes in a centralized way,
155 \item replacing some macros for configuring the display.
156 \end{itemize}
157 Primarily, the goal of the "knowledge@@package" is for the production of scientific documents (the longer, the more interesting, such as a thesis or a book) in order to improve their readability on electronic devices. Ultimately, the goal is to produce documents that are more semantic-aware. Some capabilities (link handling the index) are not related to this purpose in particular.
158
159 \section{Example running}
160 \label{section:example}
161 Try compiling this document (two compilation phases to have proper links) using "pdflatex@@example", and see how some notions are hyperlinked to their introduction point (some viewers make it more obvious than others by displaying a preview of the target of a link inside a document; since there is only one page in this example, this may be worth zooming in this case).
162 \AP When the "paper mode" is not active, links are clearly identified in blue. By default, the document is compiled in ""composition mode"".
163 Try compiling it in ""paper mode"" (an option when loading the package "knowledge@@package"), and it now looks like a regular paper (but the links are still there). In ""electronic mode"",
164 the links are still colored, but some other hints disappear like "anchor points".
165
166 % \AP provides an anchor point: this will be the precise target of the hyperlink.
167 % It is good practice to use is at the beginning of every paragraph that contains
168 % \intro commands. If 'final=false', then these anchor points appear as a small
169 % corner (red with xcolor).
170
171
172 \knowledgeconfigure{quotation=false}% temporarily disables the " notation
173 \AP While writing a document, the two syntaxes \verb|"text"| and \verb|""text""| should be used each time some important concept is used or introduced respectively in the paper. For instance:
174 \begin{quote}
175 \verb|Define a ""group"" to be a "monoid" such that...|
176 \end{quote}
177 The `\texttt{@}' symbol allows some flexibility by having a displayed text different from the target:
178 \begin{quote}
179 \verb|This kind of "algebras@groups"...|
180 \end{quote}
181 The double `\texttt{@@}' symbols allow to specify a scope. For instance, if one wants to refer to group morphisms and avoid ambiguity with, eg, ring morphisms, one can write:
182 \begin{quote}
183 \verb|A "morphism@@group" ...|
184 \end{quote}
185 \knowledgeconfigure{quotation}
186
187
188 \AP These concepts are referred to as ""knowledge"". A "knowledge" is to be defined\footnote{These macros are usually put in the preamble of the document or in a dedicated file ending in ``\texttt{.kl}'' if you are using the very helpful script "knowledge-clustering" by Rémi Morvan.} using a command of the form:
189 \begin{verbatim}
190 \knowledge{directives}
191 | name[@scope]
192 | synonym1[@scope1]
193 | synonym2[@scope2]
194 | ...
195 \end{verbatim}
196 \AP There is a long list of possible ""directives"", and the user can define its own ones. In this document, a "directive" ``\texttt{notion}'' has automatically configured, and can be used. For instance:
197 \begin{verbatim}
198 \knowledge{notion} % assuming `notion' has been defined
199 | morphism of group
200 | morphisms of group
201 | group morphism
202 | group morphisms
203 | morphism@group
204 | morphisms@group
205 \end{verbatim}
206 It means that all these terms represent the same concept, that is assumed to be introduced once, and all other uses should link to it.
207
208 Note that using undefined "knowledge" will not cause compile time errors, but be displayed as in the following ``"unknown knowledge"'' (i.e. in non-"paper mode" in orange-brown, but in regular black in "paper@@mode" or "electronic mode"). \AP The ""diagnose file"" (that ends with a ``\texttt{.diagnose}'' extension) contains detailed information about these warnings, and should be read often when finalizing the document (here, the script "knowledge-clustering" is very useful since it automatically gathers unknown terms together according to linguistic resemblance).
209
210 \AP Small red corners called ""anchor points"" are visible in the margin, and represent the precise location in a pdf document where an internal link jumps. These are introduced
211 using the \texttt{\detokenize{\AP}}command, commonly at the beginning of each paragraph that introduce some concept, or even in the middle of the paragraph. The "anchor points" become invisible in "paper@paper mode" or "electronic mode".
212
213 \AP For making an index, if the packages "makeidx@@package" or "imakeidx@@package" are loaded before, one can use extra "directives". For instance
214 \begin{verbatim}
215 \knowledge{notion, index={morphism}, index parent key={group}}
216 | morphism of group
217 | morphisms of group
218 | group morphism
219 | group morphisms
220 | morphism@group
221 | morphisms@group
222 \end{verbatim}
223 will insert the term ``morphism'' as a sub-key of the index entry ``group'', and all the uses of group morphisms will be referred to in the index, in boldface for the introduction place.
224
225 More details to be found in the documentation. To get it, run in your shell:
226 \begin{verbatim}
227 texdoc knowledge
228 \end{verbatim}
229 Happy texing!
230
231 \printindex
232
233 \end{document}