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
% flm.latex.def.flmx.xnotes -- notes: footnotes, endnotes and the other kinds.
%
% The xnotes feature writes a note by its kind's placement.
%
% A kind placed in a list (the default of the standard kind footnote): the
% note's mark in the running text, a superscript span of role
% flm.xnotes.xnote.mark holding a link of kind xnote to the note; the notes
% are a block of role flm.xnotes.<kind>.list, kind tokens xnotes and the
% kind's name, holding the kind's title as an unnumbered heading and a
% labeled list, each item's label a superscript span of role
% flm.xnotes.entry.mark:
% Text.\flmxSpan[style=superscript, role=flm.xnotes.xnote.mark,
% anchor=fnref-1]{\flmxLink[kind=xnote, href={\#fn-1}, target=fn-1,
% doc-role=noteref, label={Footnote 1}]{1}}
% ...
% \begin{flmxBlock}[role=flm.xnotes.footnote.list, kinds={xnotes footnote},
% doc-role=endnotes]
% \flmxHeading[kind=xnotes, level=2, toc=false, plain={Footnotes}]{Footnotes}
% \begin{flmxList}[kinds={numbered xnotes footnote labeled}, depth=1]
% \flmxItem[label={\flmxSpan[style=superscript,
% role=flm.xnotes.entry.mark]{1}}, anchor=fn-1]
% The note.
% \end{flmxList}
% \end{flmxBlock}
%
% A kind placed in place: the note where it is written,
% \flmxXnote[kind, anchor, doc-role]{<mark>}{<content>}
% with the keys
% kind the note's kind (footnote, or a kind the document configures);
% anchor the note's own anchor, where it has one;
% doc-role the document role, footnote;
% <mark> FLM's mark, a superscript span of role flm.xnotes.xnote.mark
% carrying the target of the mark's anchor, and <content> the note's
% content, which may hold several paragraphs.
%
% Defaults:
% the block of role flm.xnotes.<kind>.list, registered under the kind
% token xnotes, so for every kind: a block of paragraphs, the target of
% its anchor first (the heading and the list keep their own looks);
% the link kinds xnote (mark to note) and xnote-back (note back to its
% mark) as the links chunk's default link;
% \flmxXnote of every kind: a footnote at the bottom of the page carrying
% FLM's mark, in the text and before the note (LaTeX's footnote counter
% is not used), the note's text starting with the target of its anchor.
% The marks' spans are left to the span's default, the superscript of their
% style: registering one of their roles replaces that look.
%
% A template changes the look with
% \flmxDefineBlock{xnotes}{<begin code>}{<end code>} (every kind's list)
% \flmxDefineBlock{flm.xnotes.<kind>.list}{<begin code>}{<end code>}
% \flmxDefineSpan{flm.xnotes.xnote.mark}{<code over #1>}
% \flmxDefineSpan{flm.xnotes.entry.mark}{<code over #1>}
% \flmxDefineLink{xnote}{<code over #1>}, \flmxDefineLink{xnote-back}{...}
% \flmxDefineXnote{<kind>}{<code over #1 (the mark) and #2 (the content)>}
% for instance \flmxDefineXnote{footnote}{#1\marginpar{\footnotesize #1 #2}}
% for margin notes; \flmxDefineXnoteDefault{...} changes every kind without
% a registration of its own.
\ExplSyntaxOn
\flmxDefineBlock
\flmxDefineLink
\flmxDefineLink
\NewDocumentCommand \flmxXnote
% The mark #1 as LaTeX's footnote mark shows it: the span of the mark's role
% set as it stands (\@makefnmark raises it), and, where #2 is false, without
% placing the mark's target, so that the target stands once, in the text.
\cs_new_protected:Npn \__flmx_xnote_mark:nn #1#2
% The two forms \@thefnmark holds: the mark placing its target (in the text)
% and the mark placing none (before the note, and where a \ref to the note's
% anchor typesets the mark). LaTeX internal names, not expl3 ones: LaTeX
% writes \@thefnmark to the .aux file as the label's text, which is read back
% outside expl3 syntax.
\cs_new_protected:Npn \flmx@xnotemark #1
\cs_new_protected:Npn \flmx@xnotemarknotarget #1
% Removes the paragraph breaks at the head of a note's content (a note of
% several paragraphs begins with one), so that its first line follows the
% mark.
\cs_new_protected:Npn \__flmx_xnote_skip_pars:
% The default: LaTeX's \@footnotemark and \@footnotetext, the pair \footnote
% calls, with the mark \@thefnmark set to FLM's mark.
\flmxDefineXnoteDefault
\ExplSyntaxOff