forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexamplep.sty
2898 lines (2799 loc) · 125 KB
/
examplep.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
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
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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
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
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
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
643
644
645
646
647
648
649
650
651
652
653
654
655
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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
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
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
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
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
%
% examplep.sty -- typesetting verbatim TeX code and examples
% by [email protected] at Sat Sep 27 23:58:14 CEST 2003
% -- Sun Sep 28 23:38:37 CEST 2003
% ligatures broken -- Tue Sep 30 19:14:11 CEST 2003
% examplep.sty at Fri Oct 24 10:25:27 CEST 2003
% options and misc stuff at Fri Oct 24 22:23:06 CEST 2003
% xalign=, yalign= fixes, *-test.tex at Wed Dec 24 02:33:24 CET 2003
% baseline-grid=, fixes at Wed Feb 25 23:37:41 CET 2004
%
% This program is free software; you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation; either version 2 of the License, or
% (at your option) any later version.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
% GNU General Public License for more details.
%
% This is a LaTeX package that provides following features:
%
% -- a robust \PVerb macro comparable to the LaTeX \verb macro
% -- \begin{PSource} comparable to the LaTeX \begin{verbatim} environment
% -- \begin{WSource} comparable to \begin{verbwrite} in sverb.sty
% and \begin{filecontents} of latex.ltx
% -- \begin{PWSource} combining \begin{PSource} and \begin{WSource}
% -- \begin{PexaMiniPage} comparable to the LaTeX \begin{minipage} environment
% -- \PexaShowBoth that typesets LaTeX code, and also shows it verbatim;
% facing and page breaks enabled (!)
% -- package load options can be specified \usepacakge[...]{examplep}
% See samplewidth= in this file for the load option defaults. Use
% \PexaDefaults{...} instead of \usepackage[...]{examplep} to specify
% complicated options such as linenumberformat={...} (this is a LaTeX kernel
% limitation.)
% -- some more, see eurotex_2005_examplep.tex
%
% !! func-tion better hyphenation point in \Q than functi-on
% !! after \end{PSource} in pts_diploma.tex, don't require \noindent
% !! option to emit tabs as spaces
% !! allow wider Source if Sample is small enough
% !! \ifnum0=`{\fi} and similar tricks for \halign?
% !! why is it called twice?
% \def\pexa@cverb@@verbatimfont{u\normalfont\ttfamily
% \hyphenpenalty10000 }
% !! why doesn't \selectlanguage works inside \begin{PSource}[srcstyle=leftboth]
% !! \PVerb{foo} mustn't insert $\lnot$ if foo is at EOL
% !! \ifvmode testing for \PSource
% !! \PVerb{...} inner unnested braces (\futurelet?)
% !! \penalty in \PVerb
% !! \pexa@ss@left etc. should work with \PexaShowBoth (not for measuring)
% !! \@afterindenttrue etc.
% !! ASCII tab (9) characters aren't supported properly
% !! \begin{PSource} says 'Missing $ inserted.' in magyarldf-doc.tex:
% \begin{PSource}[srcstyle=leftboth]
% \grq~\glq~\glqq~\grqq~\flq~\frq~\flqq~\frqq\\
% \textquoteright~\textquotedblright\\
% \textquoteleft~\textquotedblleft\\
% \end{PSource}
% !! yalign=u \includegraphics too high, line break after 1st Source line,
% will make it it higher on the previous page (same problem sometimes
% with yalign=v)
% !! \texttt{÷#÷} ! Illegal parameter number in definition of \reserved@a.
% !! report Overfull \hbox for \begin{PSource}[srcstyle=leftnumcol,firstlinenum=8]
% Imp: \PVerb with listings
% Imp: make # work in srcstyle=leftboth (and srcstyle=leftleft?)
% Dat: multiple spaces count inside \PVerb+...+, even at line break
% Dat: it is impossible to indent the first line via \begin{WSource} etc.
% without [OPTIONS], because verbfwr.sty chops heading spaces
% Dat: 5000..9999 lines of \halign containing only `(9999)\hfil\cr' will fill
% up TeX's memory (! TeX capacity exceeded, sorry [main memory size=263001].),
% so text fed to \PexaShowBoth shouldn't exceed 375 lines (with an
% average line length of 80 characters) Dat: numbers outdated, see
% eurotex_2005_examplep.tex
% Imp: page breaks near \FBHLastDepth put a too tall \vrule on next page
% Dat: accented letters in listings.sty Source of \PexaShowBoth do not work:
% \begin{WBoth}
% "á"
% \end{WBoth}
% \PexaShowBoth{listings={language=c},srcstyle=leftnumcol}
% prints "^^e1" to the source field
% The same problem with \PexaShowBoth
% Imp: make \TeX parse ^^, use \meaning later
% OK : magyarldf-doc.tex infinite bug, corrected
%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{examplep}[2003/10/23 v0.02 Verbatim and typeset TeX code]
\edef\pexa@@restorecat{%
\catcode\string`\string`\the\catcode\string``\space\space
\catcode\string`\string$\the\catcode\string`$\space\space}
\catcode\string``12 % may have been changed by Babel
\catcode`$3
\RequirePackage{verbfwr}
% ---
\def\pexa@@samplename{pexa-sam.tex}
\def\pexa@@sourcename{pexa-src.tex}
\let\pexa@@cursourcename\pexa@@samplename
\def\pexa@dohex#1{%
\if\noexpand#1^%
\expandafter\pexa@dohex@lowa
\else\char"5E \expandafter#1\fi
}
\def\pexa@swaprelax#1#2\relax{#2#1}
%\def\pexa@swap#1#2{#2#1}% SUXX, doesn't evaluate \else correctly
%** Dat: would be too late for ^^#1#2
%** Dat: doesn't restore ^^09, because \write emits ^^I instead of ^^09
\def\pexa@dohex@lowa#1{%
\if\noexpand#18\pexa@swaprelax{\pexa@dohex@lowc 8}%
\else\if\noexpand#19\pexa@swaprelax{\pexa@dohex@lowc 9}%
\else\if\noexpand#1a\pexa@swaprelax{\pexa@dohex@lowc A}%
\else\if\noexpand#1b\pexa@swaprelax{\pexa@dohex@lowc B}%
\else\if\noexpand#1c\pexa@swaprelax{\pexa@dohex@lowc C}%
\else\if\noexpand#1d\pexa@swaprelax{\pexa@dohex@lowc D}%
\else\if\noexpand#1e\pexa@swaprelax{\pexa@dohex@lowc E}%
\else\if\noexpand#1f\pexa@swaprelax{\pexa@dohex@lowc F}%
%\else\if\noexpand#1I\pexa@swaprelax{\pexa@dohex@lowc 09}% tab: \t; Imp: better !! no #2, neither in \char "5E
\else\pexa@swaprelax{\pexa@dohex@lowd#1}%
\fi\fi\fi\fi\fi\fi\fi\fi\relax
}
\def\pexa@dohex@lowd#1{%
% Dat: ^^00 was silently dropped by \write
% Dat: ^^? is an invalid character -- never mind
\if\noexpand#1A\pexa@swaprelax{\pexa@dohex@lowc 01}%
\else\if\noexpand#1B\pexa@swaprelax{\pexa@dohex@lowc 02}%
\else\if\noexpand#1C\pexa@swaprelax{\pexa@dohex@lowc 03}%
\else\if\noexpand#1D\pexa@swaprelax{\pexa@dohex@lowc 04}%
\else\if\noexpand#1E\pexa@swaprelax{\pexa@dohex@lowc 05}%
\else\if\noexpand#1F\pexa@swaprelax{\pexa@dohex@lowc 06}%
\else\if\noexpand#1G\pexa@swaprelax{\pexa@dohex@lowc 07}%
\else\if\noexpand#1H\pexa@swaprelax{\pexa@dohex@lowc 08}%
\else\if\noexpand#1I\pexa@swaprelax{\pexa@dohex@lowc 09}% tab: \t; --- this _must_ be present here
\else\if\noexpand#1J\pexa@swaprelax{\pexa@dohex@lowc 0a}%
\else\if\noexpand#1K\pexa@swaprelax{\pexa@dohex@lowc 0b}%
\else\if\noexpand#1L\pexa@swaprelax{\pexa@dohex@lowc 0c}%
\else\if\noexpand#1M\pexa@swaprelax{\pexa@dohex@lowc 0d}%
\else\if\noexpand#1N\pexa@swaprelax{\pexa@dohex@lowc 0e}%
\else\if\noexpand#1O\pexa@swaprelax{\pexa@dohex@lowc 0f}%
\else\if\noexpand#1P\pexa@swaprelax{\pexa@dohex@lowc 10}%
\else\if\noexpand#1Q\pexa@swaprelax{\pexa@dohex@lowc 11}%
\else\if\noexpand#1R\pexa@swaprelax{\pexa@dohex@lowc 12}%
\else\if\noexpand#1S\pexa@swaprelax{\pexa@dohex@lowc 13}%
\else\if\noexpand#1T\pexa@swaprelax{\pexa@dohex@lowc 14}%
\else\if\noexpand#1U\pexa@swaprelax{\pexa@dohex@lowc 15}%
\else\if\noexpand#1V\pexa@swaprelax{\pexa@dohex@lowc 16}%
\else\if\noexpand#1W\pexa@swaprelax{\pexa@dohex@lowc 17}%
\else\if\noexpand#1X\pexa@swaprelax{\pexa@dohex@lowc 18}%
\else\if\noexpand#1Y\pexa@swaprelax{\pexa@dohex@lowc 19}%
\else\if\noexpand#1Z\pexa@swaprelax{\pexa@dohex@lowc 1a}%
\else\if\noexpand#1[\pexa@swaprelax{\pexa@dohex@lowc 1b}%
\else\if\noexpand#1\expandafter\@gobble\string\\\pexa@swaprelax{\pexa@dohex@lowc 1c}%
\else\if\noexpand#1]\pexa@swaprelax{\pexa@dohex@lowc 1d}%
\else\if\noexpand#1^\pexa@swaprelax{\pexa@dohex@lowc 1e}%
\else\if\noexpand#1_\pexa@swaprelax{\pexa@dohex@lowc 1f}%
\else\if\noexpand#1?\pexa@swaprelax{\pexa@dohex@lowc 7f}%
\else\char"5E \pexa@swaprelax{\pexa@dohex#1}%
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi
\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\fi\relax
}
\def\pexa@dohex@lowb#1{%
\if\noexpand#1aA%
\else\if\noexpand#1bB%
\else\if\noexpand#1cC%
\else\if\noexpand#1dD%
\else\if\noexpand#1eE%
\else\if\noexpand#1fF%
\else#1\fi\fi\fi\fi\fi\fi
}
\def\pexa@dohex@lowc#1#2{%
\ifnum\catcode"#1\pexa@dohex@lowb#2=13{\lccode`~="#1\pexa@dohex@lowb#2\lowercase{~}}% Dat: \lowercase{\noexpand~} didn't work, the letter `á' got hidden
\else{\lccode`+="#1\pexa@dohex@lowb#2\lowercase{+}}\fi%
}
% test at Wed Jan 5 15:57:25 CET 2005
\begingroup \catcode"A4=13 \catcode"1C=12
\edef~{\noexpand\noexpand\noexpand~}%
\edef\reserved@c{\expandafter\@gobble\string\\}%
\edef\reserved@a{\expandafter\pexa@dohex\string^IJ\pexa@dohex^4A\pexa@dohex^4a\pexa@dohex^a4\expandafter\pexa@dohex\expandafter^\reserved@c a}
\def\reserved@b{{\lccode`+="09\lowercase {+}}J\char "5E \char "5E 4A\char "5E \char "5E 4a{\lccode`~="A4\lowercase {~}}{\lccode`+="1C\lowercase {+}}a}
%%\show\reserved@a \show\reserved@b
\ifx\reserved@a\reserved@b\else\PackageError{examplep}{Unit test of \string\pexa@dohex\space failed}\@ehc\fi
\endgroup
%** Usage: \begin{PWSource}[OPTIONS]...\end{PWSource}. Writes everything (...)
%** into file \pexa@@sourcename, and also typesets it with \PexaShowSource
%** Dat: everything after \end{PWSource} in its line will be ignored
%** Dat: ^^ab hex codes >=128 will be substituted in \input (by \pexa@dohex)
%** Dat: ^^I etc. hex codes will be left alone
%** Dat: spaces at EOL will be lost (this is a limitation of TeX's eyes), so
% will be contents of lines with spaces only. This limitation is true
% for all environments in this file.
%** Dat: if `[OPTIONS]' is missing, then all spaces
\def\PWSource{%
\let\pexa@@savepar\par
\catcode`\ =12 \let\par\relax \obeylines% ugly hack so \@ifnextchar won't gobble spaces or newlines
\@ifnextchar[\pexa@PWSource{\pexa@PWSource[]}}%]
\def\pexa@PWSource[#1]{%
\def\pexa@@envopts{#1}%
\global\let\pexa@@cursourcename\pexa@@sourcename
\immediate\openout\verbfwr@writefile\pexa@@cursourcename\relax
\let\verbfwr@writecs\verbfwr@writefile
\let\verbfwr@actwriteline\verbfwr@writeline
\let\par\pexa@@savepar % so we won't get an infinite loop
\verbfwr@default@acts
\verbfwr@readenv\verbfwr@write
% Don't put anything else here!
}
\def\endPWSource{%
\immediate\closeout\verbfwr@writefile
\expandafter\PexaShowSource\expandafter{\pexa@@envopts}% use defaults
}
%** Writes its contents to file \pexa@@samplename and sets
%** \pexa@@cursourcename to \pexa@@samplename
%** Usage: \begin{WBoth}...\end{WBoth}. `...' is LaTeX source that can
%** be typeset verbatim or later \input into the middle of the document. See
%** the docs for \begin{PWSource} for more details.
\def\WBoth{%
\global\let\pexa@@cursourcename\pexa@@samplename
\immediate\openout\verbfwr@writefile\pexa@@samplename\relax
\let\verbfwr@writecs\verbfwr@writefile
\let\verbfwr@actwriteline\verbfwr@writeline
\verbfwr@default@acts
\verbfwr@readenv\verbfwr@write% finish this \cs here
}
\def\endWBoth{\immediate\closeout\verbfwr@writefile}
%** Similar to \begin{WBoth} (see docs there), but writes its contents to
%** file \pexa@@samplename.
\def\WSample{%
\immediate\openout\verbfwr@writefile\pexa@@samplename\relax
\let\verbfwr@writecs\verbfwr@writefile
\let\verbfwr@actwriteline\verbfwr@writeline
\verbfwr@default@acts
\verbfwr@readenv\verbfwr@write% finish this \cs here
}
\let\endWSample\endWBoth
%** Similar to \begin{WBoth} (see docs there), but writes its contents to
%** file \pexa@@sourcename (and sets \pexa@@cursourcename to it).
\def\WSource{%
\global\let\pexa@@cursourcename\pexa@@sourcename
\immediate\openout\verbfwr@writefile\pexa@@sourcename\relax
\let\verbfwr@writecs\verbfwr@writefile
\let\verbfwr@actwriteline\verbfwr@writeline
\verbfwr@default@acts
\verbfwr@readenv\verbfwr@write% finish this \cs here
}
\let\endWSource\endWBoth
%** Everything is ignored between \begin{PIgnore}...\end{PIgnore}. The trailing
%** Everything in the line of \end{PIgnore} is ignored, even chars after it.
%** `...' may contain unnested braces, groups or \ifs.
\def\PIgnore{%
\verbfwr@default@acts
\let\verbfwr@actemitline\@gobble
\verbfwr@readenv\verbfwr@write% finish this \cs here
}
\let\endPIgnore\endWBoth
%** Usage: \begin{PSource}[OPTIONS]...\end{PSource}. Same as \begin{PWSource},
%** but doesn't write anything to a file, so it is a little faster. Also, a
%** little more stable, since ^^ab hex codes aren't involved.
\def\PSource{%
\catcode`\ =13 \let\par\@@par \obeylines% ugly hack so \@ifnextchar won't gobble spaces or newlines
\@ifnextchar[\pexa@PSource{\pexa@PSource[]}}%]
\def\endPSource{\pexa@@undoyindent}
%\def\verbfwr@readenv@ii#1\hfuzz{{\end.}{\end{#1}}}% !!
\def\pexa@PSource[#1]{%
\pexa@doopts{#1}%
\expandafter\expandafter\expandafter\pexa@plines@start
\expandafter\verbfwr@readenv@i\@currenvir\hfuzz%
}%
\def\pexa@plines@notverbatim{%
%\catcode`~=13 %\def~{\nobreakspace{}}%
\catcode`\ =10 % restore to be space, was active
\let\pexa@setupverb\relax
\let\pexa@default@verbatimfont\relax
\def\verbfwr@read##1##2##3{\verbfwr@noter@read0}% Imp: doc why?
}
\def\pexa@plines@expandeach#1{%
% !! now \pexa@@eachline may be complicated (see listings=), this early
% expansion is no point. Re-verify purpose.
\expandafter\def\expandafter\reserved@a\expandafter{%
\expandafter\relax
\pexa@@eachline{#1}\cr}%
}
%** @param #1 `\end{PSource}' in catcode 12
%** @param #2 `\end {PSource}' with normal catcodes
\def\pexa@plines@start#1#2{%
\let\pexa@@starthalign\@empty % Dat: this is checked by \pexa@sh@leftleft and \pexa@sh@leftboth
\let\pexa@@dohalign\@empty % Imp: why so early?
%** Must be fully expandable.
\let\pexa@@eachline\@firstofone% Dat: \pexa@sh@leftboth overrides it
%%\show\pexa@default@srcstyle
\expandafter\ifx\csname pexa@ss@\pexa@default@srcstyle\endcsname\relax
\def\verbfwr@actemitlineone{% not called if there are no lines!
\let\verbfwr@actemitlineone\@empty
\pexa@starthalign% one @
\pexa@@beforefirstline
\noalign\bgroup
}%
\def\verbfwr@actemitline##1{% get line in \VerbFwrLines
%\edef\reserved@a{\def\noexpand\VerbFwrLines{\noexpand\pexa@@eachline{\VerbFwrLines}}}%
%\expandafter\egroup\reserved@a% \noalign, pass \VerbFwrLines inside the column
%\relax\VerbFwrLines\cr%\relax<.\VerbFwrLines.>\cr%
% vvv This solution makes it possible for \pexa@@eachline to contain `&' (at top level only?? -- verify again); see also @sh@leftboth
% vvv Dat: a beginning \edef\reserved@a{\relax...} is necessary to prevent
% TeX looking for \span, \omit etc.
%\edef\reserved@a{\relax\expandafter\pexa@@eachline\expandafter{\VerbFwrLines}\cr}%
\expandafter\pexa@plines@expandeach\expandafter{\VerbFwrLines}%
\expandafter\egroup\reserved@a% \noalign, pass \VerbFwrLines inside the column
%
\noalign\bgroup
}%
\def\verbfwr@actemitdone{% called if there were no lines
\ifx\verbfwr@actemitlineone\@empty
\egroup% \noalign
\egroup% \halign
\fi
}%
\expandafter\let\expandafter\pexa@plines@@setup\csname pexa@sh@\pexa@default@srcstyle\endcsname% this sets up further \catcodes
\let\pexa@@dohalign\@empty
\def\pexa@@dopars{\PackageError{Expected \string\pexa@@dohalign\space here}\@ehc}%
\else
%\expandafter\pexa@setup@calcwidths\expandafter{\pexa@default@usewidth}%
% Dat: no need to save/restore \parindent here, becasuse we do \noindent
\def\verbfwr@actemitlineone{\let\verbfwr@actemitlineone\@empty}%
\let\verbfwr@actemitdone\@empty
\def\verbfwr@actemitline##1{\expandafter\pexa@plines@parpre\expandafter\pexa@@eachline\expandafter{\VerbFwrLines}\@@par}%
\expandafter\let\expandafter\pexa@plines@@setup\csname pexa@ss@\pexa@default@srcstyle\endcsname% this sets up further \catcodes
\everypar{}%
% Dat: too early to set \hsize now
\let\pexa@@dopars\@empty
\def\pexa@@dohalign{\PackageError{Expected \string\pexa@@dopars\space here}\@ehc}%
\fi
%
% vvv Similar to \PexaShowSourceMany
%\leavevmode% for \@bsphack
%\@bsphack% don't have to save \spacefactor
\let\par\@@par% make \vskip work fine??
\expandafter\pexa@setup@calcwidths\expandafter{\pexa@default@usewidth}%
\begingroup
\pexa@@calcwidths% calculate leftmost \tabskip
\@tempdima\PexaWidth
\advance\@tempdima\tabskip
\edef\reserved@a{\def\noexpand\pexa@@tolinewidth{to\the\@tempdima}}%
\expandafter\endgroup\reserved@a
%\advance\linewidth\@totalleftma
%\def\pexa@@tolinewidth{to\linewidth}%
%
\pexa@xyindent\pexa@default@xindent\pexa@default@yindent
% \pexa@plines@notverbatim
\pexa@setup@listings
\pexa@plines@@setup
% ^^^ calls \pexa@s?@..., which calls \pexa@show@pars or \pexa@show@halign,
% which calls \pexa@setupverb and \pexa@@calcwidths, which modifies
% \tabskip and \linewidth
\let\pexa@@hpre\@empty{}% Dat: only meaningful for \input
\advance\leftskip -1\leftskip % keep stretch
\advance\rightskip-1\rightskip% keep stretch
%\leftskip\z@skip \rightskip\z@skip % Dat: needed by \begin{egysoros} -- why??
%\advance\hsize\rightskip
%\showthe\hsize
%\showthe\leftskip
%\showthe\rightskip
\let\par\@@par \obeylines
\verbfwr@read{#1}\@gobble{% read verbatim data line-by-line, call \verfwr@act... as callbacks
%\@esphack
#2%
}%
% Don't put anything else here, will be read by \verbfwr@read
}
% vvv Dat: \leavevmode would insert \indent and cancels \noindent
% vvv Dat: \null is needed for empty lines with no \catcode change for ^^M
\def\pexa@plines@parpre{\pexa@@vts\noindent\null
\kern\tabskip% !! added at Tue May 18 11:14:58 CEST 2004; for \begin{PSource} in \begin{description}; does it hurt lakk??
\pexa@@everyparr}%
% --- Adding accents and breaking ligatures
\edef\pexa@quoteleft {\relax\string`}
\edef\pexa@quoteright{\relax\string'}
\edef\pexa@hyphen {\relax\string-\relax}% Dat: 2nd \relax is superfluous?? even for ---
\edef\pexa@comma {\relax\string,}
\edef\pexa@less {\relax\string<}
\edef\pexa@greater {\relax\string>}
\let\pexa@@oldH\H% default
\let\pexa@@olddot\.% default
\def\pexa@@otone{OT1}
\def\pexa@H#1{% \H accent missing from {OT1}{cmtt}
\ifx\f@encoding\pexa@@otone% Imp: don't hard-wire cmr??
\pexa@curprop\iftrue%
\pexa@@oldH#1%
\else%
\pexa@add@accentx{125}{\fontencoding{OT1}\fontfamily{cmr}\selectfont}#1% not expandable
\fi%
\else%
\pexa@@oldH#1% {T1}{cmtt} is OK
\fi%
}%
\def\pexa@dot#1{% \. accent missing from {OT1}{cmtt}
\ifx\f@encoding\pexa@@otone%
\pexa@curprop\iftrue%
\pexa@@dot#1%
\else%
\pexa@add@accentx{95}{\fontencoding{OT1}\fontfamily{cmr}\selectfont}#1% not expandable
\fi%
\else%
\pexa@@olddot#1% {T1}{cmtt} is OK
\fi%
}%
%** Derived from LaTeX \add@accent
%** @param #1 0..255 code of the accent
%** @param #2 commands to load the accent font
%** @param #3 char to put the accent on
\def\pexa@add@accentx#1#2#3{\hmode@bgroup
\let\hmode@start@before@group\@firstofone
\setbox\@tempboxa\hbox{%
#3\global\mathchardef\accent@spacefactor\spacefactor}%
\edef\@thefont{\the\font}%
#2% select font
\accent#1%
\@thefont#3%
\egroup\spacefactor\accent@spacefactor
}
\def\pexa@@zero{0}
%** `\pexa@curprop\iftrue' behaves like `\iftrue' if the current font is
%** proportional; or `\iffalse' if the current font is fixed-width.
%** Cannot create an `\ifpexa@curprop' macro, since it won't be treated properly
%** when skipped (only \let\ifpexa@curprop\iffalse and \let\ifpexa@curprop\iftrue
%** is treated properly).
%** Ruins \reserved@a
%** Imp: better in pexample.sty
\def\pexa@curprop#1{%
\expandafter\let\expandafter\reserved@a\csname prop@\fontname\font\endcsname
\ifnum10>1\reserved@a% no ` %' here; calculate \reserved@a for the first time
\def\reserved@a{1}% \let\reserved@a0 won't work with `\ifnum'
\ifdim\fontdimen3\font=\z@
\ifdim\fontdimen4\font=\z@
\begingroup
\setbox0=\hbox{i}%
\setbox1=\hbox{W}%
\ifdim\wd0=\wd1 %
\aftergroup\let\aftergroup\reserved@a\aftergroup\pexa@@zero% found a fixed-width font
\fi
\endgroup
\fi
\fi
\expandafter\let\csname prop@\fontname\font\endcsname\reserved@a
\fi
\csname if\if\reserved@a0false\else true\fi\endcsname
}%
% ---
%** Acts based on usewidth=
%** @in \linewidth has never contained \@totalleftmargin and total_right margin
%** @out \PexaWidth = source+rule+sample a dimen register or tokens ending
%** by space `1.2pt '; \PexaWidth doesn't contain left or right indentation
%** @out \pexa@@calcwidths to set \tabskip to point to final left margin
%** to decrease \linewidth by some margins
%** Will modify \linewidth indirectly: decreases by \leftskip
%** @param #1 value of \pexa@default@usewidth: 0, 1 or 2
\def\pexa@setup@calcwidths#1{%
\if#12% usewidth=skipwidth
\begingroup
\@tempdimb\linewidth
% Dat: we definitely mustn't do \advance\@tempdimb-\@totalleftmargin,
% because \linewidth has never contained the value of \@totalleftmargin
\advance\@tempdimb-\rightskip \advance\@tempdimb-\leftskip
\edef\PexaWidth{\def\noexpand\PexaWidth{\the\@tempdimb\space}}%
\expandafter\endgroup\PexaWidth
% Dat: we really don't want to say \let\PexaWidth\@tempdimb here, because
% \small in \pexa@defaut@verbatimfont will clobber it later
\def\pexa@@calcwidths{%
% vvv this is called in \pexa@show@halign to set the left margin properly
\tabskip\leftskip \advance\tabskip\@totalleftmargin
%\advance\linewidth-\@totalleftmargin% BUGFIX at Tue Dec 23 19:55:06 CET 2003 -- fixes \PexaShowBoth
%\advance\linewidth-\leftskip% Dat: enabling this makes \begin{egysoros} buggy (too narrow line). BUGFIX at Tue Mar 30 17:40:50 CEST 2004
%\advance\linewidth-\rightskip% !! is this used? and below? (two)
}%
\else\if#11% usewidth=linewidth
\let\PexaWidth\linewidth
\def\pexa@@calcwidths{\tabskip\@totalleftmargin
%!!\advance\linewidth-\@totalleftmargin% BUGFIX at Tue Dec 23 19:55:06 CET 2003 -- fixes \PexaShowBoth
}%
\else% usewidth=hsize
\let\PexaWidth\hsize
\def\pexa@@calcwidths{\tabskip\z@ \let\linewidth\hsize}%
\fi\fi
}
\def\PexaShowSample#1{%
\begingroup
\pexa@doopts{#1}%
% vvv Dat: may contain .45\PexaWidth
% \expandafter\@temptokena\expandafter{\pexa@default@samplewidth}%
% !! test this
\begingroup
\@tempdimb\PexaWidth\relax
\let\PexaWidth\@tempdimb
\@tempdima\pexa@default@samplewidth\relax% do arithmetic: .5\PexaWidth
\edef\reserved@a{%
\noexpand\edef\noexpand\PexaWidth{\the\@tempdimb\space}%
\noexpand\PexaShowSampleMany
{\the\@tempdima}% 1
{\pexa@default@boxstyle}% 2
}%
%%\show\reserved@a
\expandafter\endgroup\reserved@a
\endgroup% BUGFIX: makes \pexa@doopts have effect
}%
%** This command is for internal use only. Use \PexaShowSample instead.
%** Shows the Sample in lines on their own. Page breaks disallowed.
%** @param #1 dimen: width of Sample (\hsize, paragraph width). Examples: .4\hsize >= .4\linewidth
%** @param #2 boxing style of Sample (boxstyle=):
%** `h': \hbox
%** `v': \vtop
%** 'm': is minipage with \vtop
%** 'p': is PexaMinipage with \vtop (recommended)
%** `V': \vbox
%** 'M': is minipage with \vbox
%** 'P': is PexaMinipage with \vbox
%** 'G': no boxing, only \begingroup .. \endgroup
\def\PexaShowSampleMany#1#2{%
\if#2G\else
\if#2h\else
\vskip\z@skip% leave horizontal mode
\fi\fi
\csname pexa@setsample@#2\endcsname{#1}%
}
% ---
\def\pexa@@tolinewidth{to\PexaWidth}
\def\pexa@@calcwidths{}
%** Default: align left
\def\pexa@@preamble{\pexa@@hpre##\hfil\tabskip\z@ plus1fill}
\def\pexa@@preamblecr{\cr}% or {\cr\noalign{\nobreak}}
\let\pexa@@hpre\@empty
%** Don't allow a page break before Sample is over
\def\pexa@preamblecr@keep{\cr\noalign{%
\ifdim-\pexa@@cnta\baselineskip<\@tempdima\nobreak\fi}}%
%** Default
\let\pexa@@beforehalign\@empty
\let\pexa@@firstlinebeg\@empty
\let\pexa@@beforefirstline\@empty
\def\pexa@default@addlinenum{0}% start line numbering from \pexa@default@addlinenum+1
\def\pexa@@cnta{0}%
\let\pexa@@cntb\pexa@default@addlinenum% default
%** Contains width of linenumbersep=, too
\def\pexa@default@linenumberwidth{0pt}%
%** Better than `~', because not affected by amsxtra.sty's redefinition.
\def\pexa@default@space{\leavevmode\nobreak\ }%
%** @example \enspace, \quad, \hbox{\space} etc.
%** @example \def\pexa@default@linenumberwidth{\parindent} \def\pexa@default@linenumbersep{\enspace}%
\def\pexa@default@linenumbersep{}%
%** No effect, will be overridden later.
\def\pexa@default@linenumberformat{}
%** Clobbers \@tempcnta. \gdef#1
%** @param #1 a macro \cs name expanding to a number
\def\pexa@decr#1{\@tempcnta#1\advance\@tempcnta\m@ne\global\edef#1{\the\@tempcnta}}
%** A tab is really more complicated than 8 (eight) spaces, but correct
%** tabbing would be hard to implement here.
\def\pexa@setuptab{%
\catcode9 13 \begingroup\lccode`~=9 \lowercase{\endgroup\def~}{\ \ \ \ \ \ \ \ }%
}
% Imp: insert \relax instead (easy in \PVerb)
\def\pexa@noligs@some{% Imp: use standard \@noligs?
% Common ligatures in monospaced fonts: `` '' ,, -- -Z << >> !` ?` (where Z has ASCII code 127)
% Dat: compare this code with \@noligs of latex.ltx -- this is more efficient
% vvv Dat: this has no effect on \pexa@cverb@outerc (and neither on inner
% \PVerb), but that is hoped to have its \break{}s already separating.
\catcode``13 \lccode`~``\lowercase{\let~\pexa@quoteleft}% break Spanish ?` and !` ligatures in cmtt10.mf (and also the '' ligature in)
\catcode`-13 \lccode`~`-\lowercase{\let~\pexa@hyphen}% break ligatures --, --- and -Z (where Z has ascii code 127)
\catcode`'13 \lccode`~`'\lowercase{\let~\pexa@quoteright}% break ligature ''
\catcode`,13 \lccode`~`,\lowercase{\let~\pexa@comma}% break ligature ,,
\catcode`<13 \lccode`~`<\lowercase{\let~\pexa@less}% break ligature <<
\catcode`>13 \lccode`~`>\lowercase{\let~\pexa@greater}% break ligature >>
}
\def\pexa@noligs@most{%
\@tempcnta32 \loop\ifnum\@tempcnta<128
\ifnum\catcode\@tempcnta=12
\lccode`~\@tempcnta \lowercase{\edef~{\relax\string~\relax}}%
\fi
\advance\@tempcnta\@ne\repeat
}
\def\pexa@@noligs{\pexa@noligs@some}
%** Called by \begin{PLines}, \PexaShowBoth, \PVerb etc.
\def\pexa@setupverb{%
\ifnum\the\catcode`^=13 % already active, is \pexa@dohex
\let\do\@makeother \dospecials
\catcode`^=13
\else
\let\do\@makeother \dospecials% \catcode`\\=12 etc. (see latex.ltx for \dospecials)
\fi
% Dat: `latex --translate-file il1-t1' emits accented glyph to file as a single char
% ^^^ Dat: don't modify catcode of 127..255, so accents will come out right
\catcode32=13 \lccode`~=32 \lowercase{\let~\pexa@default@space}% make each space count, but not a visible space -- \@xobeysp defined in latex.ltx
% ^^^ Dat: former \let~\@xobeysp
\pexa@@noligs
\let\pexa@@oldH\H \let\H\pexa@H%
\let\pexa@@olddot\.\let\.\pexa@dot%
}
%** Not \pexa@default@verbatimfont. This is used by load options to
%** examplep.sty
\def\pexa@@verbatimfont{\verbatim@font}% in latex.ltx
\def\pexa@setupverb@read{%
\catcode`\^13 \lccode`~`^\lowercase{\let~\pexa@dohex}% Dat: allow ^^e1 hex emulation (setting catcode=7 won't do good because of literal `^'s)
}
\def\pexa@starthalign{%
%\zzzzz\show\pexa@@tolinewidth\showthe\PexaWidth
\halign\pexa@@tolinewidth\bgroup
\pexa@@vts% run only once
\pexa@decr\pexa@@cnta
\pexa@decr\pexa@@cntb% must be \global because of \halign, but don't want to clobber \@tempcnt* \global{}ly
\span\pexa@@preamble % expand preamble right now: `##\hfil'
\cr% Dat: \pexa@@preamblecr isn't called _before_ the 1st line
}%
\def\pexa@@starthalign{\pexa@starthalign}%
\def\pexa@@dohalign{%
% vvv Dat: this would give \@@input available to the preamble
%\pexa@@beforefirstline% called after the \cr of the preamble, should contain \noalign{...}
%\relax\@@input\pexa@@cursourcename\space
%
\expandafter\pexa@@beforefirstline% called after the \cr of the preamble, should contain \noalign{...}
\@@input\pexa@@cursourcename\space
%\relax\pexa@setupverb@read% Dat: already called
% ^^^ Dat: \relax instead of \space would begin an extra line and demand
% an extra \cr (at end)
\egroup% terminate \halign
}%
%** Call this inside \begingroup, from a macro
%** Caller may set \pexa@@beforehalign, \tabskip; should pexa@@
\def\pexa@show@halign{%
\pexa@setupverb
\pexa@setuptab
\pexa@default@verbatimfont
\let\par\pexa@@preamblecr \obeylines% must set \par before this; so each ^^M will emit a \cr plus more
\def\pexa@@vts{%
\pexa@@firstlinebeg
%\vrule height\topskip width\z@ %!! try to do without this
\global\let\pexa@@vts\relax
}%
\pexa@@calcwidths
\pexa@@beforehalign
% Dat: \everypar{...} has no effect here (inside \halign)
\pexa@@starthalign
\pexa@@dohalign
}
\begingroup\lccode`$13 \lowercase{\endgroup\def\pexa@grabline#1${%
% Dat: we use catcode 3 (`$'), because with 13, TeX would expand ^^M first before putting it back (at empty line)
% Dat: TeX inserts the contents of \par upon an empty line -- we have to decode it
%...(#1)
\pexa@@eachline{#1}%
%^^M% give back ^^M, equivalent to
\par}}%
\def\pexa@@dopars{% Dat: in lb: isn't called by \begin{egysoros}, called by \begin{code}
\begingroup% Dat: don't do a \vbox, because it resets \parshape
% \show\par % Dat: \hskip\z@skip \@@par
%\def\par{,\@@par}%
%\obeylines
%\let\par\ourpar \obeylines
%\def\par{xxxxxxxxxxxxxx}%
\catcode13=3
\ifx\pexa@@eachline\@empty
\everypar{\setbox0\lastbox% remove \indent since \noindent is too late
\pexa@@vts\pexa@@everyparr}%
\else
\everypar{\setbox0\lastbox% remove \indent since \noindent is too late
\pexa@@vts\pexa@@everyparr \tracingmacros1 \pexa@grabline}%
\fi
%\showthe\linewidth
%\showthe\leftskip
\hsize\linewidth
\advance\hsize\leftskip% !! already done by \pexa@show@pars?? -- maybe fixup after hook?
\advance\hsize\rightskip
\pexa@setupverb@read
\relax\input\pexa@@cursourcename\space
\endgroup
}%
\def\pexa@show@pars{% modelled after \pexa@ss@left
\pexa@setupverb% Dat: we still have normal catcodes for \dospecials before calling this
\pexa@setuptab
%\showthe\catcode9
%\show\pexa@default@verbatimfont
\pexa@default@verbatimfont
%\show\pexa@@calcwidths
\parfillskip\@flushglue
\parskip\z@skip
%
\pexa@@calcwidths% doesn't always change \linewidth; sets \tabskip
% Dat: now \tabskip is the left indentation and \linewidth is the desired
% width of text. From that we calculate \leftskip and \hsize.
\leftskip\tabskip% as calculated by \pexa@@calcwidths
\hsize\linewidth% !! \PexaWidth?, respect \leftskip etc. (\pexa@setup@calcwidths)
\advance\hsize\leftskip
\advance\hsize\rightskip
%
% Dat: we don't change and don't use \parindent
\def\par{\hskip\z@skip\@@par}% obey empty lines
\obeylines
\def\pexa@@vts{%
\pexa@@firstlinebeg
%\vrule height\topskip width\z@% superfluous, ruins \baselineskip
\global\let\pexa@@vts\relax
}%
%\show\leftskip \showthe\leftskip
\pexa@@showparshook % \raggedright etc.
% Dat: \pexa@@dopars is empty for \begin{egysoros}, not empty for \begin{code}
\pexa@@dopars
}
\def\pexa@@showparshook{}
% Dat: used by source-par-align=
% Dat: \centering, \raggedright and \raggedleft clobbers these:
% \\, \rightskip, \leftskip, \parindent, \parfillskip, \@rightskip.
% We ignore \\, \parindent and \@rightskip, we have to modifye (but not
% clobber) \rightskip, \leftskip and \parfillskip only. So we have our
% own macros.
\def\pexa@paralign@center{% similar to \centering
\leftskip 1\leftskip plus 1fil\relax
\rightskip1\rightskip plus 1fil\relax
\parfillskip\z@skip}
\def\pexa@paralign@left{% similar to \raggedright
% Dat: \leftskip and \rightskip are cumulative
\leftskip 1\leftskip\relax
\rightskip1\rightskip plus 1fill\relax
\parfillskip\z@skip}%
%\parfillskip\@flushglue}% Imp: is \@flushglue better here for the line breaking algorithm?
\def\pexa@paralign@right{% similar to \raggedleft
\leftskip 1\leftskip plus 1fil\relax
\rightskip1\rightskip\relax
\parfillskip\z@skip}
\def\pexa@paralign@justify{% last line left aligned, others justified
\leftskip 1\leftskip\relax
\rightskip1\rightskip\relax
\parfillskip\@flushglue}
\def\pexa@paralign@justjust{% all lines justified => lot of Underfull \hbox{}es
\leftskip 1\leftskip\relax
\rightskip1\rightskip\relax
\parfillskip\z@skip}
%** @param #1 filename
%** @param #2 examplep options
\def\PexaInputSource#1#2{%
\begingroup
\def\pexa@@cursourcename{#1}%
\PexaShowSource{#2}
\endgroup
}
%** Dat: not affected by samplewidth=
\def\PexaShowSource#1{%
\clubpenalty\@clubpenalty % allow club lines after \paragraph{x}y\par
\begingroup
\pexa@doopts{#1}
\edef\reserved@a{\noexpand\PexaShowSourceMany
{\pexa@default@srcstyle}% 1
{\pexa@default@usewidth}% 2
{\pexa@default@xindent}% 3
{\pexa@default@yindent}% 4
}%
%\expandafter\endgroup\reserved@a
\reserved@a
\endgroup% BUGFIX: makes \pexa@doopts have effect
}
%** This command is for internal use only. Use \PexaShowSource instead.
%** Show the source of the previous \begin{WSource} / \begin{WBoth},
%** @param #1 source display style (srcstyle=):
%** `left': aligned to the left margin
%** `center': center aligned (individual lines left aligned)
%** `right': right aligned (individual lines left aligned)
%** `leftnum': left aligned with unaligned line numbering (similar to what
%** .dtx does)
%** `leftnumcol': right flushed line numbering . left flushed source line
%** `leftnumhang': marginpar-hanging line numbering . left flushed source line
%** `leftboth': similar to \PexaShowBoth, but uses \PVerb (works only with \PSource)
%** `leftbothnumcol': combination of leftboth and leftnumcol
%** `leftleft': two different columns, left aligned with a \pexa@@vrule (works only with \PSource)
%** 'paralign': left by default, affected by source-par-align=
%** @param #2 width selector: `0': use full \hsize, `1': use \linewidth only,
%** `2': use \linewidth-\leftskip-\rightskip (because of \narrower)
%** @param #3 xindent: `none' | `deeper' | `narrower' | `deepright'
%** @param #4 yindent: `none' | `deeper'
\def\PexaShowSourceMany#1#2#3#4{%
\pexa@setup@calcwidths{#2}%
\begingroup
\pexa@xyindent{#3}{#4}%
% Dat: we don't need \pexa@@calcwidths now, it will be called later.
%\pexa@@calcwidths % \leftskip, \@totalleftmargin -> \tabskip
%%\showthe\tabskip
%%\show\pexa@default@listings
\def\pexa@@eachline{}% Dat: used by listings=
\pexa@setup@listings
%%\show\pexa@@eachline
\expandafter\ifx\csname pexa@ss@#1\endcsname\relax
\csname pexa@sh@#1\endcsname% do the actual \input
\else\csname pexa@ss@#1\endcsname\fi
\pexa@@undoyindent
\pexa@endparenvgroup
}%
\def\pexa@movedeeper{%
\ifnum\@listdepth=\z@ \leftmargin\z@ \rightmargin\z@ \fi% remove garbage
\edef\pexa@@restore@xmargins{%
\noexpand\leftmargin \the\leftmargin
\noexpand\rightmargin\the\rightmargin
}%
\ifnum \@listdepth >5\relax
\@toodeep
\else
%\showthe\@listdepth
\global\advance\@listdepth\@ne
\aftergroup\global\aftergroup\advance\aftergroup\@listdepth\aftergroup\m@ne
\fi
\rightmargin\z@
% vvv defined in size*.clo, sets \leftmargin, \rightmargin, \topsep, \parsep
% \itemsep etc.
\csname @list\romannumeral\the\@listdepth\endcsname
\let\pexa@@oncedeeper\@empty
}
\let\pexa@@restore@xmargins\@empty
% The \pexa@doxindent@... commands to the following:
%
% -- clobber \leftmargin and \rightmargin to an unused value
% -- set \parshape\z@
% -- decrease \linewidth by additional left and right margin
% -- increase \@totalleftmargin by additional right margin
% -- increase \leftskip by more additional left margin
% -- increase \rightskip by more additional right margin
\def\pexa@doxindent@none{%
%\advance\@totalleftmargin 5pt
\parshape\z@
}%
\def\pexa@doxindent@deeper{%
\pexa@@oncedeeper
%\showthe\linewidth
%\showthe\rightmargin
%
% vvv do proper Overfull \hbox calculations
% vvv not done by \pexa@@oncedeeper, for \begin{egysoros} at Wed Jul 7 08:20:23 CEST 2004
\advance\linewidth -\rightmargin
\advance\linewidth -\leftmargin
%
\advance\@totalleftmargin \leftmargin % do indentation
%\advance\leftskip1em
\parshape\z@% \parshape unused, converted to \tabskip
}
%** xindent=deeppre: move deeper, but keep old \leftmargin and \rightmargin
%** Imp: why is it different from =none unless yalign=deeper
\def\pexa@doxindent@deeppre{%
\pexa@@oncedeeper
%\show\pexa@@restore@xmargins
\pexa@@restore@xmargins
% vvv Dat: removed for lakkbook at Fri Mar 26 17:24:23 CET 2004:
% \linewidth and \@totalleftmargin has already been modified; and
% \leftmargin and \rightmargin doesn't count
% !! make it indent with \begin{PSource} -- or =deeper?
\parshape\z@% \parshape unused, converted to \tabskip
}
\def\pexa@doxindent@narrower{\narrower}%
\def\pexa@doxindent@deepright{%
\pexa@@oncedeeper
\rightmargin\leftmargin
\advance\linewidth -\rightmargin
\advance\linewidth -\leftmargin
\advance\@totalleftmargin \leftmargin
\parshape\z@% \parshape unused, converted to \tabskip
}
\def\pexa@@str@addvspace{\addvspace}
\def\pexa@undo@nobreak{%
\if@nobreak
\@nobreakfalse
\ifnum\clubpenalty=\@M \clubpenalty\@clubpenalty \fi
\fi}
\def\pexa@doyindent@none{\let\pexa@@undoyindent\@empty
\pexa@undo@nobreak
\@endpetrue\@doendpe % automatic \noindent for text coming -- if not separated by newline
}%
\def\pexa@doyindent@deeper{%
\edef\pexa@@restoreleftskip{\leftskip\the\leftskip\space}%
\@rightskip\rightskip
\pexa@@oncedeeper
\@trivlist % calculates \@topsepadd depending on \ifvmode
%\show\par
\global\@newlistfalse
\pexa@undo@nobreak
\let\makelabel\@firstofone
\let\@itemlabel\@empty
\pexa@@restoreleftskip \let\pexa@@restoreleftskip\@undefined
\def\pexa@@undoyindent{%
% Dat: now \pexa@default@addvspace shouldn't contain \addvspace itself. Brr.
%\ifx\pexa@default@addvspace\pexa@@str@addvspace\else
% \let\addvspace\pexa@default@addvspace % used by \@endparenv called from \endtrivlist
%\fi
%\def\@endparenv{% original in latex.ltx
% \addpenalty\@endparpenalty\addvspace\@topsepadd\@endpetrue}
\def\@endparenv{% original latex.ltx
\addpenalty\@endparpenalty
\pexa@default@addvspace@bottom\@topsepadd
\@endpetrue}
\global\@newlistfalse
\endtrivlist}%
%\showthe\@topsepadd
%\show\pexa@default@addvspace@top
%\pexa@default@addvspace@top\@topsepadd % as calculated by \@trivlist
\expandafter\pexa@default@addvspace@top\expandafter{\the\@topsepadd}% !! as calculated by \@trivlist
}
\def\pexa@sh@left{%
% SUXX: doesn't work (TeX macro argument parsing bug??): \pexa@dumpcatcodes foo####\hfuzz\hfil\tabskip\z@ plus1fill }%
%\def\pexa@@preamble{%
% % SUXX: more complicated problems with ^^e1 and C ^ operator. Too bad.
% % Dat: now always displays ^^e1
% %\showthe\catcode`^
% %\begingroup\lccode`~`^ \lowercase{\endgroup\def~{D\zzzz}}
% \foooo####% Dat: not even `int;' works
% %####
% \hfil\tabskip\z@ plus1fill }%
\pexa@show@halign
}
\def\pexa@ss@left{% \begin{egysoros}
\let\pexa@@everyparr\@empty
\let\pexa@@showparshook\pexa@paralign@left
\pexa@show@pars
}
\def\pexa@ss@center {\let\pexa@@everyparr\@empty \let\pexa@@showparshook\pexa@paralign@center \pexa@show@pars}
\def\pexa@ss@right {\let\pexa@@everyparr\@empty \let\pexa@@showparshook\pexa@paralign@right \pexa@show@pars}
\def\pexa@sh@paralign{%
\PackageError{examplep}{srcstyle=paralign only works in par mode}\@ehc
\pexa@sh@left
}
\def\pexa@ss@paralign{\let\pexa@@everyparr\@empty \pexa@show@pars}
\def\pexa@getcatcode#1{%
\ifcat\noexpand~\noexpand#113%
\else\ifcat\relax\noexpand#1cs% control sequence
\else\ifcat,\noexpand#112%
\else\ifcat a\noexpand#111%
\else\ifcat\space\noexpand#110 % Dat: never, would be ignored by macro expansion
\else\ifcat_\noexpand#18%
\else\ifcat^\noexpand#17%
\else\ifcat&\noexpand#14%
\else\ifcat$\noexpand#13%
\else?\fi\fi\fi\fi\fi\fi\fi\fi\fi
}
%** Usage: \pexa@dumpcatcodes...\hfuzz
%** Dat: no braces or spaces, please
%** @example \pexa@dumpcatcodes Hello, World & People ($100_)!\hfuzz
\long\def\pexa@dumpcatcodes#1{%
\ifx#1\hfuzz\typeout{}\else
\message{\string#1_\pexa@getcatcode#1}%
\expandafter\pexa@dumpcatcodes
\fi}
%** @example: \pexa@showcatcodes~ (-> \penalty etc.)
\def\pexa@showcatcodes#1{%
\typeout{}%
\expandafter\pexa@dumpcatcodes#1\hfuzz}
\expandafter\def\expandafter\pexa@ifcount@low
\expandafter#\expandafter1\string\count#2\hfuzz{%
\ifx\vfuzz#1\vfuzz\expandafter\@firstoftwo
\else\expandafter\@secondoftwo\fi}
%** Test whether #1 is a count register or not, exceute #2 or #3.
\def\pexa@ifcount#1{\expandafter\expandafter\expandafter\pexa@ifcount@low
\expandafter\meaning\csname#1\expandafter\endcsname\string\count\hfuzz}
\def\pexa@listings@noligs{%
\def\lst@FillOutputBox##1{##1\lst@FillOutputBox@}%
\def\lst@FillOutputBox@##1{%
\ifx\@empty##1\else \relax##1\expandafter\lst@FillOutputBox@ \fi}%
}
\def\pexa@bsspace{\ }%
\def\pexa@listings@convert{\futurelet\@let@token\pexa@listings@convert@@}
\def\pexa@listings@convert@@{%
\ifcat\noexpand\@let@token\bgroup \expandafter\pexa@listings@convertArg
\else \expandafter\pexa@listings@convert@S \fi}
\def\pexa@listings@convert@S{%
\ifx\@let@token\pexa@bsspace \expandafter\pexa@listings@convert@SP
\else \expandafter\pexa@listings@convert@ \fi}