1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Table Macros Miscellaneous}
15
16\unprotect
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34\mutable\let\kindoftabposition\!!zerocount
35
36\permanent\tolerant\protected\def\somekindoftab[#S#1]
37 {\bgroup
38 \getdummyparameters
39 [\c!alternative=\v!vertical,
40 \c!width=\textwidth,\c!height=\textheight,
41 \c!n=\lastpage,\c!m=\realpageno,
42 #1]
43 \ifcstok{\directdummyparameter\c!alternative}\v!vertical
44 \expandafter\typo_kindoftab_indeed_v
45 \else
46 \expandafter\typo_kindoftab_indeed_h
47 \fi}
48
49\def\typo_kindoftab_indeed_v{\typo_kindoftab_indeed\vbox\vskip\c!height}
50\def\typo_kindoftab_indeed_h{\typo_kindoftab_indeed\hbox\hskip\c!width }
51
52\def\typo_kindoftab_indeed#1#2#3#4
53 {#1 to \directdummyparameter#3 \bgroup
54 \forgetall
55 \scratchnx\directdummyparameter\c!n\relax
56 \scratchmx\directdummyparameter\c!m\relax
57 \edef\kindoftabposition{\the\scratchmx}
58 \ifnum\scratchmx>\plusone
59 #2\zeropoint \s!plus \the\numexpr\scratchmx\plusone \relax\s!fill\relax
60 \fi
61 #4
62 \ifnum\scratchmx<\scratchnx\relax
63 #2\zeropoint \s!plus \the\numexpr\scratchnx\scratchmx\relax\s!fill\relax
64 \fi
65 \egroup
66 \egroup}
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\installcorenamespace{paragraphs}
110
111\installframedcommandhandler \??paragraphs {paragraphs} \??paragraphs
112
113\setupparagraphs
114 [\c!n=3,
115 \c!offset=\zeropoint,
116 \c!before=\blank,
117 \c!after=\blank,
118 \c!distance=\emwidth,
119 \c!height=\v!fit,
120 \c!width=\availablehsize,
121 \c!rule=\v!off,
122 \c!command=,
123 \c!align=,
124 \c!tolerance=\v!tolerant,
125 \c!rulethickness=\linewidth,
126 \c!rulecolor=,
127 \c!style=,
128 \c!color=,
129 \c!frame=\v!off,
130 \c!top=\vss,
131 \c!bottom=\vfill]
132
133\aliased\let\typo_paragraphs_setup_saved\setupparagraphs
134
135\let\typo_paragraphs_setup_step\gobbleoneargument
136
137\overloaded\permanent\tolerant\protected\def\setupparagraphs[#S#1]#*[#S#2]#*[#S#3]
138 {\ifarguments\or
139 \typo_paragraphs_setup_saved[#1]
140 \or
141 \typo_paragraphs_setup_saved[#1][#2]
142 \or
143 \ifcstok{#2}\v!each
144 \localcontrolledrepeat \namedparagraphsparameter{#1}\c!n
145 {\normalexpanded{\typo_paragraphs_setup_saved[#1:\the\currentloopiterator]}[#3]}
146 \else
147 \def\typo_paragraphs_setup_step##1{\typo_paragraphs_setup_saved[#1:##1][#3]}
148 \processcommalist[#2]\typo_paragraphs_setup_step
149 \fi
150 \fi}
151
152\appendtoks
153 \frozen\instance\letcsname\e!next\currentparagraphs\endcsname\nextparagraphs
154 \frozen\instance\letcsname\currentparagraphs\endcsname\nextparagraphs
155 \frozen\instance\protected\edefcsname\e!start\currentparagraphs\endcsname{\startparagraphs[\currentparagraphs]}
156 \frozen\instance\letcsname\e!stop\currentparagraphs\endcsname\stopparagraphs
157 \localcontrolledrepeat \paragraphsparameter\c!n
158 {\normalexpanded
159 {\typo_paragraphs_setup_saved
160 [\currentparagraphs:\the\currentloopiterator]
161 [\c!width=,\s!parent=\??paragraphs\currentparagraphs]}}
162 \typo_paragraphs_setup_saved[\currentparagraphs:1][\c!distance=\zeropoint]
163\to \everydefineparagraphs
164
165\newinteger \c_typo_paragraphs_n
166\newinteger \c_typo_paragraphs_max
167\newdimension\d_typo_paragraphs_width
168\newdimension\d_typo_paragraphs_auto
169
170\let\typo_paragraphs_start_cell\relax
171\let\typo_paragraphs_stop_cell \relax
172
173\permanent\protected\def\startparagraphs[#1]
174 {\bgroup
175 \cdef\currentparagraphs{#1}
176
177 \edef\p_width{\paragraphsparameter\c!width}
178 \ifempty\p_width
179 \d_typo_paragraphs_width\availablehsize
180 \else
181 \d_typo_paragraphs_width\p_width\relax
182 \fi
183 \advanceby\d_typo_paragraphs_width2\dimexpr\paragraphsparameter\c!offset\relax
184 \c_typo_paragraphs_max\paragraphsparameter\c!n\relax
185 \d_typo_paragraphs_auto\d_typo_paragraphs_width\relax
186 \scratchcounter\zerocount
187 \localcontrolledrepeat \c_typo_paragraphs_max
188 {\edef\p_width{\namedparagraphsparameter{\currentparagraphs:\the\currentloopiterator}\c!width}
189 \ifempty\p_width
190 \advanceby\scratchcounter\plusone
191 \else
192 \advanceby\d_typo_paragraphs_auto\p_width\relax
193 \fi
194 \ifnum\currentloopiterator>\plusone
195 \advanceby\d_typo_paragraphs_auto\namedparagraphsparameter{\currentparagraphs:\number\currentloopiterator}\c!distance\relax
196 \fi}
197 \ifnum\scratchcounter>\zerocount
198 \divideby\d_typo_paragraphs_auto\scratchcounter
199 \else
200 \d_typo_paragraphs_auto\zeropoint
201 \fi
202 \parindent\zeropoint
203 \c_typo_paragraphs_n\zerocount
204 \enforced\let\\\nextparagraphs
205 \edef\p_offset{\paragraphsparameter\c!offset}
206 \doifelsedimension\p_offset
207 {\scratchoffset\p_offset}
208 {\scratchoffset\zeropoint}
209 \setbox\scratchbox\hpack
210 \bgroup
211 \forgetall
212 \advanceby\hsize2\scratchoffset
213 \let\typo_paragraphs_start_cell\typo_paragraphs_start_cell_indeed
214 \let\typo_paragraphs_stop_cell \typo_paragraphs_stop_cell_indeed
215 \typo_paragraphs_start_cell_indeed}
216
217\permanent\protected\def\stopparagraphs
218 {\stopparagraphscell
219 \egroup
220 \letparagraphsparameter\c!align\v!flushleft
221 \paragraphsparameter\c!before
222 \dontleavehmode\inheritedparagraphsframed{\box\scratchbox}
223 \paragraphsparameter\c!after
224 \egroup}
225
226\permanent\protected\def\nextparagraphs
227 {\stopparagraphscell
228 \startparagraphscell}
229
230\permanent\protected\def\startparagraphscell
231 {\typo_paragraphs_start_cell}
232
233\def\typo_paragraphs_start_cell_indeed
234 {\removeunwantedspaces
235 \advanceby\c_typo_paragraphs_n\plusone
236 \ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max
237 \expandafter\typo_paragraphs_start_cell_nop
238 \else
239 \expandafter\typo_paragraphs_start_cell_yes
240 \fi}
241
242\def\typo_paragraphs_start_cell_nop
243 {\begingroup
244
245 \let\typo_paragraphs_start_cell\relax
246 \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed
247 \setbox\scratchbox\vbox\bgroup}
248
249\def\typo_paragraphs_start_cell_yes
250 {\begingroup
251 \let\typo_paragraphs_start_cell\relax
252 \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed
253 \cdef\currentparagraphs{\currentparagraphs:\the\c_typo_paragraphs_n}
254 \ifnum\c_typo_paragraphs_n>\plusone
255 \typo_paragraphs_separator
256 \fi
257 \edef\p_height{\paragraphsparameter\c!height}
258 \edef\p_width {\paragraphsparameter\c!width }
259 \useparagraphsstyleandcolor\c!style\c!color
260 \setbox\scratchbox\vtop \ifempty\p_height \orelse\ifx\p_height\v!fit \else to \p_height \fi
261 \bgroup
262 \blank[\v!disable]
263 \paragraphsparameter\c!top
264 \hsize\ifempty\p_width \d_typo_paragraphs_auto \else \p_width \fi \relax
265 \usealignparameter\paragraphsparameter
266 \paragraphsparameter\c!inner
267 \everypar{\begstrut\everypar\emptytoks}
268 \ignorespaces
269 \paragraphsparameter\c!command}
270
271\permanent\protected\def\stopparagraphscell
272 {\typo_paragraphs_stop_cell
273 \let\typo_paragraphs_stop_cell\relax}
274
275\def\typo_paragraphs_stop_cell_indeed
276 {\ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max
277 \expandafter\typo_paragraphs_stop_cell_nop
278 \else
279 \expandafter\typo_paragraphs_stop_cell_yes
280 \fi}
281
282\def\typo_paragraphs_stop_cell_nop
283 {\egroup
284 \endgroup}
285
286\def\typo_paragraphs_stop_cell_yes
287 {\ifvmode
288 \removelastskip
289 \else
290 \removeunwantedspaces
291 \endstrut
292 \endgraf
293 \fi
294 \paragraphsparameter\c!bottom
295 \egroup
296 \dontleavehmode\hpack{\raise\strutheight\box\scratchbox}
297 \endgroup}
298
299\def\typo_paragraphs_separator
300 {\scratchdistance\paragraphsparameter\c!distance
301 \ifcstok{\paragraphsparameter\c!rule}\v!on
302 \scratchwidth\paragraphsparameter\c!rulethickness
303 \scratchdistance\dimexpr(\scratchdistance\scratchwidth)2\relax
304 \hskip\scratchdistance
305 \color[\paragraphsparameter\c!rulecolor]{\vrule\s!width\scratchwidth}
306 \fi
307 \hskip\scratchdistance}
308
309\protect \endinput
310 |