summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/stex/sty/smglom/smglom.dtx
blob: 4063a66d03e86949497ee2e81179b2dc07a1c178 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
% \iffalse meta-comment
% A LaTeX Class and Package for the SMGloM Glossary
% Copyright (c) 2009 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
%
% The original of this file is in the public repository at 
% http://github.com/KWARC/sTeX/
% \fi
%   
% \iffalse
%<package|cls>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<cls>\ProvidesClass{smglom}[2019/03/20 v0.1 Semantic Multilingual Glossary for Math]
%<sty>\ProvidesPackage{smglom}[2019/03/20 v0.1 Semantic Multilingual Glossary for Math]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage[utf8]{inputenc}
\usepackage{url,array,omdoc,omtext,float}
\usepackage[show]{ed}
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\addbibresource{kwarcpubs.bib}
\addbibresource{extpubs.bib}
\addbibresource{kwarccrossrefs.bib}
\addbibresource{extcrossrefs.bib}
\usepackage{stex-logo}
\usepackage{ctangit}
\usepackage{hyperref}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\def\githubissue#1{\cite{sTeX:github:on}, \hyperlink{hstp://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}
\DocInput{smglom.dtx}
\end{document}
%</driver>
% \fi
% 
%\CheckSum{152}
% 
% \changes{v0.1}{2013/12/17}{First Version}
% \changes{v0.1}{2014/2/17}{Renamed ad split into \texttt{smglom.sty} and \texttt{smglom.cls}}
%
% 
% \MakeShortVerb{\|}
%
% \def\omdoc{OMDoc\xspace}
% \def\smglom{SMGloM\xspace}
% \def\latexml{{\LaTeX}ML\xspace}
% \title{{\texttt{smglom.cls/sty}}: Semantic Multilingual Glossary for Math}
%    \author{Michael Kohlhase\\
%    FAU Erlangen-N\"urnberg\\
%    \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
%   The |smglom| package is part of the {\sTeX} collection, a version of {\TeX/\LaTeX}
%   that allows to markup {\TeX/\LaTeX} documents semantically without leaving the
%   document format, essentially turning {\TeX/\LaTeX} into a document format for
%   mathematical knowledge management (MKM).
%
%   This package supplies an infrastructure for writing {\omdoc} glossary entries. 
% \end{abstract}
%
%\tableofcontents\newpage
% 
%\begin{omgroup}[id=sec:STR]{Introduction}
%
% \end{omgroup}
% 
% \begin{omgroup}[id=sec:user]{The User Interface}\
% 
%
% \begin{omgroup}[id=sec:user:options]{Package and Class Options}
%   |smglom.cls| accepts all options of the |omdoc.cls| and |article.cls| and just passes
%   them on to these. 
% \end{omgroup}
% 
% \begin{omgroup}[id=user:modules]{Convenience Macros for \protect\smglom Modules}
%   \ednote{document them}
% \end{omgroup}
% 
% \begin{omgroup}[id=user:relations]{Terminological Relations}
%   \ednote{document them}
% \end{omgroup}
% 
% \begin{omgroup}[id=user:alignments]{Namespaces and Alignments}
%   \ednote{MK: maybe this should go into some other module; it seems awfully
%   foundational.} In \smglom, we often want to align the content of glossary modules to
%   formalizations, e.g. to take advantage of type declarations there. The
%   \DescribeMacro{\symalign}|\symalign| macro takes two regular arguments: the first is
%   the name symbol declared in the current module (e.g. by a |\symi|), and the second the
%   URI name of a symbol in an external theory in the form \meta{theory}|?|\meta{name}.
%   
%   As full MMT URIs are of the form \meta{URI}|?|\meta{theory}|?|\meta{name}, we need a
%   way to specify the \meta{URI}. We adopt the system of \textbf{namespaces} of in MMT:
%   the \DescribeMacro{\namespace} macro declares a namespace URI. If the optional
%   argument is given, then this is a namespace abbreviation declaration, which can be
%   used later, for instance in |\symalign| that takes an optional first argument: the
%   namespace of the external theory. 
% 
%   The situation below is typical. We first declare the namespace abbreviation |sets| and
%   then use the \DescribeMacro{\modalign}|\modalign| macro to specify that the external
%   theory |sets:?ESet| is the default alignment target, i.e. any symbol that in the local
%   |emptyset| module is aligned by default to the symbol with the same name in the
%   external |sets:?ESet| theory. 
%   
% \begin{verbatim}
% \begin{modsig}[creators=miko]{emptyset}
%   \gimport{set}
%   \namespace[sets]{http://mathhub.info/MitM/smglom/sets}
%   \modalign[sets]{ESet}
% 
%  \symdef{eset}{\emptyset}
%  \symi{non-empty}
%  \symalign{non-empty}{ESet?non_empty}
% \end{modsig}
% \end{verbatim}
% 
%   The default alignment breaks down for the symbol |non-empty|, so we specify an
%   alignment to the symbol |Eset?non_empty| via |\symalign|.
% \end{omgroup}
% \end{omgroup}
% 
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\printbibliography}\newpage
%
% \begin{omgroup}[id=sec:impl:cls]{Implementation: The SMGloM Class}
%
% \begin{omgroup}[id=sec:impl:cls:options]{Class Options}
%
% To initialize the |smglom| class, we pass on all options to |omdoc.cls| as well as the
% |stex| and |smglom| packages. 
% 
%    \begin{macrocode}
%<*cls>
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{omdoc}
                           \PassOptionsToPackage{\CurrentOption}{stex}
                           \PassOptionsToPackage{\CurrentOption}{smglom}}
\ProcessOptions
%    \end{macrocode}
% 
% We load |omdoc.cls|, the |smglom| package that provides the SMGloM-specific
% functionality\ednote{MK:describe that above}, and the |stex| package to allow OMDoc
% compatibility. 
%
%    \begin{macrocode}
\LoadClass{omdoc}
\RequirePackage{smglom}
\RequirePackage{stex}
\RequirePackage{amstext}
\RequirePackage{amsfonts}
%</cls>
%    \end{macrocode}
%
% Now we do the same thing for the package; first the options, which we just pass on to
% the |stex| package.  
%
%    \begin{macrocode}
%<*sty>
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{statements}
                          \PassOptionsToPackage{\CurrentOption}{structview}
                          \PassOptionsToPackage{\CurrentOption}{smultiling}}
\ProcessOptions
%    \end{macrocode}
%
% We load |omdoc.cls|, and the desired packages. For the {\latexml} bindings, we make sure
% the right packages are loaded.
%
%    \begin{macrocode}
\RequirePackage{statements}
\RequirePackage[langfiles]{smultiling}
\RequirePackage{structview}
%    \end{macrocode}
% \end{omgroup}
% 
% \begin{omgroup}[id=impl:modules]{Convenience Macros for \protect\smglom Modules}
% \begin{macro}{\gimport}
% Just a shortcut, we have a starred and unstarred version, the first one is conservative.
% For example, if we execute:\newline
% \begin{center}
% |\gimport[smglom/numberfields]{naturalnumbers}|\newline
% \end{center}
% First we are redirected to |\@gimport@nostar|, we store the
% |smglom/numberfields|\meta{the repo's path} in |\@test|, then store
% |\mh@currentrepos|\meta{current directory} in |\mh@repos|. If no repo's path is offered,
% that means the module to import is under the same directory, so we let |repos=\mh@repos|
% and pass bunch of parameters to |\importmhmodule|, which is defined in |module.sty|. If
% there's a repo's path, then we let repos=\meta{the repo's path}. Finally we use
% |\mhcurrentrepos|(defined in |module.sty|) to change the |\mh@currentrepos|.
%    \begin{macrocode}
\def\gimport{\@ifstar\@gimport@star\@gimport@nostar}%
\newrobustcmd\@gimport@star[2][]{%
  \def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \importmhmodule[conservative,repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \importmhmodule[conservative,repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
\newrobustcmd\@gimport@nostar[2][]{%
  \def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \importmhmodule[repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \importmhmodule[repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{guse}
%   just a shortcut
%    \begin{macrocode}
\newrobustcmd\guse[2][]{\def\@test{#1}%
  \edef\mh@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \usemhmodule[repos=\mh@@repos,ext=tex,path=#2]{#2}%
  \else%
    \usemhmodule[repos=#1,ext=tex,path=#2]{#2}%
  \fi%
  \mhcurrentrepos{\mh@@repos}%
  \ignorespacesandpars%
}%
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{gstructure}
%   we essentially copy over the definition of |mhstructure|, but adapt it to the \smglom
%   situation.
%    \begin{macrocode}
\newenvironment{gstructure}[3][]{\def\@test{#1}%
  \xdef\mh@@@repos{\mh@currentrepos}%
  \ifx\@test\@empty%
    \gdef\@@doit{\importmhmodule[repos=\mh@@@repos,path=#3,ext=tex]{#3}}%
  \else%
    \gdef\@@doit{\importmhmodule[repos=#1,path=#3,ext=tex]{#3}}%
  \fi%
  \ifmod@show\par\noindent structure import "#2" from module #3 \@@doit\fi%
  \ignorespacesandpars}
{\aftergroup\@@doit\ifmod@show end import\fi%
  \ignorespacesandparsafterend}
%    \end{macrocode}
% \end{environment}
% \end{omgroup}
% 
% \begin{omgroup}[id=impl:relations]{Terminological Relations}
%
% \begin{macro}{*nym}
%    \begin{macrocode}
\newrobustcmd\hypernym[3][]{\if@importing\else\par\noindent #2 is a hypernym of #3\fi}%
\newrobustcmd\hyponym[3][]{\if@importing\else\par\noindent #2 is a hyponym of  #3\fi}%
\newrobustcmd\meronym[3][]{\if@importing\else\par\noindent #2 is a meronym of #3\fi}%
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\MSC}
%   to define the Math Subject Classification, \ednote{MK: what to do for the LaTeXML side?}
%    \begin{macrocode}
\newrobustcmd\MSC[1]{\if@importing\else MSC: #1\fi\ignorespacesandpars}%
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% 
% \begin{omgroup}[id=impl:alignments]{Namespaces and Alignments}
%
% \begin{macro}{\namespace}
%    \begin{macrocode}
\newcommand\namespace[2][]{\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\modalign}
%    \begin{macrocode}
\newcommand\modalign[2][]{\ignorespaces}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\symalign}
%    \begin{macrocode}
\newcommand\symalign[3][]{\ignorespaces}
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
%
% \begin{omgroup}[id=sec:langbindings]{For Language Bindings}
%
% Here we adapt the |smultiling| functionality to the special situation, where the module
% and file names are identical by design. 
%
% \begin{environment}{gviewsig}
%   The |gviewsig| environment is just a layer over the |mhviewsig| environment with the keys
%   suitably adapted.
%    \begin{macrocode}
\newenvironment{gviewsig}[4][]{% keys, id, from, to
  \def\test{#1}%
  \ifx\@test\@empty%
    \begin{mhviewsig}[frompath=#3,topath=#4]{#2}{#3}{#4}%
  \else%
    \begin{mhviewsig}[frompath=#3,topath=#4,#1]{#2}{#3}{#4}%
  \fi%
  \ignorespacesandpars%
}{%
  \end{mhviewsig}%
  \ignorespacesandparsafterend%
}%
%    \end{macrocode}
% \end{environment}
%
% \begin{environment}{gviewnl}
%   The |gviewnl| environment is just a layer over the |mhviewnl| environment with the
%   keys suitably adapted.
%    \begin{macrocode}
\newenvironment{gviewnl}[5][]{% keys, id, lang, from, to
  \def\@test{#1}\ifx\@test\@empty%
    \begin{mhviewnl}[frompath=#4,topath=#5]{#2}{#3}{#4}{#5}%
  \else%
    \begin{mhviewnl}[frompath=#4,topath=#5,#1]{#2}{#3}{#4}{#5}%
  \fi%
\ignorespacesandpars%
}{%
  \end{mhviewnl}%
  \ignorespacesandparsafterend%
}%
%    \end{macrocode}
% \end{environment}
%
% \begin{macro}{\gincludeview}
%   \ednote{This is fake for now, needs to be implemented and documented}
%    \begin{macrocode}
\newcommand\gincludeview[2][]{\ignorespacesandpars}%
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% 
% \begin{omgroup}{Authoring States, etc}
% We add a key to the module environment.
%    \begin{macrocode}
\addmetakey{module}{state}%
%    \end{macrocode}
% \end{omgroup}
%
% \begin{omgroup}{Shadowing of repositories}
% \begin{macro}{\repos@macro} 
%   |\repos@macro| parses a GitLab repository name \meta{group}|/|\meta{name} and creates
%   an internal macro name from that, which will be used 
%    \begin{macrocode}
\def\repos@macro#1/#2;{#1@shadows@#2}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\shadow} 
%   |\shadow{|\meta{orig}|}{|\meta{fork}|}| declares a that the private repository
%   \meta{fork} shadows the MathHub repository \meta{orig}. Internally, it simply defines
%   an internal macro with the shadowing information.
%    \begin{macrocode}
\def\shadow#1#2{\@namedef{\repos@macro#1;}{#2}}%
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\MathHubPath} 
%   |\MathHubPath{|\meta{repos}|}| computes the path of the fork that shadows the MathHub
%   repository \meta{repos} according to the current |\shadow| specification. The computed
%   path can be used for loading modules from the private version of \meta{repos}. 
%    \begin{macrocode}
\def\MathHubPath#1{\@ifundefined{\repos@macro#1;}{#1}{\@nameuse{\repos@macro#1;}}}%
%</sty>
%    \end{macrocode}
% \end{macro}
% \end{omgroup}
% \end{omgroup} 
% \Finale
\endinput
% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi

% LocalWords:  iffalse cls smglo smglo.dtx omdoc latexml texttt smlog.cls sref SMGloM ifx
% LocalWords:  maketitle newpage tableofcontents newpage omgroup ednote ltxml smglom.dtx
% LocalWords:  printbibliography showmeta metakeys amstext ginput newrobustcmd sproof cmath
% LocalWords:  module-defs gimport renewrobustcmd langbindings gle newenvironment amsfonts
% LocalWords:  doctex NeedsTeXFormat langfiles ngerman smultiling xspace formalizations
%  LocalWords:  symalign symalign symi textbf modalign modalign ESet emptyset initialize
%  LocalWords:  stex impl:modules unstarred numberfields mh@currentrepos mh@repos 1,ext
%  LocalWords:  importmhmodule mhcurrentrepos conservative,repos tex,path guse gstructure
%  LocalWords:  ignorespacesandpars usemhmodule mhstructure xdef gdef 3,ext 1,path nym
%  LocalWords:  ifmod@show noindent aftergroup ignorespacesandparsafterend impl:relations
%  LocalWords:  impl:alignments newcommand begingroup catcode`_ gviewsig mhviewsig
%  LocalWords:  3,topath gviewnl mhviewnl 4,topath gincludeview addmetakey