1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Anchoring Macros Boxes}
15
16\unprotect
17
18\startMPpositiongraphic{mypos:boxanchor:arrow}{}
19 anch_box_arrows_draw ;
20\stopMPpositiongraphic
21
22\def\anch_box_connect_parameters#1#2
23 {span=no,
24 from=\boxanchorposone,
25 to=\boxanchorpostwo,
26 distance={\namedboxanchorcontentparameter{#1}\c!distance},
27 dashtype={\namedboxanchorcontentparameter{#1}\c!dash},
28 arrow={\namedboxanchorcontentparameter{#1}\c!arrow},
29 alternative={\namedboxanchorcontentparameter{#1}\c!alternative},
30 text={\namedboxanchorcontentparameter{#1}\c!text},
31 rulethickness={\namedboxanchorcontentparameter{#1}\c!rulethickness},
32 linecolor=\namedboxanchorcontentparameter{#1}{\c!rulecolor},
33 #2}
34
35\mutable\lettonothing\boxanchorone
36\mutable\lettonothing\boxanchortwo
37\mutable\lettonothing\boxanchorposone
38\mutable\lettonothing\boxanchorpostwo
39
40\tolerant\permanent\protected\def\connectboxanchors[#1]#*[#2]#*[#S#3]#*[#S#4]#*#:#5#6
41 {\begingroup
42
43 \edef\boxanchorone{\boxanchoringclass:#5}
44 \edef\boxanchortwo{\boxanchoringclass:#6}
45
46
47
48 \doifnotanchorbox{\boxanchorone}{\defineboxanchor[\boxanchorone]}
49 \doifnotanchorbox{\boxanchortwo}{\defineboxanchor[\boxanchortwo]}
50
51 \edef\boxanchorposone{#1:#2:\namespacedboxanchor{\boxanchorone}}
52 \edef\boxanchorpostwo{#1:#2:\namespacedboxanchor{\boxanchortwo}}
53
54
55
56 \setboxanchor[\boxanchorone][#1][#3]\hpack{\xypos{\boxanchorposone}}
57 \setboxanchor[\boxanchortwo][#2][#4]\hpack{\xypos{\boxanchorpostwo}}
58
59 \ifparameter#3\or\setupboxanchorcontent[#1][#3]\fi
60 \ifparameter#4\or\setupboxanchorcontent[#2][#4]\fi
61
62 \normalexpanded{
63 \startpositionoverlay{text1}
64 \setMPpositiongraphic
65 {\boxanchorposone}
66 {\namedboxanchorcontentparameter{#1}\c!mp}
67 {\anch_box_connect_parameters{#1}{#3}}
68 \stoppositionoverlay
69 }
70 \ifcstok{\namedboxanchorcontentparameter{#1}\c!page}\v!yes
71 \normalexpanded{
72 \startpositionoverlay{text1}
73 \setMPpositiongraphic
74 {\boxanchorpostwo}
75 {\namedboxanchorcontentparameter{#1}\c!mp}
76 {\anch_box_connect_parameters{#1}{#3}}
77 \stoppositionoverlay
78 }
79 \fi
80 \endgroup}
81
82
83
84\tolerant\permanent\protected\def\connectmatrixanchors[#1]#*[#2]#*[#S#3]#*[#S#4]#*#:#5#6
85 {\begingroup
86 \doifelseinset{#5}{\m_anch_matrix_list}\donetrue\donefalse
87 \ifdone\else
88 \defineboxanchor[#5]
89 \setboxanchor[#5][#1][#3]\hpack{\xypos{\namespacedboxanchor{#5}}}
90 \xdef\m_anch_matrix_list{\m_anch_matrix_list,#5}
91 \fi
92 \ifparameter#3\or\setupboxanchorcontent[#1][#3]\fi
93 \doifelseinset{#6}{\m_anch_matrix_list}\donetrue\donefalse
94 \ifdone\else
95 \defineboxanchor[#6]
96 \setboxanchor[#6][#2][#4]\hpack{\xypos{\namespacedboxanchor{#6}}}
97 \xdef\m_anch_matrix_list{\m_anch_matrix_list,#6}
98 \fi
99 \ifparameter#4\or\setupboxanchorcontent[#1][#4]\fi
100 \startpositionoverlay{text1}
101 \setMPpositiongraphic
102 {\namespacedboxanchor{#5}}
103 {\namedboxanchorcontentparameter{#1}\c!mp}
104 {from=\namespacedboxanchor{#5},
105 to=\namespacedboxanchor{#6},
106 distance={\namedboxanchorcontentparameter{#1}\c!distance},
107 dashtype={\namedboxanchorcontentparameter{#1}\c!dash},
108 arrow={\namedboxanchorcontentparameter{#1}\c!arrow},
109 alternative={\namedboxanchorcontentparameter{#1}\c!alternative},
110 text={\namedboxanchorcontentparameter{#1}\c!text},
111 rulethickness={\namedboxanchorcontentparameter{#1}\c!rulethickness},
112 linecolor=\namedboxanchorcontentparameter{#1}{\c!rulecolor},
113
114 leftedge=\namespacedboxanchor\c!leftedge,
115 rightedge=\namespacedboxanchor\c!rightedge}
116 \stoppositionoverlay
117 \endgroup}
118
119\lettonothing\m_anch_matrix_list
120
121\tolerant\permanent\protected\def\startmatrixanchors
122 {\glet\m_anch_matrix_list\empty
123 \defineboxanchor[\v!leftedge]
124 \setboxanchor[\v!leftedge][\v!leftedge]\hpack{\xypos{\namespacedboxanchor\v!leftedge}}
125 \defineboxanchor[\v!rightedge]
126 \setboxanchor[\v!rightedge][\v!rightedge]\hpack{\xypos{\namespacedboxanchor\v!rightedge}}
127 \setupmathfence[\c!leftsource=\v!leftedge,\c!rightsource=\v!rightedge]}
128
129\tolerant\permanent\protected\def\stopmatrixanchors
130 {\setupmathfence[\c!leftsource=,\c!rightsource=]
131 \glet\m_anch_matrix_list\empty}
132
133\defineboxanchorcontent
134 [arrow]
135 [\c!mp=mypos:boxanchor:arrow,
136 \c!distance=1.5\exheight,
137 \c!rulethickness=\linewidth,
138 \c!rulecolor=textcolor]
139
140\defineboxanchorcontent
141 [\v!top]
142 [arrow]
143 [\c!corner=\v!height,
144 \c!location=\v!depth,
145 \c!yoffset=.25\exheight,
146 \c!alternative=\v!top]
147
148\defineboxanchorcontent
149 [\v!bottom]
150 [arrow]
151 [\c!corner=\v!depth,
152 \c!location=\v!height,
153 \c!yoffset=\namedboxanchorcontentparameter{top}\c!yoffset,
154 \c!alternative=\v!bottom]
155
156\defineboxanchorcontent
157 [\v!left]
158 [arrow]
159 [\c!corner={\v!middle,\v!left},
160 \c!xoffset=1.25\emwidth,
161 \c!alternative=\v!left]
162
163\defineboxanchorcontent
164 [\v!right]
165 [arrow]
166 [\c!corner={\v!middle,\v!right},
167 \c!xoffset=\namedboxanchorcontentparameter{left}\c!xoffset,
168 \c!alternative=\v!right]
169
170\defineboxanchorcontent
171 [\v!leftedge]
172 [\v!left]
173 [\c!xoffset=.25\exheight]
174
175\defineboxanchorcontent
176 [\v!rightedge]
177 [\v!right]
178 [\c!xoffset=0.25\exheight]
179
180\defineboxanchorcontent[\v!middle:\v!bottom][\v!bottom][\c!alternative=\v!middle,\c!yoffset=.5\exheight]
181\defineboxanchorcontent[\v!middle:\v!top ][\v!top ][\c!alternative=\v!middle,\c!yoffset=.5\exheight]
182\defineboxanchorcontent[\v!middle:\v!left ][\v!left ][\c!alternative=\v!middle,\c!xoffset=.5\exheight]
183\defineboxanchorcontent[\v!middle:\v!right ][\v!right ][\c!alternative=\v!middle,\c!xoffset=.5\exheight]
184
185\defineboxanchorcontent
186 [\v!left:\v!bottom]
187 [\v!bottom]
188 [\c!alternative=\v!middle,
189 \c!corner={\v!left,\v!depth},
190 \c!xoffset=.25\exheight,
191 \c!yoffset=.25\exheight]
192
193\defineboxanchorcontent
194 [\v!right:\v!bottom]
195 [\v!bottom]
196 [\c!alternative=\v!middle,
197 \c!corner={\v!right,\v!depth},
198 \c!xoffset=.25\exheight,
199 \c!yoffset=.25\exheight]
200
201\defineboxanchorcontent
202 [\v!left:\v!top]
203 [\v!top]
204 [\c!alternative=\v!middle,
205 \c!corner={\v!left,\v!height},
206 \c!xoffset=.25\exheight,
207 \c!yoffset=.25\exheight]
208
209\defineboxanchorcontent
210 [\v!right:\v!top]
211 [\v!top]
212 [\c!alternative=\v!middle,
213 \c!corner={\v!right,\v!height},
214 \c!xoffset=.25\exheight,
215 \c!yoffset=.25\exheight]
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\protect
256 |