summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/memoir/doc-src/memsty.sty
blob: a0427c232b17cdd2126eefad6224a1fcdbec0215 (plain)
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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
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
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
%% memsty.sty    For memman
\ProvidesPackage{memsty}[2010/02/09 for memman]

%%%%\usepackage{desc}% temporary, until code added to memoir itself

%%\usepackage{layouts}[2001/04/29]
%%\usepackage{verbatim}
%%\usepackage{glossit}
%\usepackage{etex}
\usepackage{layouts}[2001/04/29]
\usepackage{url}
\usepackage{fixltx2e}
\usepackage{alltt}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{latexsym}
\usepackage{memfonts}
\usepackage{pifont}
\usepackage{amsmath}
\usepackage[T1]{fontenc}

\providecommand{\LMnote}[2]{}  
\providecommand{\PWnote}[2]{}  

\newcommand\Added[1]{\sidepar{\tiny Added #1}}

%%%%%%%%%%%%%%%%%%% kill scale change warning in layouts
\renewcommand*{\setlayoutscale}[1]{\setlength{\l@youtunitlength}{1pt}
  \l@youtunitlength= #1\l@youtunitlength
  \renewcommand*{\l@youtscale}{#1}}

%%%%%%%%%%%%%%%%%% plainmarkruled pagestyle
\makepagestyle{plainmarkruled}
  \makeheadrule{plainmarkruled}{\textwidth}{\normalrulethickness}
  \makeevenhead{plainmarkruled}{\scshape\leftmark}{}{}
  \makeoddhead{plainmarkruled}{}{}{\scshape\rightmark}
  \makeevenfoot{plainmarkruled}{\thepage}{}{}
  \makeoddfoot{plainmarkruled}{}{}{\thepage}
\makepsmarks{plainmarkruled}{\@ruledmarks}



%%%%%%%%%%%%%%%%%% index pagestyle
\makepagestyle{index}
  \makeheadrule{index}{\textwidth}{\normalrulethickness}
  \makeevenhead{index}{\rightmark}{}{\leftmark}
  \makeoddhead{index}{\rightmark}{}{\leftmark}
  \makeevenfoot{index}{\thepage}{}{}
  \makeoddfoot{index}{}{}{\thepage}

\makeindex
%\showindexmarktrue

%%%%%%%%%%%%%%%%%%%%%%% glossary
\makeglossary
\changeglossactual{?}
\changeglossnum{\@currentlabel} 
\changeglossnum{\thepage}
\changeglossnumformat{|hyperpage} %|
\renewcommand*{\glossaryname}{Command summary}
\renewcommand{\glossitem}[4]{%
  \sbox\@tempboxa{#1 \space #2 #3 \makebox[2em]{#4}}%
\par\hangindent 2em
  \ifdim\wd\@tempboxa<0.8\linewidth
    #1 \space #2 #3 \dotfill \makebox[2em][r]{#4}\relax
  \else
    #1 \dotfill \makebox[2em][r]{#4}\\
    #2 #3
  \fi}
\renewcommand*{\glossarymark}{\markboth{\glossaryname}{\glossaryname}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%% endnotes
\makepagenote
\notepageref%      use page numbers
\newcommand*{\notemark}{\markboth{\notesname}{\notesname}}
\renewcommand*{\notedivision}{\chapter{\notesname}\notemark}
\renewcommand*{\notenumintext}[1]{}%  no number marks in main text
\renewcommand*{\notenuminnotes}[1]{}% no number marks in listing
\renewcommand*{\idtextinnotes}[1]{\vspace{-0.5\onelineskip}
                                  \par [#1]\space}
\renewcommand*{\notemark}{\markboth{{\scshape \notesname}}{{\scshape \notesname}}}
\renewcommand*{\pagenotesubhead}[3]{%
  \section{#1 #2 #3}}
%%\renewcommand*{\notemark}{\markboth{\notesname}{\notesname}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Short and long ToC

\newcommand*{\setupshorttoc}{%
  \renewcommand*{\contentsname}{Short contents}
  \let\oldchangetocdepth\changetocdepth
  \let\oldprecistoctext\precistoctext
  \renewcommand{\precistoctext}[1]{}
  \let\oldcftchapterfillnum\cftchapterfillnum
  \renewcommand*{\changetocdepth}[1]{}
  \setcounter{tocdepth}{0}% chapters
  \renewcommand*{\cftchapterfont}{\hfill\sffamily}
  \renewcommand*{\cftchapterpagefont}{\normalfont}
  \renewcommand*{\cftchapterleader}{ \textperiodcentered\space}
  \renewcommand*{\cftchapterafterpnum}{\cftparfillskip}
%%  \setpnumwidth{0em}
%%  \setpnumwidth{1.5em}
  \renewcommand*{\cftchapterfillnum}[1]{%
    {\cftchapterleader}\nobreak
    \hbox to 1.5em{\cftchapterpagefont ##1\hfil}\cftchapterafterpnum\par}
  \setrmarg{0.3\textwidth}
  \setlength{\unitlength}{\@tocrmarg}
  \addtolength{\unitlength}{1.5em}
  \let\oldcftpartformatpnum\cftpartformatpnum
  \renewcommand*{\cftpartformatpnum}[1]{%
    \hbox to\unitlength{{\cftpartpagefont ##1}}}
  \let\oldcftbookformatpnum\cftbookformatpnum
  \renewcommand*{\cftbookformatpnum}[1]{%
    \hbox to\unitlength{{\cftbookpagefont ##1}}}}


\newcommand*{\setupparasubsecs}{%
  \let\oldnumberline\numberline%
  \renewcommand*{\cftsubsectionfont}{\itshape}%
  \renewcommand*{\cftsubsectionpagefont}{\itshape}%
  \renewcommand{\l@subsection}[2]{%
    \ifnum\c@tocdepth > 1\relax%
      \def\numberline####1{\textit{####1}~}%
      \leftskip=\cftsubsectionindent%
      \rightskip=\@tocrmarg%
%%      \advance\rightskip 0pt plus \hsize % uncomment this for raggedright
%%      \advance\rightskip 0pt plus 2em    % uncomment this for semi-ragged
      \parfillskip=\fill%
      \ifhmode ,\ \else\noindent\fi%
      \ignorespaces% 
      {\cftsubsectionfont ##1}~{\cftsubsectionpagefont##2}%
       \let\numberline\oldnumberline\ignorespaces%
    \fi}}


\AtEndDocument{\addtocontents{toc}{\par}}%%% OK


\newcommand*{\setupmaintoc}{%
  \renewcommand{\contentsname}{Contents}
  \let\changetocdepth\oldchangetocdepth
  \let\precistoctext\oldprecistoctext
  \let\cftchapterfillnum\oldcftchapterfillnum
  \addtodef{\cftchapterbreak}{\par}{}
  \renewcommand*{\cftchapterfont}{\normalfont\sffamily}
  \renewcommand*{\cftchapterleader}{\sffamily\cftdotfill{\cftchapterdotsep}}
  \renewcommand*{\cftchapterafterpnum}{}
  \renewcommand{\cftchapterbreak}{\par\addpenalty{-\@highpenalty}}
  \setpnumwidth{2.55em}
  \setrmarg{3.55em}
  \setcounter{tocdepth}{2}
  \let\cftpartformatpnum\oldcftpartformatpnum
  \addtodef{\cftpartbreak}{\par}{}
  \let\cftbookformatpnum\oldcftbookformatpnum
  \addtodef{\cftbookbreak}{\par}{}
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{graphicx}
\ifpdf
  \usepackage[pdftex,
              plainpages=false,
              pdfpagelabels,
%%%  hyperfootnotes=false,
              bookmarksnumbered,
              colorlinks,
%              ocgcolorlinks, % this only works for pdflatex
             ]{hyperref} 
  \DeclareGraphicsRule{*}{mps}{*}{}
\else
  \usepackage[plainpages=false,
  pdfpagelabels,
%%%  hyperfootnotes=false,
  bookmarksnumbered,
  breaklinks,
  % colorlinks,
  ]{hyperref} 
  \usepackage{breakurl}
  \DeclareGraphicsRule{*}{eps}{*}{}
\fi
%%%  \usepackage{memhfixc} %% now called by hyperref


% this is a lillt special, using this one can change the link colors
% in the manual to blacnmk without changing any file, just use
%
% pdflatex "\def\MEMOIRblacklinks{}\input{memman.tex}"
%
\@ifundefined{MEMOIRblacklinks}{%
  \definecolor{linkcolour}{rgb}{0,0.2,0.6}
  \definecolor{citecolour}{rgb}{0,0.6,0.2}
  % \definecolor{filecolor}{rgb}{0,0.2,0.6}
  \definecolor{urlcolour} {rgb}{0.8,0,0.8}
}{%
  \typeout{Asked for black links, so that is what you are going to get}
  \definecolor{linkcolour}{rgb}{0,0,0}
  \definecolor{citecolour}{rgb}{0,0,0}
  % \definecolor{filecolor}{rgb}{0,0,0}
  \definecolor{urlcolour} {rgb}{0,0,0}
  \hypersetup{colorlinks}
}
\hypersetup{
    pdftitle={The memoir class},
    pdfauthor={Peter Wilson, maintained by Lars Madsen},
    linkcolor=linkcolour,citecolor=citecolour,
    filecolor=urlcolour,urlcolor=urlcolour,
  }

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%% Logos
\providecommand*{\tx}{TeX}
\providecommand*{\txbook}{\tx book}
\providecommand*{\ltx}{La\tx}
\providecommand*{\ltxe}{\ltx2e}
\providecommand*{\pdfltx}{pdf\ltx}
\providecommand*{\ixpdfltx}{\index{pdfLaTeX?\pdfltx}}
\providecommand*{\pixpdfltx}{\pdfltx\ixpdfltx}   % print & index pdfLaTeX
\providecommand*{\etx}{\texttt{etex}}
\providecommand*{\ixetx}{\index{etex?\etx}}
\providecommand*{\pixetx}{\etx\ixetx}            % print & index etex
\providecommand*{\xetx}{Xe\tx}
\providecommand*{\luatx}{Lua\tx}

\providecommand*{\ixxetx}{\index{XeTeX?\xetx}}
\providecommand*{\pixxetx}{\xetx\ixxetx}         % print & index XeTeX
\providecommand*{\TeXUG}{\tx{} Users Group}
\providecommand*{\tug}{\textsc{tug}}
\providecommand*{\ixtug}{\index{TUG?\tug}}
\providecommand*{\pixtug}{\tug\ixtug}            % print & index TUG

\providecommand*{\cTeXan}{Comprehensive \tx{} Archive Network}
\providecommand*{\ctan}{\textsc{ctan}}        % print CTAN
\providecommand*{\ixctan}{\index{CTAN?\ctan}} % index CTAN
\providecommand*{\pixctan}{\ctan\ixctan}      % print & index CTAN

\newcommand*{\ctt}{\textsc{ctt}}               % print CTT
\newcommand*{\ixctt}{\index{ctt?\ctt}}        % index CTT
\newcommand*{\pixctt}{\ctt\ixctt}             % print & index CTT
\newcommand*{\prtoc}{ToC}             % print ToC
\newcommand*{\prlof}{LoF}             % print LoF
\newcommand*{\prlot}{LoT}             % print LoT
\newcommand*{\ixtoc}{\index{ToC}}     % index ToC
\newcommand*{\ixlof}{\index{LoF}}     % index LoF
\newcommand*{\ixlot}{\index{LoT}}     % index LoT
\newcommand*{\toc}{\prtoc\ixtoc}      % print & index ToC
\newcommand*{\lof}{\prlof\ixlof}      % print & index LoF
\newcommand*{\lot}{\prlot\ixlot}      % print & index LoT
\newcommand*{\prfrontmatter}{front matter} % macros for frontmatter
\newcommand*{\prFrontmatter}{Front matter} 
\newcommand*{\ixfrontmatter}{\index{front matter?\prfrontmatter}}
\newcommand*{\pixfrontmatter}{\prfrontmatter\ixfrontmatter}
\newcommand*{\pixFrontmatter}{\prFrontmatter\ixfrontmatter}
\newcommand*{\prmainmatter}{main matter}  % macros for mainmatter
\newcommand*{\prMainmatter}{Main matter} 
\newcommand*{\ixmainmatter}{\index{main matter?\prmainmatter}}
\newcommand*{\pixmainmatter}{\prmainmatter\ixmainmatter}
\newcommand*{\pixMainmatter}{\prMainmatter\ixmainmatter}
\newcommand*{\prbackmatter}{back matter}  % macros for backmatter
\newcommand*{\prBackmatter}{Back matter} 
\newcommand*{\ixbackmatter}{\index{back matter?\prbackmatter}}
\newcommand*{\pixbackmatter}{\prbackmatter\ixbackmatter}
\newcommand*{\pixBackmatter}{\prBackmatter\ixbackmatter}

%%%%%%%% from Typo
\providecommand*{\alltx}{(La)\tx}
\providecommand*{\metafont}{Metafont}
\providecommand*{\pscript}{Post\-Script}
\providecommand*{\ixpscript}{\pscript\index{PostScript}}
\providecommand*{\pdf}{PDF}
\providecommand*{\pixpdf}{\pdf\index{PDF}}
%\providecommand*{\prog}[1]{\Prog{#1}}
%\providecommand*{\ixprog}[1]{\index{#1 program?\prog{#1} program}%
%                             \index{program!#1?\prog{#1}}}
%\providecommand*{\pixprog}[1]{\prog{#1}\ixprog{#1}}
%%\providecommand*{\ctt}{\texttt{ctt}}
%%\providecommand*{\ixtx}{\index{TeX?\tx}}
%%\providecommand*{\pixtx}{\tx\ixtx}
%%\providecommand*{\ixltx}{\index{LaTeX?\ltx}}
%%\providecommand*{\pixltx}{\ltx\ixltx}

\newcommand*{\theclass}{memoir}

%%% Print and Index macros
\newcommand*{\noidxnum}[1]{}

%% index @ in macrocode
\newcommand*{\idxatincode}{\index{@?\texttt{@}!in macro code}}
\newcommand*{\seeatincode}{see \Sref{sec:alltexcommands}}

% index marking
\newcommand{\idxmark}[1]{#1\markboth{#1}{#1}}
%%%% index sup/sub and sub \indexsupsubmain{main}{sub}
\newcommand*{\indexsupsubmain}[2]{\index{#1!#2}\index{#2}}
%%%% index pair of sup/sub items
\newcommand*{\indextwo}[2]{\index{#1!#2}\index{#2!#1}}
%%% index pair of sup/sub/sub
\newcommand*{\indexthree}[3]{\index{#1!#2!#3}\index{#2!#1!#3}}

%%% \typesubidx{sub} -> \index{type!sub} Index a type subitem
\newcommand*{\typesubidx}[1]{\index{type!#1}}
%%% \seeonceidx{main}{sub} %% index main (see sub), and index sub
\newcommand*{\seeonceidx}[2]{%
  \@ifundefined{s1#2s1}%
    {\global\@namedef{s1#2s1}{?!?}\index{#1!#2|see{#2}}\index{#2}}% %|
    {\index{#2}}}
%%% \facesubseeidx{sub} %% index typeface (see sub), and index sub
\newcommand*{\facesubseeidx}[1]{\seeonceidx{typeface}{#1}}
\newcommand*{\Pfontfam}[1]{\texttt{#1}}   % print name of a fontfamily
\newcommand*{\pfontfam}[1]{\Pfontfam{#1}%  
             \index{#1 fontfam?\Pfontfam{#1} (fontfamily)}%
             \index{fontfamily!#1?\Pfontfam{#1}}}  % print/index fontfamily

\newcommand*{\Ppstyle}[1]{\textsl{#1}}
\newcommand*{\pstyle}[1]{\Ppstyle{#1}%
            \index{#1 pages?\Ppstyle{#1} (pagestyle)}%
            \index{pagestyle!#1?\Ppstyle{#1}}}            % pagestyle
\newcommand*{\Pcstyle}[1]{\textsl{#1}}
\newcommand*{\cstyle}[1]{\Pcstyle{#1}%
            \index{#1 chaps?\Pcstyle{#1} (chapterstyle)}%
            \index{chapterstyle!#1?\Pcstyle{#1}}}          % chapterstyle
\newcommand*{\Phstyle}[1]{\textsl{#1}}                    
\newcommand*{\hstyle}[1]{\Phstyle{#1}%
             \index{#1 heads?\Phstyle{#1} (headstyles)}%
             \index{headstyles!#1?\Phstyle{#1}}}      % headstyles
\newcommand*{\Pclass}[1]{\textsf{#1}}
\newcommand*{\Lclass}[1]{\Pclass{#1}%
            \index{#1 class?\Pclass{#1} (class)}%
            \index{class!#1?\Pclass{#1}}}                % class name
\newcommand*{\Iclasssub}[2]{\index{#1 class?\Pclass{#1} (class)!#2}}
\newcommand*{\Mname}{\Pclass{memoir}}                    % Print memoir
\newcommand*{\Ppack}[1]{\textsf{#1}}
\newcommand*{\Lpack}[1]{\Ppack{#1}%
            \index{#1 pack?\Ppack{#1} (package)}%
            \index{package!#1?\Ppack{#1}}}              % package name
\newcommand*{\Popt}[1]{\textsf{#1}}
\newcommand*{\Lopt}[1]{\Popt{#1}%
            \index{#1 opt?\Popt{#1} (option)}%
            \index{option!#1?\Popt{#1}}}               % option name
\newcommand*{\Pe}[1]{\texttt{#1}}                      % print env name
%%% 2009/12/19 added \ixenv & changed \Ie to use it
\newcommand*{\ixenv}[1]{\index{#1 env?\Pe{#1} (environment)}% index env
                        \index{environment!#1?\Pe{#1}}}
\newcommand*{\Ie}[1]{\Pe{#1}\ixenv{#1}}                % print & index env
\newcommand*{\Pcn}[1]{\texttt{#1}}                     % print counter name
\newcommand*{\Icn}[1]{\texttt{#1}\index{#1 cou?\Pcn{#1} (counter)}%
                                \index{counter!#1?\Pcn{#1}}}
\newcommand*{\Itt}[1]{\texttt{#1}\index{#1tt?\texttt{#1}}}
\newcommand*{\file}[1]{\texttt{#1}}              % print a file name
\newcommand*{\ixfile}[1]{%                       % index a file name
            \index{#1 file?\file{#1} (file)}%
            \index{file!#1?\file{#1}}}
\newcommand*{\pixfile}[1]{\file{#1}\ixfile{#1}} % print & index a file name
% print and index a length
\newcommand*{\lnc}[1]{\cmdprint{#1}%
  \index{\expandafter\@gobble\string#1len?\string\cmdprint{\string#1} (length)}%
  \index{length!\expandafter\@gobble\string#1len?\string\cmdprint{\string#1}}}

\newcommand*{\posarg}[1]{\textsf{#1}}   % print positioning argument
% index a positioning argument
\newcommand*{\ixposarg}[1]{%
             \index{#1 (position argument)?\posarg{#1} (position argument)}}
% print and index a positioning argument
\newcommand*{\pixposarg}[1]{\posarg{#1}\ixposarg{#1}} 

%     print and index a counter representation
\newcommand*{\pcrep}[1]{\texttt{#1}}
\newcommand*{\ixcrep}[1]{\index{#1 tt?\pcrep{#1}}%
                         \index{counter representation!#1 tt?\pcrep{#1}}}
\newcommand*{\Icrep}[1]{\texttt{#1}\index{#1 tt?\texttt{#1}}}%                % counter representation
\renewcommand*{\Icrep}[1]{\pcrep{#1}\ixcrep{#1}}%   % print & index counter rep
\newcommand*{\pixcrep}[1]{\pcrep{#1}\ixcrep{#1}} % print & index counter rep

% print (and index) TeX keywords                                
\newcommand*{\pkey}[1]{\texttt{#1}}       % TeX keywords
\newcommand*{\pixkey}[1]{\pkey{#1}\index{#1 key?\pkey{#1} (keyword)}%
\index{keyword!#1?\pkey{#1}}}

\newcommand*{\patexp}{@-expression}        %  print @-expression
\newcommand*{\ixatexp}{%
             \index{@-expression?\patexp}} % index @-expression
\newcommand*{\pixatexp}{\patexp\ixatexp}   % print & index @-expression

\newcommand*{\Pprog}[1]{\textsf{#1}}       % print program name
\newcommand*{\Iprog}[1]{\index{#1 prog?\Pprog{#1} (program)}%
                        \index{program!#1?\Pprog{#1}}} % index program name
\newcommand*{\Iprogsub}[2]{\index{#1 prog?\Pprog{#1} (program)!#2}}
\newcommand*{\Lprog}[1]{\Pprog{#1}\Iprog{#1}}      % print & index program name
\DeclareRobustCommand{\Pmakeindex}{\Pprog{MakeIndex}}
\DeclareRobustCommand{\Imakeindex}{\Iprog{MakeIndex}}
\DeclareRobustCommand{\Lmakeindex}{\Lprog{MakeIndex}}
\DeclareRobustCommand{\Pbibtex}{\Pprog{BibTeX}}
\DeclareRobustCommand{\Ibibtex}{\Iprog{BibTeX}}
\DeclareRobustCommand{\Lbibtex}{\Lprog{BibTeX}}

% print and index an \if... \piif{if...}
\newcommand*{\piif}[1]{\cs{#1}\index{#1?\cs{#1}}}

% index command \!
\newcommand*{\iexcl}{\index{"!?\cs{!}}}    
% print and index \!
\newcommand*{\pixabang}{\cmdprint{\!}\index{"!?\string\cs{}\texttt{"!}}}
% print and index \\!
\newcommand*{\pixslashbang}{\cmdprint{\\!}\index{"\"\"!?\string\cmdprint{\\}\texttt{"!}}}

\DeclareRobustCommand{\senv}[1]{\texttt{\bs begin\{#1\}}} % print \begin{env}
\DeclareRobustCommand{\eenv}[1]{\texttt{\bs end\{#1\}}}   % print \end{env}

\newcommand*{\listofx}{`List of\ldots'}

\newcommand*{\Note}{\textbf{NOTE:}}

\newcommand*{\ptrue}{\texttt{true}}   % print TRUE
\newcommand*{\pfalse}{\texttt{false}} % print FALSE
\DeclareRobustCommand{\btitle}[1]{\textit{#1}} % print a book/article/etc title


%%% numbers
\let\Mfrac\slashfrac
\newcommand*{\ratio}[2]{{\ensuremath #1 \raise0.2ex\hbox{:} #2}}% or perhaps 0.15ex
\providecommand*{\abyb}[2]{\ensuremath{#1 \times #2}}       %   e.g., 3 x 4
\providecommand*{\abybm}[3]{\ensuremath{#1 \times #2}\:#3}  % e.g., 3 x 4 cm
\providecommand*{\atob}[2]{\ensuremath{#1\!:\!#2}}          % e.g., 3:4


\DeclareRobustCommand*{\lb}{\texttt{\char`\{}}          % prints {
\DeclareRobustCommand*{\rb}{\texttt{\char`\}}}          % prints }

%% A couple of shorthands
\newcommand*{\tmri}{\mathrm{i}}
\newcommand*{\tmrx}{\mathrm{x}}

\newcommand*{\foredge}{fore-edge}
\newlength{\pwlayi}\setlength{\pwlayi}{0.45\textwidth} % 
\newlength{\pwlayii}\setlength{\pwlayii}{0.45\pwlayi}

\DeclareRobustCommand{\Vprint}[1]{\texttt{\string#1}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% stuff for demoing fonts
\DeclareFontFamily{T1}{bodoni}{}
\DeclareFontShape{T1}{bodoni}{m}{n}{ <-> bodonirg9a }{}
%% \usethisfont[encoding]{size}{baselineskip}{family}{series}{shape}
\newcommand*{\usethisfont}[6][T1]{%
  \fontencoding{#1}\fontsize{#2}{#3}\fontfamily{#4}\fontseries{#5}%
  \fontshape{#6}\selectfont}
\newcommand*{\termfont}[3]{%
  \usethisfont{25}{30}{#1}{#2}{#3}}
\newcommand*{\UCalphabet}{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z \&}
\newcommand*{\LCalphabet}{a b c d e f g h i j k l m n o p q r s t u v w x y z
                          1 2 3 4 5 6 7 8 9 0 ! ? fi fl}
\newcommand*{\fox}{It was a dark and stormy night. 
                   While all the good men were coming to the aid of the
                   party, the quick brown dog had jumped over the fast red fox 
                   to its great surprise. The cattle had wound slowly
                   o'er the lea and I was in the dark.}
\newcommand*{\Kafka}{`But aren't Kafka's Schlo{\ss} and {\AE}sop's
{\OE}uvres often na{\"\i}ve vis-\`a-vis the d{\ae}monic ph{\oe}nix's
official r\^ole in fluffy souffl\'es?' }
\newcommand*{\namesAZ}{ {\AA}ngel\aa\ Beatrice Claire
  Diana \'Erica Fran\c{c}oise Ginette H\'el\`ene Iris
  Jackie K\=aren {\L}au\.ra Mar{\'\i}a N\H{a}ta{\l}{\u\i}e {\O}ctave
  Pauline Qu\^eneau Roxanne Sabine 
%%  T\~a{\'\j}a 
  T\~aja 
  Ur\v{s}ula  Vivian Wendy Xanthippe Yv{\o}nne Z\"azilie }



%% sans label for labelled list
\newcommand*{\sflabel}[1]{\hspace\labelsep \normalfont\sffamily #1}
%% italic label for labelled list
\newcommand*{\itlabel}[1]{\hspace\labelsep \normalfont\itshape #1}


%%%%%% stuff for new LaTeX code environment

% \zeroseps sets list before/after skips to minimum values
\newcommand*{\@zeroseps}{\setlength{\topsep}{\z@}
                        \setlength{\partopsep}{\z@}
                        \setlength{\parskip}{\z@}}
\newlength{\gparindent} \setlength{\gparindent}{\parindent}
\setlength{\gparindent}{0.5\parindent}
% now we can do the new environment. This has no extra before/after
% spacing.
% \LMnote{2010/06/09}{Experimenting with a bit of space before and
% after, looks a bit better}
\newenvironment{lcode}{\@zeroseps
  \nopagebreak
  \vskip0.4em plus 0.1em minus 0.2em
  \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
  \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
    \vspace{-\baselineskip}
  \vskip0.6em plus 0.1em minus 0.2em
   \noindent}

%%%%% LaTeX syntax
%%%% control space above/below center environment
\newcommand*{\tightcenter}{%
  \topsep=0.25\onelineskip\trivlist \centering\item\relax}
\def\endtightcenter{\endtrivlist}
\LMnote{2010/06/25}{Added a \cs{crcr} here, a bit of a trick, but now
  the last line in syntax does not longer need to end with \\}
\newenvironment{syntax}{\begin{tightcenter}
                        \begin{tabular}{|p{0.9\linewidth}|} \hline}%
                       {\crcr\hline
                        \end{tabular}
                        \end{tightcenter}}

%%%%% for demoing chapterstyles
\newcommand*{\chaptext}[1]{The above is a demonstration of the \textit{#1} 
chapterstyle. It is one of several styles that come as part of the
\Pclass{memoir} class.}

%%%\renewcommand*{\theHchapter}{\thesheetsequence.\arabic{chapter}}

\newcount\savechapcnt
\newcount\demochapcnt
\newcount\saveseccnt
\newcount\savesubseccnt
\demochapcnt=0
%%\newcommand*{\theHc@demochapcnt}{\thefigure.\arabic{\c@demochapcnt}}
\newcount\savefigcnt
\newcount\saveftncnt
\newcommand*{\demochapcolor}{\definecolor{shadecolor}{gray}{0.75}}
\LMnote{2011/05/25}{I've moved the demochaps to an appendix, so
  \cs{@chapapp} need a little redoing}
\newenvironment{demochap}[2][\onelineskip]{%
%  \typeout{Chapter value going in: \thechapter}
  \savechapcnt=\c@chapter
  \saveseccnt=\c@section
  \savesubseccnt=\c@subsection
  \saveftncnt=\c@footnote
  \c@chapter=\demochapcnt
%%  \stepcounter{demochapcnt}
  \counterwithout*{figure}{chapter}
  \begin{figure}[htbp]
%%%    \definecolor{shadecolor}{gray}{0.75}
    \demochapcolor
    \begin{shaded}
      \savefigcnt=\c@figure
      \begingroup
%%        \hrule
        \let\@chapapp\chaptername% such that appendix does not disturb
%        \renewcommand{\theHchapter}{\thepage.\thechapter.showcase}
        \renewcommand\thechapter{\arabic{chapter}}
        \vspace*{#1}
        \chapterstyle{#2}
        \let\clearforchapter\relax
        \let\insertchapterspace\relax
        \renewcommand*{\addcontentsline}[3]{}
        \renewcommand*{\thispagestyle}[1]{}
        \renewcommand*{\markboth}[2]{}
        \let\refstepcounter\stepcounter
        \chapter{Demonstration of the #2 chapter style}
        \chaptext{#2}
        \vspace{\onelineskip}
        \hrule
      \endgroup
    \end{shaded}
    \global\demochapcnt=\c@chapter
    \ifnum\demochapcnt>9\relax
      \global\demochapcnt=0\relax
    \fi
    \c@chapter=\savechapcnt
%    \advance\c@chapter\m@ne
%    \renewcommand{\theHchapter}{\thepage.\thechapter-\the\demochapcnt.\thesheetsequence.showcase}
%    \refstepcounter{chapter}%
%    \stepcounter{chapter}
    \begin{center}
      \caption{The #2 chapterstyle}\label{dc#2}
    \end{center}
    \savefigcnt=\c@figure
    \global\advance\savefigcnt\m@ne
%%    \gdef\theHchapter{\thefigure.\thechapter}
    }{%\gdef\theHchapter{\thechapter}
  \end{figure}
  \counterwithin{figure}{chapter}
  \global\c@chapter=\savechapcnt
  \global\c@section=\saveseccnt
  \global\c@subsection=\savesubseccnt
  \global\c@footnote=\saveftncnt}

\newenvironment{demochap*}[2][\onelineskip]{
  \let\DCcaption\caption
  \renewcommand\caption[1]{\DCcaption{##1. This style requires the
      \Lpack{graphicx} package}}
  \begin{demochap}[#1]{#2}}{\end{demochap}}
  

%%% comma separated in-line items 
\let\litemize\itemize \let\endlitemize\enditemize
\renewenvironment{litemize}{\renewcommand{\item}{\unskip, }}{}
\newenvironment{lineitems}{\litemize\renewcommand{\item}{\unskip, }}%
                          {\endlitemize\unskip }

%% typeset stuff in a box
\newdimen\showbinset
\newcommand{\showit}[1]{%
  \setlength{\showbinset}{\linewidth}%
  \addtolength{\showbinset}{-2\fboxsep}%
  \addtolength{\showbinset}{-2\fboxrule}%
  \par\vspace{0.5\onelineskip}\noindent
  \fbox{\parbox{\showbinset}{{#1}}\vspace{0.5\onelineskip}}}
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% VERSALS

% Save file as: DROP.STY               Source: FILESERV@SHSU.BITNET  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  DROP.DOC <February 17, 1988>
%  Macro for dropping and enlarging the first letter(s) of a paragraph.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Macro written by David G. Cantor, and published Fri, 12 Feb 88, in
%  TeXhax, 1988 #16.  
%  Internet:  dgc@math.ucla.edu
%  UUCP:      ...!{ihnp4, randvax, sdcrdcf, ucbvax}!ucla-cs!dgc
%
%  Modified for use with LaTeX by Dominik Wujastyk, February 17, 1988
%  Internet:   dow@wjh12.harvard.edu
%  Bitnet:     dow@harvunxw.bitnet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  This LaTeX macro is for dropping and enlarging the first letter(s) of a
%  paragraph.  The argument may be one or more letters.
%
%  Here is an example of its usage:
%
%  \documentstyle[drop]{article}
%  \begin{document}
%    \drop{IN} THE beginning God created the heaven and the earth.  Now the
%    earth was unformed and void, and darkness was upon the face of the
%    deep; and the spirit of God hovered over the face of the waters.
%  \end{document}
%
%  Which will produce something along these lines:
%
%  I I\  I THE beginning God  created the heaven and  the earth.
%  I I \ I Now the earth was unformed and void, and darkness was
%  I I  \I upon the face of the deep; and the spirit of God hov-
%  ered over the face of the waters.
%
%  In the first instance the macro will pause during LaTeX processing and 
%  ask you for the font you wish to use for you drop capital.  When you
%  have something that looks good, then comment out box one in DROP.STY,
%  and comment in box two, replacing "cmr10 scaled \magstep5" with the font
%  of your choice.
%
%  In my opinion (DW) there are no fonts available in the standard
%  TeX/LaTeX set that are ideal for this use, unless you go down to 9pt or 
%  8pt for your text face, and this is too small.  If you have Metafont you
%  should consider generating a cmr17 font at a magstep of two (about 25pt)
%  or three (about 30pt), or even more, depending on the point size of your
%  main text.  Why not go the whole hog and design some really fancy 
%  capitals from scratch!
%
%%%%%%%%%%%%%%%%%%%%% BOX ONE %%%%%%%%%%%%%%%%%%%%%%%%%
%\typein[\dropinitialfont]{Font for Dropped initial:}  %
%\font\largefont \dropinitialfont                      %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%%%%%%%%%%%%%%%%%%%% BOX TWO %%%%%%%%%%%%%%%%%%%%%%%%%
%\font\largefont= cmr10 scaled \magstep5              %
%\font\largefont= cmbx10 scaled \magstep5              %
%\font\largefont= cmbx17 scaled \magstep3              %
\font\largefont= cmr17 scaled \magstep5              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\drop#1#2{{\noindent
    \setbox0\hbox{\largefont #1}\setbox1\hbox{#2}\setbox2\hbox{(}%
    \count0=\ht0\advance\count0 by\dp0\count1\baselineskip
    \advance\count0 by-\ht1\advance\count0by\ht2
    \dimen1=.5ex\advance\count0by\dimen1\divide\count0 by\count1
    \advance\count0 by1\dimen0\wd0
    \advance\dimen0 by.25em\dimen1=\ht0\advance\dimen1 by-\ht1
    \global\hangindent\dimen0\global\hangafter-\count0
    \hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
    \dp0=0in\ht0=0in\box0}#2}

% end of DROP.STY
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\newcommand{\versal}[1]{{\noindent
    \setbox0\hbox{\largefont #1}%
    \count0=\ht0                   % height of versal
    \count1=\baselineskip          % baselineskip
    \divide\count0 by \count1      % versal height/baselineskip
    \dimen1 = \count0\baselineskip % distance to drop versal
    \advance\count0 by 1\relax     % no of indented lines
    \dimen0=\wd0                   % width of versal
    \global\hangindent\dimen0      % set indentation distance
    \global\hangafter-\count0      % set no of indented lines
    \hskip-\dimen0\setbox0\hbox to\dimen0{\raise-\dimen1\box0\hss}%
    \dp0=0in\ht0=0in\box0}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% END VERSALS


\newlength{\gparskip} \setlength{\gparskip}{\parskip}

\typeout{Defining listeg, egsource, egresult, etc}
\newenvironment{listeg}{%
  \list{}{%
    \listparindent\z@
    \itemindent\listparindent
    \parsep\z@
    \leftmargin\gparindent
    \rightmargin\leftmargin}
    \item\relax}{\endlist}

%%% pair with egresult
% \begin{egsource}{label}
\newcommand*{\egsourcecolor}{\definecolor{shadecolor}{gray}{0.9}}
\newenvironment{egsource}[1]{%
  \parskip\z@ \topsep\z@% 
  \egsourcecolor
  \shaded
  \listeg\centerline{Source for example~\ref{#1}}%\label{#1}
  \vspace{\onelineskip}
  \small\setlength{\baselineskip}{\onelineskip}\nobreak\verbatim}%
  {\endverbatim\endlisteg\endshaded}%\vskip\onelineskip\noindent}

%%\newcommand*{\captegsource}{Source for example}
%%\newfloat[chapter]{tegsource}{los}{\captegresult}
%%\newcommand*{\listegsourcesname}{List of source code examples}
%%\newlistof{listofegsources}{los}{\listegsourcesname}
%%\newlistentry[chapter]{tegsource}{los}{0}

%%\renewenvironment{egsource}[1]{%
%%\tegsource
%%  \parskip\z@ \topsep\z@% 
%%  \egsourcecolor
%%  \shaded
%%  \listeg\centerline{Source for example~\ref{#1}}%\
%%  \vspace{\onelineskip}
%%  \small\setlength{\baselineskip}{\onelineskip}\nobreak\verbatim}%
%%  {\endverbatim\endlisteg\endshaded%}
%%\endtegsource}


\newcommand*{\Hline}{\mbox{}\hrulefill\mbox{}} % line across the page


\newcommand*{\shadecodecolor}{\definecolor{shadecolor}{gray}{0.93}}
\newenvironment{shadecode}{\@zeroseps
  \shadecodecolor
  \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
  \shaded
  \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
   \vspace{-\baselineskip}%
   \endshaded
   \noindent}
  
\newenvironment{typeseteg}{%
  \list{}{%
    \listparindent\gparindent
    \itemindent\listparindent
    \parsep\gparskip
    \leftmargin\gparindent
    \rightmargin\leftmargin}
    \item\relax}{\endlist}

\newcommand*{\captegresult}{Typeset example}
\newfloat[chapter]{tegresult}{loe}{\captegresult}
\newcommand*{\listegresultsname}{List of typeset examples}
\newlistof{listofegresults}{loe}{\listegresultsname}
\newlistentry[chapter]{tegresult}{loe}{0}

\newcommand*{\egresultcolor}{\definecolor{shadecolor}{gray}{0.9}}
%%% pair with egsource
% \begin{egresult}[caption]{label}
\newenvironment{egresult}[2][]{%
  \begin{tegresult}
  \egresultcolor
\begin{shaded}
  \caption{#1}\label{#2}
  \vspace{-0.75\onelineskip}
  \Hline
  \begin{typeseteg}}%
  {\end{typeseteg}%
   \vspace{-0.5\onelineskip}
   \Hline
\end{shaded}
\end{tegresult}}

\newenvironment{egresultplain}[2][]{%
  \begin{tegresult}
  \egresultcolor
\begin{shaded}
  \caption{#1}\label{#2}
  \begin{typeseteg}}%
  {\end{typeseteg}%
\end{shaded}
\end{tegresult}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% More stuff for showing examples

\newcommand*{\egstart}[1][0pt]{\par\begingroup
  \begin{adjustwidth}{-#1}{-#1}%
  \centering
  \begin{minipage}{0.45\linewidth}}
\newcommand*{\egmid}{%
  \end{minipage}\hfill\begin{minipage}{0.45\linewidth}}
\newcommand*{\egend}{%
  \end{minipage}\end{adjustwidth}\endgroup\par}

\newoutputstream{egout}
  \openoutputfile{\jobname.ego}{egout}

\newcommand*{\shadefigurecolor}{\definecolor{shadecolor}{gray}{0.75}}
\newenvironment{shadefigure}{%
  \begin{figure}
  \centering
  \shadefigurecolor
  \begin{shaded}}%
  {\end{shaded}\end{figure}}

\newcommand*{\shadetablecolor}{\definecolor{shadecolor}{gray}{0.75}}
\newenvironment{shadetable}{%
  \begin{table}
  \centering
  \shadetablecolor
  \begin{shaded}}%
  {\end{shaded}\end{table}}

%%%%% Option, etc description list
\newenvironment{plainlist}%
               {\list{}{\labelwidth\z@ \itemindent-\leftmargin
                        \let\makelabel\plainlistlabel}}%
               {\endlist}
\newcommand*{\plainlistlabel}[1]{\hspace\labelsep
                                 \normalfont #1}


\DeclareRobustCommand{\ls}[1]{\texttt{\char`\\#1} (length)}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% FROM TITLEPAGES.TEX

%%%%%% for FontSite fonts
\newcommand*{\FSfont}[1]{%
  \fontfamily{#1}\selectfont}
%%%%% for `standard' LaTeX fonts
\newcommand*{\LXfont}[1]{%
  \fontfamily{#1}\selectfont}

\newcommand*{\boxminipage}{%
  \@ifnextchar [%]
    \@ibxminipage
    {\@iiibxminipage c\relax[s]}}
\def\@ibxminipage[#1]{%
  \@ifnextchar [%]
    {\@iibxminipage{#1}}%
    {\@iiibxminipage{#1}\relax[s]}}
\def\@iibxminipage#1[#2]{%
  \@ifnextchar [%]
    {\@iiibxminipage{#1}{#2}}%
    {\@iiibxminipage{#1}{#2}[#1]}}
\let\@bxminto\@empty
\def\@iiibxminipage#1#2[#3]#4{%
  \ifx\relax#2\else
    \setlength\@tempdimb{#2}%
    \def\@bxminto{to\@tempdimb}%
  \fi
  \leavevmode
  \@pboxswfalse
  \if #1b\vbox
  \else
    \if #1t\vtop
    \else
      \ifmmode \vcenter
      \else \@pboxswtrue $\vcenter
      \fi
    \fi
  \fi
%  \@bxminto
  \bgroup%          outermost vbox
    \hsize #4
    \hrule\@height\fboxrule
    \hbox\bgroup%   inner hbox
      \vrule\@width\fboxrule \hskip\fboxsep 
        \vbox \@bxminto
        \bgroup% innermost vbox
        \vskip\fboxsep
        \advance\hsize -2\fboxrule \advance\hsize -2\fboxsep
        \textwidth\hsize \columnwidth\hsize
        \@parboxrestore
        \def\@mpfn{mpfootnote}\def\thempfn{\thempfootnote}\c@mpfootnote\z@
        \let\@footnotetext\@mpfootnotetext
        \let\@listdepth\@mplistdepth \@mplistdepth\z@
        \@minipagerestore\@minipagetrue
        \everypar{\global\@minipagefalse\everypar{}}}

\def\endboxminipage{%
  \par\vskip-\lastskip
  \ifvoid\@mpfootins\else
    \vskip\skip\@mpfootins\footnoterule\unvbox\@mpfootins\fi
  \vskip\fboxsep
  \egroup%    end innermost vbox
  \hskip\fboxsep \vrule\@width\fboxrule
  \egroup%    end hbox
  \hrule\@height\fboxrule
  \egroup%    end outermost vbox
  \if@pboxsw $\fi}

\newlength{\tpheight}\setlength{\tpheight}{0.9\textheight}
\newlength{\txtheight}\setlength{\txtheight}{0.9\tpheight}
\newlength{\tpwidth}\setlength{\tpwidth}{0.9\textwidth}
\newlength{\txtwidth}\setlength{\txtwidth}{0.9\tpwidth}
\newlength{\tdrop} % (already defined)

\newenvironment{showtitle}{%
  \begin{boxminipage}[c][\tpheight]{\tpwidth}
  \centering\begin{vplace}\begin{minipage}[c][\txtheight]{\txtwidth}}%
{\end{minipage}\end{vplace}\end{boxminipage}}

\definecolor{Dark}{gray}{.2}
\definecolor{Medium}{gray}{.6}
\definecolor{Light}{gray}{.8}

\newcommand*{\plogo}{\fbox{$\mathcal{PL}$}}

%%%%%%%%%%%%%%%%%%


%%%%%%%%% section head designs
\newcommand*{\defaultsecheads}{
  \setsecheadstyle{\normalfont\Large\bfseries\raggedright}
    \setsecindent{0pt}
    \setbeforesecskip{-3.5ex plus -1ex minus -.2ex}
    \setaftersecskip{2.3ex plus .2ex}
  \setsubsecheadstyle{\normalfont\large\bfseries\raggedright}
    \setsubsecindent{0pt}
    \setbeforesubsecskip{-3.25ex plus -1ex minus -.2ex}
    \setaftersubsecskip{1.5ex plus .2ex}
  \setsubsubsecheadstyle{\normalfont\bfseries\raggedright}
    \setsubsubsecindent{0pt}
    \setbeforesubsubsecskip{-3.25ex plus -1ex minus -.2ex}
    \setaftersubsubsecskip{1.5ex plus .2ex}
  \setparaheadstyle{\normalfont\bfseries}
    \setparaindent{0pt}
    \setbeforeparaskip{3.25ex plus 1ex minus .2ex}
    \setafterparaskip{-1em}
  \setsubparaheadstyle{\normalfont\bfseries}
    \setsubparaindent{0pt}
    \setbeforesubparaskip{3.25ex plus 1ex minus .2ex}
    \setaftersubparaskip{-1em}
}

%%%%%%%%%%%%%% Manual layout and design elements

\newcommand*{\memmansecheads}{
  \setsecheadstyle{\normalfont\scshape\raggedright}
    \setsecindent{0pt}
    \setbeforesecskip{-1.333\onelineskip plus -0.5\onelineskip minus -0.5\onelineskip}
    \setaftersecskip{.667\onelineskip plus 0.1\onelineskip}
%%% surround = 2 lines (1.333/.667)
%%% surround = 1 line (.667/.333)
  \setsubsecheadstyle{\normalfont\sffamily\raggedright}
    \setsubsecindent{0pt}
    \setbeforesubsecskip{-.667\onelineskip plus -0.5\onelineskip minus -0.5\onelineskip}
    \setaftersubsecskip{0.333\onelineskip plus 0.1\onelineskip}
%%% surround = 1 line (.667/.333)
  \setsubsubsecheadstyle{\normalfont\itshape\raggedright}
    \setsubsubsecindent{0pt}
    \setbeforesubsubsecskip{-0.667\onelineskip plus -0.25\onelineskip minus -0.25\onelineskip}
    \setaftersubsubsecskip{0.333\onelineskip plus 0.1\onelineskip}
%%% no surround
  \setparaheadstyle{\normalfont\sffamily}
    \setparaindent{0pt}
    \setbeforeparaskip{1.0\onelineskip plus 0.5\onelineskip minus 0.25\onelineskip}
    \setafterparaskip{-1em}
  \setsubparaheadstyle{\normalfont\sffamily}
    \setsubparaindent{0pt}
    \setbeforesubparaskip{1.0\onelineskip plus 0.5\onelineskip minus 0.25\onelineskip}
    \setaftersubparaskip{-1em}
}


%%%%%% hypermarks in index
%    from email from Lars Madsen
\providecommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries \ifx\@tempa\@tempb @ \else #1\fi\vskip\onelineskip\par}}
% extended to add booksmarks for each letter group.
\renewcommand{\doidxbookmark}[1]{{\def\@tempa{Symbols}\def\@tempb{#1}%
  \centering\bfseries \ifx\@tempa\@tempb %
  Analphabetics 
  \phantomsection%
  \pdfbookmark[0]{Analphabetics}{Analphabetics-idx}%
%  \label{AnalphabeticsAnalphabeticsAnalphabetics-idx}%
  \else 
  #1%
  \phantomsection%
  \pdfbookmark[0]{#1}{#1-idx}%
%  \label{#1#1#1-idx}%
  \fi%
  \vskip\onelineskip\par}}
\providecommand{\hyperpage}[1]{#1}


%%% need more space for ToC page numbers
\setpnumwidth{2.55em}
\setrmarg{3.55em}

%%% need more space for ToC section numbers
\cftsetindents{section}{1.5em}{3.0em}
\cftsetindents{subsection}{4.5em}{3.9em}
\cftsetindents{subsubsection}{8.4em}{4.8em}
\cftsetindents{paragraph}{10.7em}{5.7em}
\cftsetindents{subparagraph}{12.7em}{6.7em}

%%% and for LoF and LoT numbers
\cftsetindents{figure}{0em}{3.0em}
\cftsetindents{table}{0em}{3.0em}

%%% set up the page layout
\settrimmedsize{11in}{210mm}{*}
\setlength{\trimtop}{0pt}
\setlength{\trimedge}{\stockwidth}
\addtolength{\trimedge}{-\paperwidth}
\settypeblocksize{7.75in}{33pc}{*}
\setulmargins{4cm}{*}{*}
\setlrmargins{1.25in}{*}{*}
\setmarginnotes{17pt}{51pt}{\onelineskip}
\setheadfoot{\onelineskip}{2\onelineskip}
\setheaderspaces{*}{2\onelineskip}{*}
\LMnote{2010/02/05}{added \cs{setsidefeet} to get 
it to use the new width for the  margin par}
\setsidefeet{\marginparsep}{9em}%
   {\onelineskip}{0pt}%
   {\normalfont\footnotesize}{\textheight}%
\checkandfixthelayout



%%% empty pagestyle for Part pages
\aliaspagestyle{part}{empty}

\bibliographystyle{alpha}

%%% subfigures and tables
\newsubfloat{figure}
\newsubfloat{table}
\setcounter{lofdepth}{2}

%%% Set oldstylenums (which here are taken from CMR, not Palatino)
\DeclareRobustCommand{\Moldstyle}[1]{{\Large\oldstylenums{#1}}}

%%%%% Pavlic `fix' for index

\let\original@wrindexm@m\@wrindexm@m
\def\@wrindexm@m{\catcode`\ =10 \original@wrindexm@m}

% for letter group bookmarks for glossary items
\newcommand\doglobookmark[1]{%
  \def\@tempa{Symbols}\def\@tempb{#1}%
  \ifx\@tempa\@tempb %
  \phantomsection\pdfbookmark[0]{Analphabetics}{Analphabetics-glo}%
  \else%
  \phantomsection\pdfbookmark[0]{#1}{#1-glo}%
  \fi%
}


%%%% SNIPLETS %%%%
\newcounter{sniplet}
\counterwithin{sniplet}{chapter}
\newcommand*\snipletname{Sniplet}
\newcommand*\snipletref[1]{\snipletname~\ref{#1} on~\pref{#1}}
\newenvironment{sniplet}[1][]{
  \refstepcounter{sniplet}
  \edef\mem@e{\@ifnotmtarg{#1}{\space(#1)}}
  \section*{\snipletname~\thesniplet\mem@e}
  \phantomsection
  \addcontentsline{toc}{section}{\snipletname\ \thesniplet\mem@e}
  \renewenvironment{lcode}{%\@zeroseps
    \renewcommand{\verbatim@startline}{\verbatim@line{\hskip\gparindent}}
    \small\setlength{\baselineskip}{\onelineskip}\verbatim}%
  {\endverbatim
    \vspace{-0.75\baselineskip}%
    \noindent}
}{}

\let\normalchangetocdepth\changetocdepth
\newcommand\sniplettoc{%
  \setcounter{@memmarkcntra}{\value{tocdepth}}%
  \begingroup%
  \let\changetocdepth\@gobble%
  \normalchangetocdepth{-10}%
  \cftinsertcode{start-sniplets}{\normalchangetocdepth{3}}%
  \cftinsertcode{end-sniplets}{\normalchangetocdepth{-10}}%
  \let\tocheadstart\relax%\@gobble
  % \printtoctitle\@gobble
  \renewcommand\printtoctitle[1]{\section*{Sniplet overview}}%
  \let\aftertoctitle\relax%
  \let\printtocnonum\relax%
  \let\precistoctext\@gobble%
  \setlength\cftsectionindent{0pt}%
  \tableofcontents*
  \endgroup
  \setcounter{tocdepth}{\value{@memmarkcntra}}
}



%%% CTAN links
\providecommand\CTANurl{}
\AtBeginDocument{
  \@ifpackageloaded{hyperref}{
    \renewcommand*\CTANurl[1]{\href{http://mirror.ctan.org#1}{\nolinkurl{#1}}}
  }{
    \renewcommand*\CTANurl[1]{\url{#1}}
  }
}


\newcommand\reimplemented[2]{%
  \textit{Reimplemented, #1\footnote{#2}}
  \fancybreak{}
}

\newenvironment{caveat}{\par\medskip\noindent\textbf{\textit{Caveat.}}\enskip\itshape}{\par\medskip}
\newenvironment{note}{\par\medskip\noindent\textbf{\textit{Note.}}\enskip\itshape}{\par\medskip}
\newenvironment{note*}[1]{\par\medskip\noindent\textbf{\textit{#1.}}\enskip\itshape}{\par\medskip}
\newenvironment{hint}{\par\medskip\noindent\textbf{\textit{Hint.}}\enskip\itshape}{\par\medskip}
\renewcommand{\cmdprint}[1]{\textup{\texttt{\string#1}}}



\newenvironment{recommended}{%
  \@zeroseps%
  \parskip\z@ \topsep\z@%
  \definecolor{shadecolor}{gray}{0.9}%
  \fboxsep0pt%
  \shaded%
  \list{}{%
    \labelwidth\z@
    \itemindent\z@
    \addtolength\itemindent{\labelsep}
    \parsep\z@
    \listparindent1.5em
    \leftmargin\z@
    \rightmargin\leftmargin}
    \item[\textbf{Recommended alternative}]\mbox{}\par\smallskip
      \nobreak%\ignorespaces
  \noindent\ignorespaces}%
  { \endlist
    \endshaded}


%\renewcommand\theHfootnote{\thefootnote.\thesheetsequence}
 


\typeout{End memsty.sty}
\endinput