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