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