1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Spacing Macros Horizontal}
15
16
17
18\unprotect
19
20\registerctxluafile{spachor}{autosuffix}
21
22\ifdefined\parfillrightskip\else \aliased\let\parfillrightskip\parfillskip \fi
23
24\bitwiseflip \normalizelinemode \normalizelinenormalizecode
25\bitwiseflip \normalizelinemode \parindentskipnormalizecode
26\bitwiseflip \normalizelinemode \clipwidthnormalizecode
27\bitwiseflip \normalizelinemode \flattendiscretionariesnormalizecode
28\bitwiseflip \normalizelinemode \flattenhleadersnormalizecode
29
30
31\bitwiseflip \normalizeparmode \normalizeparnormalizeparcode
32\bitwiseflip \normalizeparmode \flattenvleadersnormalizeparcode
33
34\lettonothing\v_spac_indentation_current
35
36\newdimension\d_spac_indentation_par
37\parindent \d_spac_indentation_par
38
39\newconditional\c_spac_indentation_indent_first \c_spac_indentation_indent_first\conditionaltrue
40\newconstant \c_spac_indentation_toggle_state
41
42
43
44
45\permanent\protected\def\presetindentation
46 {\doifoutervmode{\ifconditional\c_spac_indentation_indent_first\else\spac_indentation_variant_no\fi}}
47
48\permanent\protected\def\setupindenting
49 {\doifelsenextoptionalcs\spac_indentation_setup_options\spac_indentation_setup_size}
50
51\permanent\protected\def\spac_indentation_setup_size
52 {\assigndimension\v_spac_indentation_current\d_spac_indentation_par{1\emwidth}{1.5\emwidth}{2\emwidth}
53 \ifzeropt\parindent\else
54 \parindent\d_spac_indentation_par\relax
55 \fi}
56
57\aliased\let\synchronizeindenting\spac_indentation_setup_size
58
59\lettonothing\m_spac_indentation_options
60
61\def\spac_indentation_setup_options[#1]
62 {\edef\m_spac_indentation_options{#1}
63 \ifempty\m_spac_indentation_options \else
64 \spac_indentation_setup_indeed
65 \fi}
66
67\def\spac_indentation_setup_indeed
68 {
69
70
71 \processcommacommand[\m_spac_indentation_options]\spac_indentation_apply_step_one
72 \processcommacommand[\m_spac_indentation_options]\spac_indentation_apply_step_two
73 \ifzeropt\parindent\else
74 \doifemptytoks\everypar\spac_indentation_set_everypar
75 \fi
76 \ifconditional\c_spac_indentation_indent_first
77 \spac_indentation_variant_yes
78 \else
79 \spac_indentation_variant_no
80 \fi
81 \spac_indentation_check_toggle}
82
83\def\spac_indentation_set_everypar
84 {\everypar{\checkindentation}}
85
86\permanent\protected\def\useindentingparameter#1
87 {\edef\m_spac_indentation_options{#1\c!indenting}
88 \ifempty\m_spac_indentation_options \else
89 \spac_indentation_setup_indeed
90 \fi}
91
92
93
94
95
96
97
98
99\installcorenamespace {indentingpreset}
100
101\permanent\tolerant\protected\def\defineindenting[#1]#*[#2]
102 {\ifarguments\else\edefcsname\??indentingpreset#1\endcsname{#2}\fi}
103
104\def\spac_indentation_apply_step_one_nested
105 {\expandafter\processcommacommand\expandafter[\lastnamedcs]\spac_indentation_apply_step_one}
106
107\def\spac_indentation_apply_step_two_nested
108 {\expandafter\processcommacommand\expandafter[\lastnamedcs]\spac_indentation_apply_step_two}
109
110\def\spac_indentation_apply_step_one#1
111 {\ifcsname\??indentingpreset#1\endcsname
112 \spac_indentation_apply_step_one_nested
113 \orelse\ifcsname\??indentingmethod#1\endcsname
114
115 \else
116 \edef\v_spac_indentation_current{#1}
117 \let\v_spac_indentation_normal\v_spac_indentation_current
118 \spac_indentation_setup_size
119 \fi}
120
121\def\spac_indentation_apply_step_two#1
122 {\ifcsname\??indentingpreset#1\endcsname
123 \spac_indentation_apply_step_two_nested
124 \orelse\ifcsname\??indentingmethod#1\endcsname
125 \lastnamedcs
126 \else
127
128 \fi}
129
130\permanent\protected\def\indenting
131 {\doifelsenextoptionalcs\spac_indentation_setup_options\relax}
132
133
134
135\installcorenamespace{indentingmethod}
136
137\permanent\protected\def\installindentingmethod#1#2
138 {\defcsname\??indentingmethod#1\endcsname{#2}}
139
140\installindentingmethod \v!no {\parindent\zeropoint}
141\installindentingmethod \v!not {\parindent\zeropoint}
142
143\installindentingmethod \v!first {\c_spac_indentation_indent_first\conditionaltrue}
144\installindentingmethod \v!next {\c_spac_indentation_indent_first\conditionalfalse}
145
146\installindentingmethod \v!yes {\parindent\d_spac_indentation_par\relax}
147\installindentingmethod \v!always{\parindent\d_spac_indentation_par\relax}
148
149\installindentingmethod \v!never {\parindent\zeropoint\relax
150 \c_spac_indentation_toggle_state\zerocount}
151
152\installindentingmethod \v!odd {\c_spac_indentation_toggle_state\plusone}
153\installindentingmethod \v!even {\c_spac_indentation_toggle_state\plustwo}
154
155\installindentingmethod \v!normal{\ifempty\v_spac_indentation_normal\else
156 \let\v_spac_indentation_current\v_spac_indentation_normal
157 \spac_indentation_setup_size
158 \fi}
159
160\installindentingmethod \v!reset {\c_spac_indentation_indent_first\conditionaltrue
161 \parindent\zeropoint
162 \c_spac_indentation_toggle_state\zerocount}
163
164\installindentingmethod \v!toggle{\parindent\ifzeropt\parindent
165 \d_spac_indentation_par
166 \else
167 \zeropoint
168 \fi\relax}
169
170\permanent\protected\def\noindenting{\indenting[\v!no, \v!next ]}
171\permanent\protected\def\doindenting{\indenting[\v!yes,\v!first]}
172
173
174
175
176
177\aliased\let\checkindentation\relax
178
179\installmacrostack\checkindentation
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198\def\spac_indentation_remove
199 {\ifzeropt\parindent \else
200 \undent
201 \fi}
202
203\def\spac_indentation_kill_indeed
204 {
205 \spac_indentation_remove}
206
207\permanent\protected\def\spac_indentation_do_toggle_indeed
208 {
209 \enforced\glet\checkindentation\spac_indentation_no_toggle_indeed
210 \spac_indentation_remove}
211
212\permanent\protected\def\spac_indentation_no_toggle_indeed
213 {
214 \enforced\glet\checkindentation\spac_indentation_do_toggle_indeed}
215
216\permanent\protected\def\spac_indentation_do_indeed
217 {}
218
219\permanent\protected\def\spac_indentation_do_toggle
220 {\enforced\glet\checkindentation\spac_indentation_do_toggle_indeed}
221
222\permanent\protected\def\spac_indentation_no_toggle
223 {\enforced\glet\checkindentation\spac_indentation_no_toggle_indeed}
224
225\permanent\protected\def\spac_indentation_check_toggle
226 {\ifcase\c_spac_indentation_toggle_state
227
228 \or
229 \spac_indentation_no_toggle
230 \or
231 \spac_indentation_do_toggle
232 \fi}
233
234\permanent\protected\def\spac_indentation_variant_yes
235 {\enforced\glet\checkindentation\spac_indentation_do_indeed}
236
237\permanent\protected\def\spac_indentation_no_next_check
238 {\spac_indentation_remove
239 \enforced\glet\checkindentation\spac_indentation_do_indeed}
240
241\permanent\protected\def\spac_indentation_variant_no
242 {\ifinpagebody \else
243
244 \enforced\glet\checkindentation\spac_indentation_no_next_check
245 \fi}
246
247\permanent\protected\def\nonoindentation
248 {\ifinpagebody \else
249
250 \enforced\glet\checkindentation\spac_indentation_do_indeed
251 \fi}
252
253\permanent\protected\def\spac_indentation_variant_force
254 {\ifvmode \ifzeropt\parindent \else
255
256
257
258 \noindent\hskip\parindent
259 \fi \fi}
260
261
262
263\aliased\let\indentation \spac_indentation_variant_force
264\aliased\let\noindentation\spac_indentation_variant_no
265\aliased\let\doindentation\spac_indentation_variant_yes
266
267\permanent\protected\def\dontrechecknextindentation
268 {\global\enforced\let\dorechecknextindentation\relax}
269
270\aliased\let\dorechecknextindentation\relax
271
272
273
274
275
276\permanent\protected\def\spac_indentation_check_next_indentation
277 {\global\enforced\let\dorechecknextindentation\relax
278 \begingroup
279 \autoparagraphmode\zerocount
280 \doifelsenextchar\par\endgroup{\endgroup\spac_indentation_variant_no}}
281
282\def\spac_indentation_variant_auto
283 {\global\enforced\let\dorechecknextindentation\spac_indentation_check_next_indentation}
284
285
286
287
288\installcorenamespace{indentnext}
289
290\permanent\protected\def\checknextindentation[#1]
291 {\begincsname\??indentnext#1\endcsname}
292
293\permanent\protected\def\useindentnextparameter#1
294 {\edef\p_indentnext{#1\c!indentnext}
295 \ifempty\p_indentnext\else
296 \begincsname\??indentnext\p_indentnext\endcsname
297 \fi}
298
299\letcsname\??indentnext \endcsname\donothing
300\letcsname\??indentnext\v!yes \endcsname\spac_indentation_variant_yes
301\letcsname\??indentnext\v!no \endcsname\spac_indentation_variant_no
302\letcsname\??indentnext\v!auto\endcsname\spac_indentation_variant_auto
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343\permanent\protected\def\forgetparindent
344 {\c_spac_indentation_indent_first\conditionaltrue
345 \d_spac_indentation_par\zeropoint
346 \parindent\zeropoint
347 \let\v_spac_indentation_current\v!none}
348
349\appendtoks
350 \forgetparindent
351\to \everyforgetall
352
353\permanent\protected\def\forgethorizontalstretch
354 {\emergencystretch\zeropoint}
355
356\appendtoks
357 \forgethorizontalstretch
358\to \everyforgetall
359
360
361
362\permanent\protected\def\softbreak
363 {\relax\ifhmode\hskip\parfillskip\break\fi}
364
365
366
367
368
369
370
371
372
373
374\installcorenamespace{spacecodemethod}
375
376\sfcode\)=\zerocount
377\sfcode\'=\zerocount
378\sfcode\]=\zerocount
379
380\def\spac_spacecodes_set_fixed#1
381 {\sfcode\.#1\relax \sfcode\,#1\relax
382 \sfcode\?#1\relax \sfcode\!#1\relax
383 \sfcode\:#1\relax \sfcode\;#1\relax}
384
385\def\spac_spacecodes_set_stretch
386 {\sfcode\.3000 \sfcode\,1250
387 \sfcode\?3000 \sfcode\!3000
388 \sfcode\:2000 \sfcode\;1500 }
389
390\permanent\protected\def\frenchspacing {\spac_spacecodes_set_fixed\plusthousand}
391\permanent\protected\def\newfrenchspacing{\spac_spacecodes_set_fixed{1050}}
392\permanent\protected\def\nonfrenchspacing{\spac_spacecodes_set_stretch}
393
394\permanent\protected\def\installspacingmethod#1#2{\defcsname\??spacecodemethod#1\endcsname{#2}}
395
396\installspacingmethod \empty {}
397\installspacingmethod \v!fixed {\frenchspacing }
398\installspacingmethod \v!packed {\newfrenchspacing}
399\installspacingmethod \v!broad {\nonfrenchspacing}
400
401\permanent\tolerant\protected\def\setupspacing[#1]
402 {\ifarguments\or
403 \begincsname\??spacecodemethod#1\endcsname
404 \fi
405 \updateraggedskips}
406
407
408
409\permanent\protected\def\fsp#1
410 {#1
411 \ifchknum#1\or
412 \spacefactor\plusthousand
413 \fi}
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434\permanent\protected\def\synchronizespacecodes{\updateraggedskips}
435
436
437
438
439
440
441
442
443
444\aliased\let\normalspaceprimitive=\
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463\permanent\protected\def\specialspaceprimitive
464 {
465 \ifhmode
466 \spacefactor\plusthousand
467 \else
468 \dontleavehmode
469 \fi
470 \normalspaceprimitive}
471
472
473
474
475\permanent\protected\def\normalnotobeyedspace
476 {\ifmmode\normalspaceprimitive\else\specialspaceprimitive\fi}
477
478\pushoverloadmode
479
480\overloaded\let\ =\normalnotobeyedspace
481
482\popoverloadmode
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505\permanent\protected\def\nonbreakablespace{\penalty\plustenthousand\normalspaceprimitive}
506
507\letcatcodecommand \ctxcatcodes \tildeasciicode \nonbreakablespace
508
509
510\permanent\protected\def\removelastspace{\ifhmode\unskip\fi}
511\permanent\protected\def\nospace {\removelastspace\ignorespaces}
512
513\ifdefined\nospaces
514 \permanent\protected\def\nospacing{\normalnospaces\plusone}
515 \permanent\protected\def\dospacing{\normalnospaces\zerocount}
516\else
517 \permanent\protected\def\nospacing{\spaceskip\scaledpoint \xspaceskip\zeroskip}
518 \permanent\protected\def\dospacing{\spaceskip\currentspaceskip\xspaceskip\zeroskip}
519\fi
520
521\ifdefined\softhyphen \else
522 \let\softhyphen\explicitdiscretionary
523\fi
524
525
526
527\cldcontext{"\string\\protected\string\\def\string\\\string\n{\string\\space}"}
528
529
530
531
532
533
534
535
536\permanent\protected\def\fixedspace
537 {\setbox\scratchbox\hpack{\mathortext{0}{0}}
538 \hskip\wd\scratchbox\relax}
539
540\permanent\protected\def\fixedspaces
541 {\letcatcodecommand \ctxcatcodes \tildeasciicode\fixedspace
542
543 \enforced\letcharcode\tildeasciicode\fixedspace}
544
545\appendtoks
546
547 \enforced\letcharcode\tildeasciicode\space
548 \enforced\let\ \space
549\to \everysimplifycommands
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579\newboundary\c_spac_keepspaces_boundary
580
581\permanent\protected\def\keepunwantedspaces
582 {\ifhmode\ifnum\lastboundary=\c_spac_keepspaces_boundary\else
583 \boundary\c_spac_keepspaces_boundary
584 \fi\fi}
585
586\permanent\protected\def\removeunwantedspaces
587 {\ifhmode
588 \expandafter \spac_helpers_remove_unwantedspace
589 \fi}
590
591\def\spac_helpers_remove_unwantedspace
592 {\ifnum\lastboundary=\c_spac_keepspaces_boundary
593 \expandafter\unboundary
594 \orunless\ifnum\lastnodetype=\gluenodecode
595
596 \orelse\ifnum\lastnodesubtype=\indentskipsubtypecode
597
598 \else
599 \unskip
600 \expandafter\spac_helpers_remove_unwantedspace
601 \fi}
602
603\permanent\protected\def\onlynonbreakablespace
604 {\ifdim\lastskip=\interwordspace
605 \unskip
606 \nonbreakablespace
607 \fi
608 \ignorespaces}
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634\ifdefined\enspace \else \permanent\protected\def\enspace{\kern .5\emwidth} \fi
635\ifdefined\emspace \else \permanent\protected\def\emspace{\kern \emwidth} \fi
636
637\ifdefined\quad \else \permanent\protected\def\quad {\hskip \emwidth\relax} \fi
638\ifdefined\enskip \else \permanent\protected\def\enskip {\hskip.5\emwidth\relax} \fi
639\ifdefined\qquad \else \permanent\protected\def\qquad {\hskip 2\emwidth\relax} \fi
640
641\permanent\protected\def\negenspace{\kern.5\emwidth}
642\permanent\protected\def\negemspace{\kern \emwidth}
643
644
645
646\permanent\protected\def\charspace{ }
647
648\permanent\tolerant\protected\def\quads[#1]
649 {\dontleavehmode
650 \begingroup
651
652 \scratchcounter\ifchknumber#1\or\lastchknumber\else\plusthree\fi
653 \zwj\dorecurse\scratchcounter{\hskip\emwidth\zwj}
654 \endgroup}
655
656
657
658\permanent\protected\def\rapfillskip{.5\hsize plus .092\hsize minus .5\hsize}
659
660
661
662\newgluespec\s_spac_fi \s_spac_fi \zeropoint \s!plus 1\s!fi \relax
663\newgluespec\s_spac_fil \s_spac_fil \zeropoint \s!plus 1\s!fil \relax
664\newgluespec\s_spac_fill \s_spac_fill \zeropoint \s!plus 1\s!fill \relax
665\newgluespec\s_spac_filll \s_spac_filll \zeropoint \s!plus 1\s!filll\relax
666
667\newgluespec\s_spac_neg_fi \s_spac_neg_fi \zeropoint \s!plus1\s!fi \relax
668\newgluespec\s_spac_neg_fil \s_spac_neg_fil \zeropoint \s!plus1\s!fil \relax
669\newgluespec\s_spac_neg_fill \s_spac_neg_fill \zeropoint \s!plus1\s!fill \relax
670\newgluespec\s_spac_neg_filll \s_spac_neg_filll \zeropoint \s!plus1\s!filll\relax
671
672\permanent\protected\untraced\def\hfilll {\hskip\s_spac_filll\relax}
673\permanent\protected\untraced\def\vfilll {\vskip\s_spac_filll\relax}
674
675\permanent\protected\untraced\def\hfillneg {\hskip\s_spac_neg_fill \relax}
676\permanent\protected\untraced\def\hfilllneg{\hskip\s_spac_neg_filll\relax}
677\permanent\protected\untraced\def\vfillneg {\vskip\s_spac_neg_fill \relax}
678\permanent\protected\untraced\def\vfilllneg{\vskip\s_spac_neg_filll\relax}
679
680\permanent\protected\def\tfskip {\begingroup\tf\hskip\emwidth\endgroup}
681\permanent\protected\def\dotfskip#1{\begingroup\tf\hskip #1\endgroup}
682
683
684
685\installcorenamespace{narrower}
686\installcorenamespace{narrowermethod}
687
688\newgluespec\s_spac_narrower_left
689\newgluespec\s_spac_narrower_right
690\newgluespec\s_spac_narrower_middle
691
692\installcommandhandler \??narrower {narrower} \??narrower
693
694\setupnarrower
695 [\c!before=\endgraf,
696 \c!after=\endgraf,
697 \c!left=1.5\emwidth,
698 \c!right=1.5\emwidth,
699 \c!middle=1.5\emwidth,
700 \c!default=\v!middle]
701
702\appendtoks
703 \frozen\instance\protected\edefcsname\e!start\currentnarrower\endcsname{\spac_narrower_start[\currentnarrower]}
704 \frozen\instance\protected\edefcsname\e!stop \currentnarrower\endcsname{\spac_narrower_stop}
705\to \everydefinenarrower
706
707\permanent\protected\def\installnarrowermethod#1#2
708 {\defcsname\??narrowermethod#1\endcsname{#2}}
709
710\protected\def\spac_narrower_method_analyze#1
711 {\ifcsname\??narrowermethod#1\endcsname
712 \lastnamedcs
713 \else
714 \global\advanceby\s_spac_narrower_middle#1\relax
715 \fi}
716
717\def\spac_narrower_initialize[#1]
718 {\dorepeatwithcommand[#1]\spac_narrower_method_analyze}
719
720\installnarrowermethod \v!left {\global\advanceby\s_spac_narrower_left \narrowerparameter\c!left \relax}
721\installnarrowermethod \v!middle {\global\advanceby\s_spac_narrower_middle \narrowerparameter\c!middle\relax}
722\installnarrowermethod \v!right {\global\advanceby\s_spac_narrower_right \narrowerparameter\c!right \relax}
723\installnarrowermethod{\v!left }{\global\advanceby\s_spac_narrower_left \narrowerparameter\c!left \relax}
724\installnarrowermethod{\v!middle}{\global\advanceby\s_spac_narrower_middle\narrowerparameter\c!middle\relax}
725\installnarrowermethod{\v!right }{\global\advanceby\s_spac_narrower_right \narrowerparameter\c!right \relax}
726\installnarrowermethod \v!reset {\global \s_spac_narrower_left \zeroskip
727 \global \s_spac_narrower_middle \zeroskip
728 \global \s_spac_narrower_right \zeroskip\relax}
729\installnarrowermethod \v!none {}
730\installnarrowermethod \v!reverse {}
731
732\permanent\overloaded\tolerant\protected\def\spac_narrower_start[#1]#*[#2]
733 {\begingroup
734 \cdef\currentnarrower{#1}
735 \ifparameter#2\or
736 \spac_narrower_start_apply{#2}
737 \else
738 \spac_narrower_start_apply{\narrowerparameter\v!default}
739 \fi}
740
741\newgluespec \s_spac_narrower_left_last
742\newgluespec \s_spac_narrower_right_last
743\newconditional\s_spac_narrower_last_swap
744
745\def\spac_narrower_start_apply#1
746 {\narrowerparameter\c!before
747 \global\s_spac_narrower_left \zeroskip
748 \global\s_spac_narrower_right \zeroskip
749 \global\s_spac_narrower_middle\zeroskip
750 \edef\scratchstringone{#1}
751 \ifx\scratchstringone\v!reverse
752 \ifconditional\s_spac_narrower_last_swap
753 \frozen\leftskip \s_spac_narrower_right_last
754 \frozen\rightskip\s_spac_narrower_left_last
755 \s_spac_narrower_last_swap\conditionalfalse
756 \else
757 \frozen\leftskip \s_spac_narrower_left_last
758 \frozen\rightskip\s_spac_narrower_right_last
759 \s_spac_narrower_last_swap\conditionaltrue
760 \fi
761 \else
762 \normalexpanded{\processcommalistwithparameters[\scratchstringone]}\spac_narrower_initialize
763 \frozen\advanceby\leftskip \dimexpr\s_spac_narrower_left \s_spac_narrower_middle\relax
764 \frozen\advanceby\rightskip\dimexpr\s_spac_narrower_right\s_spac_narrower_middle\relax
765 \fi
766 \seteffectivehsize}
767
768\permanent\protected\def\spac_narrower_stop
769 {\narrowerparameter\c!after
770 \normalexpanded{
771 \endgroup
772 \s_spac_narrower_left_last \the\leftskip \relax
773 \s_spac_narrower_right_last\the\rightskip\relax
774 \ifconditional\s_spac_narrower_last_swap
775 \s_spac_narrower_last_swap\conditionalfalse
776 \else
777 \s_spac_narrower_last_swap\conditionaltrue
778 \fi
779 }}
780
781\permanent\tolerant\protected\def\startnarrower[#1]
782 {\begingroup
783 \lettonothing\currentnarrower
784 \ifparameter#1\or
785 \spac_narrower_start_apply{#1}
786 \else
787 \spac_narrower_start_apply{\narrowerparameter\v!default}
788 \fi}
789
790\aliased\let\stopnarrower\spac_narrower_stop
791
792\permanent\tolerant\protected\def\startnarrow[#S#1]#*[#S#2]
793 {\begingroup
794 \ifnum\lastarguments=\plustwo
795 \expandafter\spac_narrower_start_named_two
796 \else
797 \expandafter\spac_narrower_start_named_one
798 \fi[#1][#2]}
799
800
801
802\def\spac_narrower_start_named_one[#S#1]
803 {\doifelseassignment{#1}\spac_narrower_start_named_one_yes\spac_narrower_start_named_one_nop[#1]}
804
805\def\spac_narrower_start_named_one_yes[#S#1][#2]
806 {\setupcurrentnarrower[#1]
807 \spac_narrower_start_apply{\narrowerparameter\v!default}}
808
809\def\spac_narrower_start_named_one_nop[#1][#2]
810 {\cdef\currentnarrower{#1}
811 \spac_narrower_start_apply{\narrowerparameter\v!default}}
812
813\def\spac_narrower_start_named_two[#S#1]
814 {\doifelseassignment{#1}\spac_narrower_start_named_settings_how\spac_narrower_start_named_tag_unknown[#1]}
815
816\def\spac_narrower_start_named_settings_how[#S#1][#2]
817 {\setupcurrentnarrower[#1]
818 \spac_narrower_start_apply{#2}}
819
820\def\spac_narrower_start_named_tag_unknown[#1][#S#2]
821 {\doifelseassignment{#2}\spac_narrower_start_named_tag_settings\spac_narrower_start_named_tag_how[#1][#2]}
822
823\def\spac_narrower_start_named_tag_settings[#1][#S#2]
824 {\cdef\currentnarrower{#1}
825 \setupcurrentnarrower[#2]
826 \spac_narrower_start_apply{\narrowerparameter\v!default}}
827
828\def\spac_narrower_start_named_tag_how[#1][#2]
829 {\cdef\currentnarrower{#1}
830 \spac_narrower_start_apply{#2}}
831
832\aliased\let\stopnarrow\spac_narrower_stop
833
834\newdimension\d_spac_effective_hsize \permanent\protected\def\effectivehsize {\hsize}
835\newdimension\d_spac_effective_leftskip \permanent\protected\def\effectiveleftskip {\dimexpr\leftskip \relax}
836\newdimension\d_spac_effective_rightskip \permanent\protected\def\effectiverightskip{\dimexpr\rightskip\relax}
837
838\permanent\protected\def\seteffectivehsize
839 {\setlocalhsize
840 \d_spac_effective_hsize \localhsize
841 \d_spac_effective_leftskip 1\leftskip
842 \d_spac_effective_rightskip1\rightskip
843 \enforced\let\effectivehsize \d_spac_effective_hsize
844 \enforced\let\effectiveleftskip \d_spac_effective_leftskip
845 \enforced\let\effectiverightskip\d_spac_effective_rightskip}
846
847\installcorenamespace{skipadaptionleft}
848\installcorenamespace{skipadaptionright}
849
850\newgluespec\leftskipadaption
851\newgluespec\rightskipadaption
852
853\defcsname\??skipadaptionleft \v!yes\endcsname{\ifzeropt\d_spac_indentation_par\narrowerparameter\c!left\else\d_spac_indentation_par\fi}
854\letcsname\??skipadaptionleft \v!no \endcsname\zeropoint
855\letcsname\??skipadaptionleft \empty\endcsname\zeropoint
856\defcsname\??skipadaptionright\v!yes\endcsname{\narrowerparameter\c!right}
857\letcsname\??skipadaptionright\v!no \endcsname\zeropoint
858\letcsname\??skipadaptionright\empty\endcsname\zeropoint
859
860\letcsname\??skipadaptionleft \v!standard\expandafter\endcsname\csname\??skipadaptionleft \v!yes\endcsname
861\letcsname\??skipadaptionright\v!standard\expandafter\endcsname\csname\??skipadaptionright\v!yes\endcsname
862
863\permanent\protected\def\dosetleftskipadaption #1{\leftskipadaption \ifcsname\??skipadaptionleft #1\endcsname\lastnamedcs\else#1\fi\relax}
864\permanent\protected\def\dosetrightskipadaption#1{\rightskipadaption\ifcsname\??skipadaptionright#1\endcsname\lastnamedcs\else#1\fi\relax}
865
866\permanent\protected\def\doadaptleftskip #1{\normalexpanded{\dosetleftskipadaption {#1}}\frozen\advanceby\leftskip \leftskipadaption }
867\permanent\protected\def\doadaptrightskip#1{\normalexpanded{\dosetrightskipadaption{#1}}\frozen\advanceby\rightskip\rightskipadaption}
868
869\permanent\protected\def\forgetbothskips
870 {\leftskip \zeroskip
871 \rightskip\zeroskip
872 \relax}
873
874\appendtoks
875 \forgetbothskips
876\to \everyforgetall
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891\installcorenamespace{tolerancemethods}
892
893\mutable\lettonothing\bottomtolerance
894
895\permanent\protected\def\installtolerancemethod#1#2#3
896 {\defcsname\??tolerancemethods#1:#2\endcsname{#3}}
897
898\installtolerancemethod \v!vertical \v!verystrict {\lettonothing\bottomtolerance}
899\installtolerancemethod \v!vertical \v!strict {\def\bottomtolerance{.050}}
900\installtolerancemethod \v!vertical \v!tolerant {\def\bottomtolerance{.075}}
901\installtolerancemethod \v!vertical \v!verytolerant {\def\bottomtolerance{.100}}
902
903\installtolerancemethod \v!horizontal \v!stretch {\emergencystretch\bodyfontsize\relax}
904\installtolerancemethod \v!horizontal \v!space {\spaceskip.5em\s!plus.25em\s!minus.25em\relax}
905\installtolerancemethod \v!horizontal \v!verystrict {\tolerance\plustwohundred}
906\installtolerancemethod \v!horizontal \v!strict {\tolerance1500 }
907\installtolerancemethod \v!horizontal \v!tolerant {\tolerance3000 }
908\installtolerancemethod \v!horizontal \v!verytolerant {\tolerance4500 }
909
910\appendetoks
911 \pretolerance\plushundred
912 \tolerance \plustwohundred
913\to\everyforgetall
914
915\def\spac_tolerances_step_vertical #1{\csname\??tolerancemethods\v!vertical :#1\endcsname}
916\def\spac_tolerances_step_horizontal#1{\csname\??tolerancemethods\v!horizontal:#1\endcsname}
917
918\permanent\tolerant\protected\def\setuptolerance[#1]
919 {\ifarguments\or
920 \ifinset\v!vertical{#1}
921 \processcommacommand[#1]\spac_tolerances_step_vertical
922 \else
923 \processcommacommand[#1]\spac_tolerances_step_horizontal
924 \fi
925 \fi}
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017\permanent\protected\def\justonespace{\removeunwantedspaces\space}
1018
1019
1020
1021\installcorenamespace{hspace}
1022
1023\permanent\protected\def\ignorecrlf
1024 {\enforced\let\crlf\justonespace
1025 \enforced\let\\\crlf}
1026
1027\permanent\tolerant\protected\def\definehspace[#1]#*[#2]#*[#3]
1028 {\ifparameter#3\or
1029 \defcsname\??hspace#1:#2\endcsname{#3}
1030 \else
1031 \defcsname\??hspace :#1\endcsname{#2}
1032 \fi}
1033
1034\permanent\tolerant\protected\def\hspace[#1]#*[#2]
1035 {\ifhmode
1036 \removeunwantedspaces
1037 \hskip
1038 \ifparameter#2\or
1039 \hspaceamount{#1}{#2}
1040 \orelse\ifparameter#1\or
1041 \hspaceamount\empty{#1}
1042 \else
1043 \hspaceamount\empty\s!default
1044 \fi
1045 \relax
1046 \expandafter\ignorespaces
1047 \fi}
1048
1049\permanent\overloaded\def\hspaceamount #1#2{\dimexpr\ifcsname\??hspace#1:#2\endcsname\lastnamedcs\else\zeropoint\fi\relax}
1050\permanent\overloaded\def\directhspaceamount #1{\dimexpr\ifcsname\??hspace :#1\endcsname\lastnamedcs\else\zeropoint\fi\relax}
1051
1052
1053
1054\definehspace [\v!small] [.25\emspaceamount]
1055\definehspace [\v!medium] [.5\emspaceamount]
1056\definehspace [\v!big] [1\emspaceamount]
1057\definehspace [\v!normal] [1\spaceamount]
1058\definehspace [\v!default] [\spaceamount]
1059\definehspace [\v!none] [\zeropoint]
1060
1061
1062
1063
1064\permanent\protected\def\textormathspace #1#2#3{\ifmmode\mskip#1#2\else\kern #1\hspaceamount\empty{#3}\fi\relax}
1065\permanent\protected\def\textormathspacecommand #1#2#3{\ifmmode\mskip#1#2\else#3\fi\relax}
1066\permanent\protected\def\breakabletextormathspace#1#2#3{\ifmmode\mskip#1#2\else\hskip#1\hspaceamount\empty{#3}\fi\relax}
1067
1068\overloaded\permanent\protected \def\hairspace {\textormathspace\hairmuskip{.5}}
1069\overloaded\permanent\protected \def\thinspace {\textormathspace\thinmuskip 1}
1070
1071\overloaded\permanent\protected \def\thickspace {\textormathspace\thickmuskip3}
1072\overloaded\permanent\protected \def\neghairspace {\textormathspace\thinmuskip{.5}}
1073\overloaded\permanent\protected \def\negthinspace {\textormathspace\thinmuskip 1}
1074\overloaded\permanent\protected \def\negmedspace {\textormathspace\medmuskip 2}
1075\overloaded\permanent\protected \def\negthickspace{\textormathspace\thickmuskip3}
1076\overloaded\permanent\protected\edef\medspace {\textormathspacecommand\medmuskip{\tocharacter"205F}}
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095\definehspace[.5][.1250\emwidth]
1096\definehspace[1] [.1667\emwidth]
1097\definehspace[2] [.2222\emwidth]
1098\definehspace[3] [.2777\emwidth]
1099
1100
1101
1102\suggestedalias \, \thinspace
1103\suggestedalias \: \medspace
1104\suggestedalias \; \thickspace
1105\suggestedalias \! \negthinspace
1106
1107
1108
1109
1110
1111
1112\permanent\def\flexiblespaceamount#1#2#3
1113 {#1\interwordspace
1114 \s!plus#2\interwordstretch
1115 \s!minus#3\interwordshrink}
1116
1117\permanent\def\fixedspaceamount#1
1118 {#1\interwordspace}
1119
1120
1121
1122
1123
1124
1125
1126\installcorenamespace{spacemethods}
1127
1128\permanent\protected\def\installspacemethod#1#2
1129 {\defcsname\??spacemethods#1\endcsname{#2}}
1130
1131\permanent\def\activatespacehandler#1
1132 {\csname\??spacemethods\ifcsname\??spacemethods#1\endcsname#1\else\v!off\fi\endcsname}
1133
1134\permanent\protected\def\spac_spaces_checked_control{\mathortext\normalspace{\dontleavehmode{\tt\controlspace}}}
1135\permanent\protected\def\spac_spaces_checked_normal {\mathortext\normalspace{\dontleavehmode\normalspace}}
1136\permanent\protected\def\spac_spaces_checked_fixed {\mathortext\normalspace{\dontleavehmode\fixedspace}}
1137
1138
1139
1140\installspacemethod \v!on
1141 {\obeyspaces
1142 \enforced\let\obeyedspace\spac_spaces_checked_control
1143 \enforced\let\ =\obeyedspace}
1144
1145\installspacemethod \v!yes
1146 {\obeyspaces
1147 \enforced\let\obeyedspace\spac_spaces_checked_normal
1148 \enforced\let\ =\obeyedspace}
1149
1150\installspacemethod \v!off
1151 {\normalspaces
1152 \enforced\let\obeyedspace\normalspace
1153 \enforced\let\ =\normalspaceprimitive}
1154
1155\installspacemethod \v!fixed
1156 {\obeyspaces
1157 \enforced\let\obeyedspace\spac_spaces_checked_fixed
1158 \enforced\let\ =\obeyedspace}
1159
1160\appendtoks
1161 \normalspaces
1162\to \everybeforeoutput
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179\permanent\protected\def\outdented#1
1180 {\hskip\hangindent#1\relax}
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192\def\spac_glues_text_or_math#1#2
1193 {\begingroup
1194 \ifmmode
1195 \mskip#1
1196 \else
1197 \scratchdimen#1\hspaceamount\empty{#2}
1198 \scratchskip\scratchdimen\s!plus.5\scratchdimen\s!minus.3\scratchdimen
1199 \hskip\scratchskip
1200 \fi
1201 \endgroup}
1202
1203\permanent\protected\def\thinglue {\spac_glues_text_or_math\thinmuskip \v!small}
1204\permanent\protected\def\medglue {\spac_glues_text_or_math\medmuskip \v!medium}
1205\permanent\protected\def\thickglue{\spac_glues_text_or_math\thickmuskip\v!big}
1206
1207
1208
1209\permanent\protected\def\widened
1210 {\doifelsenextoptionalcs\spac_widened_yes\spac_widened_nop}
1211
1212\def\spac_widened_yes[#1]#2{\hbox \s!spread #1{\hss#2\hss}}
1213\def\spac_widened_nop #1{\hbox \s!spread \emwidth{\hss#1\hss}}
1214
1215
1216
1217\permanent\protected\def\ignoredlinebreak{\unskip\space\ignorespaces}
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264\permanent\protected\def\startignorespaces
1265 {\pushmacro\nospaces
1266 \nospaces\plusone}
1267
1268\permanent\protected\def\stopignorespaces
1269 {\popmacro\nospaces}
1270
1271
1272
1273
1274\permanent\def\obeyfollowingtoken{{}}
1275
1276
1277
1278\permanent\protected\def\interwordspacebefore{\wordboundary\zwnj\hskip\interwordspace\relax}
1279\permanent\protected\def\interwordspaceafter {\hskip\interwordspace\relax\zwnj\wordboundary}
1280
1281\permanent\protected\def\interwordspacesbefore#1{\dofastloopcs{#1}\interwordspacebefore}
1282\permanent\protected\def\interwordspacesafter #1{\dofastloopcs{#1}\interwordspaceafter}
1283\permanent\protected\def\interwordspaces #1{\wordboundary\zwnj\dofastloopcs{\numexpr#1\minusone}\interwordspaceafter}
1284
1285
1286
1287\installcorenamespace{mplocation}
1288
1289\defcsname\??mplocation\v!left \endcsname{1}
1290\defcsname\??mplocation\v!right\endcsname{2}
1291\defcsname\??mplocation\v!inner\endcsname{3}
1292\defcsname\??mplocation\v!outer\endcsname{4}
1293
1294\permanent\def\mplocation#1{\ifcsname\??mplocation#1\endcsname\lastnamedcs\else0\fi}
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306\protect \endinput
1307 |