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 \d_typo_paragraphs_width{\d_typo_paragraphs_width(\paragraphsparameter\c!offset)*2}
184 \c_typo_paragraphs_max{\paragraphsparameter\c!n}
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)}
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
206 \setbox\scratchbox\hpack
207 \bgroup
208 \forgetall
209
210 \ifchkdimension\paragraphsparameter\c!offset\or\advanceby\hsize2\lastchkdimension\fi
211 \let\typo_paragraphs_start_cell\typo_paragraphs_start_cell_indeed
212 \let\typo_paragraphs_stop_cell \typo_paragraphs_stop_cell_indeed
213 \typo_paragraphs_start_cell_indeed}
214
215\permanent\protected\def\stopparagraphs
216 {\stopparagraphscell
217 \egroup
218 \letparagraphsparameter\c!align\v!flushleft
219 \paragraphsparameter\c!before
220 \dontleavehmode\inheritedparagraphsframed{\box\scratchbox}
221 \paragraphsparameter\c!after
222 \egroup}
223
224\permanent\protected\def\nextparagraphs
225 {\stopparagraphscell
226 \startparagraphscell}
227
228\permanent\protected\def\startparagraphscell
229 {\typo_paragraphs_start_cell}
230
231\def\typo_paragraphs_start_cell_indeed
232 {\removeunwantedspaces
233 \advanceby\c_typo_paragraphs_n\plusone
234 \ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max
235 \expandafter\typo_paragraphs_start_cell_nop
236 \else
237 \expandafter\typo_paragraphs_start_cell_yes
238 \fi}
239
240\def\typo_paragraphs_start_cell_nop
241 {\begingroup
242
243 \let\typo_paragraphs_start_cell\relax
244 \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed
245 \setbox\scratchbox\vbox\bgroup}
246
247\def\typo_paragraphs_start_cell_yes
248 {\begingroup
249 \let\typo_paragraphs_start_cell\relax
250 \let\typo_paragraphs_stop_cell\typo_paragraphs_stop_cell_indeed
251 \cdef\currentparagraphs{\currentparagraphs:\the\c_typo_paragraphs_n}
252 \ifnum\c_typo_paragraphs_n>\plusone
253 \typo_paragraphs_separator
254 \fi
255 \edef\p_height{\paragraphsparameter\c!height}
256 \edef\p_width {\paragraphsparameter\c!width }
257 \useparagraphsstyleandcolor\c!style\c!color
258 \setbox\scratchbox\vtop \ifempty\p_height \orelse\ifx\p_height\v!fit \else to \p_height \fi
259 \bgroup
260 \blank[\v!disable]
261 \paragraphsparameter\c!top
262 \hsize\ifempty\p_width \d_typo_paragraphs_auto \else \p_width \fi \relax
263 \usealignparameter\paragraphsparameter
264 \paragraphsparameter\c!inner
265 \everypar{\begstrut\everypar\emptytoks}
266 \ignorespaces
267 \paragraphsparameter\c!command}
268
269\permanent\protected\def\stopparagraphscell
270 {\typo_paragraphs_stop_cell
271 \let\typo_paragraphs_stop_cell\relax}
272
273\def\typo_paragraphs_stop_cell_indeed
274 {\ifnum\c_typo_paragraphs_n>\c_typo_paragraphs_max
275 \expandafter\typo_paragraphs_stop_cell_nop
276 \else
277 \expandafter\typo_paragraphs_stop_cell_yes
278 \fi}
279
280\def\typo_paragraphs_stop_cell_nop
281 {\egroup
282 \endgroup}
283
284\def\typo_paragraphs_stop_cell_yes
285 {\ifvmode
286 \removelastskip
287 \else
288 \removeunwantedspaces
289 \endstrut
290 \endgraf
291 \fi
292 \paragraphsparameter\c!bottom
293 \egroup
294 \dontleavehmode\hpack{\raise\strutheight\box\scratchbox}
295 \endgroup}
296
297\def\typo_paragraphs_separator
298 {\scratchdistance{\paragraphsparameter\c!distance}
299 \ifcstok{\paragraphsparameter\c!rule}\v!on
300 \scratchwidth{\paragraphsparameter\c!rulethickness}
301 \scratchdistance{(\scratchdistance\scratchwidth)2}
302 \hskip\scratchdistance
303 \color[\paragraphsparameter\c!rulecolor]{\vrule\s!width\scratchwidth}
304 \fi
305 \hskip\scratchdistance}
306
307\protect \endinput
308 |