| 1 |
%% ---------------------------------------------------------------- |
| 2 |
%% scikgtex --- Scientific Knowledge Graph TeX (SciKgTeX) is a |
| 3 |
%% LuaLaTeX package which makes it possible to annotate specific |
| 4 |
%% research contributions in scientific documents. SciKGTeX will |
| 5 |
%% enrich the document by adding marked contributions to PDF |
| 6 |
%% metadata in a structured XMP format which can be picked up by |
| 7 |
%% Search Engines and Knowledge Graphs. |
| 8 |
%% More information on how to use the package can be found here: |
| 9 |
%% https://github.com/Christof93/SciKGTeX#readme |
| 10 |
%% |
| 11 |
%% Author: Christof Bless |
| 12 |
%% E-mail: [email protected] |
| 13 |
%% Released under the MIT License |
| 14 |
%% See https://opensource.org/licenses/MIT |
| 15 |
%% ---------------------------------------------------------------- |
| 16 |
%% |
| 17 |
\NeedsTeXFormat{LaTeX2e} |
| 18 |
\ProvidesPackage{scikgtex}[2022/11/13 v2.1.1] |
| 19 |
% |
| 20 |
\def\useignorespacesandallpars#1\ignorespaces\fi{% |
| 21 |
#1\fi\ignorespacesandallpars} |
| 22 |
% |
| 23 |
\makeatletter |
| 24 |
\def\ignorespacesandallpars{% |
| 25 |
\@ifnextchar\par |
| 26 |
{\expandafter\ignorespacesandallpars\@gobble}% |
| 27 |
{}% |
| 28 |
} |
| 29 |
\makeatother |
| 30 |
% |
| 31 |
\RequirePackage{suffix} |
| 32 |
%% init variable which checks if hyperref is loaded. |
| 33 |
\newcommand{\hyperrefloaded}{null}% |
| 34 |
% |
| 35 |
\errorcontextlines=5 |
| 36 |
% |
| 37 |
\directlua {% |
| 38 |
SciKGTeX = require('scikgtex')% |
| 39 |
CONFORM_TO_PDFA = false% |
| 40 |
} |
| 41 |
\DeclareOption{compatibility}{ |
| 42 |
\directlua {% |
| 43 |
CONFORM_TO_PDFA = true% |
| 44 |
} |
| 45 |
} |
| 46 |
\ProcessOptions\relax |
| 47 |
|
| 48 |
\newcommand{\addmetaproperty}[2][]{% |
| 49 |
\directlua{% |
| 50 |
local new_property = "\luaescapestring{\unexpanded{#2}}"% |
| 51 |
local ns = "\luaescapestring{\unexpanded{#1}}"% |
| 52 |
SciKGTeX:add_property(new_property, ns)% |
| 53 |
}% |
| 54 |
\ignorespaces |
| 55 |
}% |
| 56 |
|
| 57 |
\newcommand{\newpropertycommand}[2][]{% |
| 58 |
\directlua{% |
| 59 |
local new_property = "\luaescapestring{\unexpanded{#2}}"% |
| 60 |
local ns = "\luaescapestring{\unexpanded{#1}}"% |
| 61 |
SciKGTeX:make_new_command(new_property, ns)% |
| 62 |
}% |
| 63 |
\ignorespaces |
| 64 |
}% |
| 65 |
|
| 66 |
\newcommand{\metatitle}[2][]{% |
| 67 |
\directlua{% |
| 68 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 69 |
SciKGTeX.XMP:set_title(value)% |
| 70 |
}% |
| 71 |
#2% |
| 72 |
}% |
| 73 |
|
| 74 |
\WithSuffix\newcommand\metatitle*[2][]{% |
| 75 |
\directlua{% |
| 76 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 77 |
SciKGTeX.XMP:set_title(value)% |
| 78 |
}% |
| 79 |
\ignorespaces |
| 80 |
}% |
| 81 |
|
| 82 |
\newcommand{\metaauthor}[2][]{% |
| 83 |
\directlua{% |
| 84 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 85 |
SciKGTeX.XMP:add_author(value)% |
| 86 |
}% |
| 87 |
#2% |
| 88 |
}% |
| 89 |
|
| 90 |
\WithSuffix\newcommand\metaauthor*[2][]{% |
| 91 |
\directlua{% |
| 92 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 93 |
SciKGTeX.XMP:add_author(value)% |
| 94 |
}% |
| 95 |
\ignorespaces |
| 96 |
}% |
| 97 |
|
| 98 |
\newcommand{\researchfield}[2][]{% |
| 99 |
\directlua{% |
| 100 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 101 |
SciKGTeX.XMP:set_researchfield(value)% |
| 102 |
}% |
| 103 |
#2% |
| 104 |
}% |
| 105 |
|
| 106 |
\WithSuffix\newcommand\researchfield*[2][]{% |
| 107 |
\directlua{% |
| 108 |
local value = "\luaescapestring{\unexpanded{#2}}"% |
| 109 |
SciKGTeX.XMP:set_researchfield(value)% |
| 110 |
}% |
| 111 |
\ignorespaces |
| 112 |
}% |
| 113 |
% |
| 114 |
\newcommand{\uri}[2]{% |
| 115 |
\ifcsname href\endcsname% |
| 116 |
\renewcommand{\hyperrefloaded}{true}% |
| 117 |
\else% |
| 118 |
\renewcommand{\hyperrefloaded}{false}% |
| 119 |
\fi% |
| 120 |
% |
| 121 |
\directlua{% |
| 122 |
local label = "\luaescapestring{\unexpanded{#2}}"% |
| 123 |
local uri = "\luaescapestring{\unexpanded{#1}}"% |
| 124 |
SciKGTeX:print_entity(uri, label, \hyperrefloaded)% |
| 125 |
}% |
| 126 |
}% |
| 127 |
|
| 128 |
\newcommand{\contribution}[3][]{% |
| 129 |
\directlua{% |
| 130 |
local contrib_n = "\luaescapestring{\unexpanded{#1}}"% |
| 131 |
local property = "\luaescapestring{\unexpanded{#2}}"% |
| 132 |
local value = "\luaescapestring{\unexpanded{#3}}"% |
| 133 |
SciKGTeX.XMP:add_annotation(contrib_n, property, value, 'annotation-id')% |
| 134 |
}% |
| 135 |
#3% |
| 136 |
}% |
| 137 |
|
| 138 |
\WithSuffix\newcommand\contribution*[3][]{% |
| 139 |
\directlua{% |
| 140 |
local contrib_n = "\luaescapestring{\unexpanded{#1}}"% |
| 141 |
local property = "\luaescapestring{\unexpanded{#2}}"% |
| 142 |
local value = "\luaescapestring{\unexpanded{#3}}"% |
| 143 |
SciKGTeX.XMP:add_annotation(contrib_n, property, value, 'annotation-id')% |
| 144 |
}% |
| 145 |
\ignorespaces |
| 146 |
}% |
| 147 |
|
| 148 |
\newpropertycommand{researchproblem} |
| 149 |
\newpropertycommand{result} |
| 150 |
\newpropertycommand{method} |
| 151 |
\newpropertycommand{objective} |
| 152 |
\newpropertycommand{conclusion} |
| 153 |
|
| 154 |
%% Copyright (C) 2022 by Christof Bless <[email protected]> |
| 155 |
%% |
| 156 |
%% This work may be distributed and/or modified under the |
| 157 |
%% conditions of the MIT License. |
| 158 |
%% |
| 159 |
%% This work consists of the file scikgtex.sty |
| 160 |
%% and the lua file scikgtex.lua. |
| 161 |
%% |
| 162 |
%% |
| 163 |
%% End of file `scikgtex.sty'. |