% \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 %\NeedsTeXFormat{LaTeX2e}[1999/12/01] %\ProvidesClass{smglom}[2019/03/20 v0.1 Semantic Multilingual Glossary for Math] %\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} % % \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} % % \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;}}}% % % \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