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