summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/metanorma/metanorma.cls
blob: 894f9a860dc4a9f455fe09c730f100b531d250c7 (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
%
% tex2mn 0.5.0 - converts Metanorma documents from LaTeX to AsciiDoc
%
% Copyright (C) 2019-2020 Ribose Inc. <open.source@ribose.com>
% This project is available under the terms of the MIT License.
%

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{metanorma}
   [2019/07/07 Metanorma]

\LoadClass{article}

\RequirePackage{graphicx}
\RequirePackage{hyperref}
% TODO: what's the best baseline AMS setup?
\RequirePackage{amsmath}
\RequirePackage{subcaption}
\RequirePackage{enumitem}

\RequirePackage{verbatim}

\RequirePackage{xparse}

%% RDF %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% \RequirePackage{lxRDFa}
% Let's not introduce another (mostly trivial) dependency, and just embed it:
\DeclareRobustCommand{\lxRDFa}[2][]{}
\DeclareRobustCommand{\lxRDF}[2][]{}

\NewDocumentCommand{\mn}{m}
  {\lxRDF[#1]{property=mn:attributes}}

%% Document attributes %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter

\NewDocumentCommand{\set}{mm}{%
  \lxRDF{property=#1,content=#2}%
  \expandafter\def\csname metadata@#1\endcsname{#2}}

\@onlypreamble\set

\NewDocumentCommand{\get}{m}
  {\csname metadata@#1\endcsname}

\makeatother

\NewDocumentCommand{\att}{om}{#2}

%% General style %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% No indentation on paragraphs.
\setlength\parindent{0pt}

%% Strikethrough %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% `normalem` avoids changes to the behaviour of emphasis.
\RequirePackage[normalem]{ulem}

% We decouple the class' API from the package choice.
\let\textst\sout

%% Blocks %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage[framemethod=TikZ]{mdframed}

\mdfdefinestyle{mnbase}{
  frametitlerule=true,
  frametitlefont=\sffamily\bfseries\scshape\small,
  linecolor=gray,
}

% Admonitions

\mdfdefinestyle{note}{linecolor=blue,frametitle=Note}
\mdfdefinestyle{tip}{linecolor=green,frametitle=Tip}
\mdfdefinestyle{important}{linecolor=yellow,frametitle=Important}
\mdfdefinestyle{caution}{linecolor=red,frametitle=Caution}
\mdfdefinestyle{warning}{linecolor=orange,frametitle=Warning}

\newmdenv[style=mnbase,style=note]{note}
\newmdenv[style=mnbase,style=tip]{tip}
\newmdenv[style=mnbase,style=important]{important}
\newmdenv[style=mnbase,style=caution]{caution}
\newmdenv[style=mnbase,style=warning]{warning}

% Requirement, recommendation and permission

\mdfdefinestyle{requirement}{linecolor=gray,frametitle=Requirement}
\mdfdefinestyle{recommendation}{linecolor=gray,frametitle=Recommendation}
\mdfdefinestyle{permission}{linecolor=gray,frametitle=Permission}

\newmdenv[style=mnbase,style=requirement]{requirement}
\newmdenv[style=mnbase,style=recommendation]{recommendation}
\newmdenv[style=mnbase,style=permission]{permission}

% Specification, measurement target, verification and import

\mdfdefinestyle{specification}{linecolor=lightgray,frametitle=Specification}
\mdfdefinestyle{measurement-target}{linecolor=lightgray,frametitle=Measurement target}
\mdfdefinestyle{verification}{linecolor=lightgray,frametitle=Verification}
\mdfdefinestyle{import}{linecolor=lightgray,frametitle=Import}

\newmdenv[style=mnbase,style=specification]{specification}
\newmdenv[style=mnbase,style=measurement-target]{measurement-target}
\newmdenv[style=mnbase,style=verification]{verification}
\newmdenv[style=mnbase,style=import]{import}

%% Terms and definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\NewDocumentCommand{\alt}{m}{{\large #1}\par}
\NewDocumentCommand{\deprecated}{m}{\textbf{DEPRECATED:} #1\par}
\NewDocumentCommand{\domain}{m}{\textbf{DOMAIN:} #1\par}

\mdfdefinestyle{example}{linecolor=lightgray,frametitle=Example}
\mdfdefinestyle{source}{linecolor=lightgray,frametitle=Source}

\newmdenv[style=mnbase,style=example]{example}
\newmdenv[style=mnbase,style=source]{source}

%% Citation macros %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% TODO: handle localities formatting
\NewDocumentCommand{\mncite}{omo}{\cite[#1]{#2}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newlist{key}{description}{1}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%