summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/sectsty/sectsty.dtx
blob: 06cf21fe30568785f0fb8cdc33238c911d62fc43 (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
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
% \iffalse
% File sectsty.dtx
% Copyright Rowland McDonnell 1996, 1998, and 2002
% email rowland.mcdonnell@physics.org
% Some bits copyright the LaTeX3 team 1998.
%
% To install the sectsty package, run LaTeX on sectsty.ins.  To 
% typeset the documentation, run LaTeX on sectsty.dtx.
%
% Documentation and source file for the sectsty package. The package 
% consists of two files:
% 
% sectsty.ins
% sectsty.dtx
%
% This program - the two files sectsty.dtx and sectsty.ins - may be
% distributed and/or modified under the conditions of the LaTeX Project
% Public License, either version 1.2 of this license or (at your option)
% any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.2 or later is part of all distributions of LaTeX 
% version 1999/12/01 or later.
%
% Don't give this file to anyone unless you also give them an unmodified
% versions of sectsty.ins.
% 
% Don't modify this file unless you change its name and change all the
% various identification strings it contains to indicate that: it's
% derived from my sectsty package, it's now your responsibility, and
% it's no longer part of the sectsty package.
% 
% Remove \OnlyDescription to get the code typeset.  The code is not 
% well documented.
%
% Note to me: comment out \OnlyDescription to get the checksum right, 
% and then uncomment it because I don't want the code typeset by 
% default (this package is meant for non-hackers).
%
%\fi
%\iffalse
%<*driver>
\documentclass[a4paper,11pt]{ltxdoc}
\usepackage{varioref}
\def\MacroFont{\fontencoding\encodingdefault
               \fontfamily\ttdefault
               \fontseries\mddefault
               \fontshape\updefault
               \normalsize}%
\OnlyDescription
\begin{document}
 \DocInput{sectsty.dtx}
\end{document}
%</driver>
%\fi
%\iffalse
%<*package>
%\fi
%%
%% \CheckSum{1463}
%% \CharacterTable
%%  {Upper-case    \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
%%   Lower-case    \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
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%
%\iffalse
% The instances of ^^A are `real' comment characters to suppress the 
% end-of-line space in the middle of the command definitions.
%\fi
%
% \makeatletter
%\newcommand{\ttlb}{{\ttfamily\def\@tempcmda{OT1}^^A
%\ifx\f@encoding\@tempcmda\char"7B\else\{\fi}}
%
%\newcommand{\ttrb}{{\ttfamily\def\@tempcmda{OT1}^^A
%\ifx\f@encoding\@tempcmda\char"7D\else\}\fi}}
%
%\newcommand{\ttbs}{{\ttfamily\def\@tempcmda{OT1}^^A
%\ifx\f@encoding\@tempcmda\char`\\\else\textbackslash\fi}}
%^^A  \char`\\ was \char"5C
%
%\newcommand*{\comname}[2][VF500F2E]{{\ttfamily\ttbs #2^^A
%\def\@tempcmda{VF500F2E}\def\@tempcmdb{#1}^^A
%\ifx\@tempcmda\@tempcmdb\else\comarg{#1}\fi}}
%
%\newcommand*{\itinangle}[1]{$\langle$^^A
%{\mdseries\rmfamily\itshape#1}\/$\rangle$}
%
%\newcommand*{\comarg}[1]{{\ttfamily\ttlb^^A
%\itinangle{#1}\ttrb}}
%
%\newcommand*{\comoptarg}[1]{{\ttfamily[$\langle$^^A
%{\rmfamily\itshape#1}\/$\rangle$]}}
% \makeatother
% 
% \author{Rowland McDonnell\\ \texttt{rowland.mcdonnell@physics.org}}
% \title{The \packname{sectsty} package v2.0.2}
% \date{25th February 2002}
% 
% \newcommand*{\packname}[1]{{\sffamily #1}}
% \newcommand*{\classname}[1]{{\ttfamily #1}}
% \newcommand*{\filename}[1]{{\ttfamily #1}}
% 
% \maketitle
% 
% \tableofcontents
%
% \section{Introduction}
% 
% The \packname{secsty} package provides a set of commands for changing 
% the fount\footnote{I am one of the few remaining English speaking 
% people on the planet to use this spelling to refer to a set of type in 
% one size and style.} used for the various sectional headings in the 
% standard \LaTeXe\ document classes: \classname{article}, 
% \classname{book}, and \classname{report}.  This package also works 
% with the KOMA-Script classes \classname{scrartcl}, 
% \classname{scrbook}, and \classname{scrreprt}.
% 
% When I refer to sectional headings in this document, I mean the stuff 
% that is printed in the body of a document to indicate the start of 
% a part, chapter, section, and so on.  Appendix headings are treated 
% as chapter headings.
% 
% I'd appreciate any bug reports, comments, or suggestions emailed to 
% the address above.  I'm especially interested in any problems you 
% might have had understanding the documentation; and, of course, 
% anything else you'd like to tell me about this package.  I'm 
% certainly interested in any problems you might have had in using 
% \packname{sectsty} with other packages, although I can't promise to 
% be able to do anything useful about such problems.
%
% The \packname{titlesec} package offers a different 
% approach to changing the appearance of sectional headings.   The 
% \packname{fncychap} package has a set of alternative `canned' chapter 
% headings.  Both are available from CTAN.
% 
% Donald Arseneau won't let me say what bits of \packname{sectsty} he 
% wrote, but I'd like to thank him anyway: I couldn't have managed 
% without his help.  Thanks are also due to the various people who sent 
% me bug reports -- I've not kept track so rather than mention some of 
% you and miss others out, I'll just say thanks and leave it at that.  
% You know who you are and I appreciate your help.
% 
% \section{Basic use of \packname{sectsty}}
% 
% Make sure you include the package in your document by saying in your 
% document preamble:
%\begin{verbatim} 
%    \usepackage{sectsty}
%\end{verbatim}
% You will then have some new commands available.  For example:
%\begin{verbatim} 
%    \allsectionsfont{\sffamily}
%\end{verbatim}
% will give you sanserif for all sectional headings.
% 
% \packname{Sectsty} doesn't make any changes to the fount used until 
% you tell it what to do. The idea is that you supply some standard 
% \LaTeX\ fount selection commands which change the default selection. 
% The standard classes use Computer Modern Bold Extended by default for 
% sectional headings, and your commands change this. This means the 
% example above gives you Computer Modern Sanserif Bold Extended by 
% default.
% 
% You might want to change all headings so that they used medium 
% italic.  Since the default headings use bold extended, you need to 
% switch to the medium weight as well as switching to italic using the 
% standard \LaTeX\ fount selection commands, like this:
%\begin{verbatim}
%    \allsectionsfont{\mdseries\itshape}
%\end{verbatim}
% You can change the style of the different sectional headings separately.
% If you want \comname{section}s to be set in bold Adobe Times, you might 
% use standard \LaTeX\ fount selection commands like this:
%\begin{verbatim}
%    \sectionfont{\fontfamily{ptm}\selectfont}
%\end{verbatim}
% 
% Similar commands exist to change the style of the rest of \LaTeX's 
% standard headings independently: \comname{chapterfont}\comarg{commands} 
% will change chapter headings, and so on.  The full list of commands is 
% given in section~\vref{sec:command_list}.
% 
% If you don't understand the fount selection commands above, you might 
% like to look at the file \filename{fntguide.tex} that comes with the 
% standard \LaTeX\ distribution.
% 
% \section{Raggedright, raggedleft, and centred headings}
% 
% The arguments to \packname{sectsty}'s sectional heading style changing 
% commands can contain any \LaTeX\ commands you like.  For example, you 
% might say:
%\begin{verbatim}
%    \allsectionsfont{\sffamily\raggedright}
%\end{verbatim}
% and all sectional headings would be typeset raggedright in bold 
% extended sanserif. Not all \LaTeX\ commands will work properly when 
% used this like, although these three commands all have the expected 
% effect when used in one of \packname{sectsty}'s 
% \comname{\itinangle{section}font} commands:
% \begin{center}
% \begin{tabular}{ll}
% \comname{centering}   & Headings centred on the page \\
% \comname{raggedright} & Headings set flush left with a ragged right 
%                         margin \\
% \comname{raggedleft}  & Headings set flush right with a ragged left 
%                         margin \\
% \end{tabular}
% \end{center}
% It's a bad idea to use any of these commands to change paragraph or 
% subparagraph sectional headings: these two sections begin with `run-in' 
% headings that are on the same line as the start of the section's text, 
% and don't like being messed around like this. You can change the 
% indentation before these two sectional headings like this:
%\begin{verbatim}
%    \subparagraphfont{\hspace*{5em}}
%\end{verbatim}
% This adds an extra 5\,em space before each subparagraph heading.
% 
% As a further example, you might want chapter headings set flush with 
% the right margin.  This will do the job:
%\begin{verbatim}
%    \chapterfont{\raggedleft}
%\end{verbatim}
% 
% If you want to play around with this sort of thing, it might be useful 
% to know what sort of positioning you get by default with the standard 
% classes: all sectional headings except chapter and part are fully 
% justified (text set flush with the left and right margins), and 
% chapter headings are raggedright. Part headings vary: they are 
% raggedright in the article class, and centred in the book and report 
% classes.
% 
% \subsection{A complication affecting multiple line headings}
% 
% The standard \comname{section}, \comname{subsection}, and 
% \comname{subsubsection} commands ensure that, if you've got a 
% multiple line heading, lines beyond the first are typeset with a small 
% amount of indentation.  This is called hanging indentation, and is 
% entirely appropriate with the standard formatting.  However, two 
% problems arise from this: firstly, this hanging indentation usually 
% looks pretty stupid if you've decided to have centred headings; and 
% secondly, due to a bug in \LaTeX, the hanging indentation is 
% suppressed if you use |\\| in a heading that's typeset raggedright or 
% centred.
% 
% The first problem can be dealt with: if you use the 
% \comname{nohang} command in the appropriate 
% \comname{\itinangle{section}font} command, the hanging indentation will 
% be suppressed. For example:
%\begin{verbatim}
%    \sectionfont{\nohang\centering}
%\end{verbatim}
% will ensure that any multiple line section headings come out centred 
% as expected.
% 
% The second problem -- the suppression of hanging indentation when you 
% use |\\| in a raggedright or centred heading -- remains unsolved. I'm 
% told that it's caused by the definition of \comname{@centercr}. This 
% is part of the \LaTeX\ kernel and beyond my abilities to patch up. 
% This problem has been reported as a \LaTeX\ bug, so it might well be 
% sorted out in a future \LaTeX\ release.
% 
% Donald Arseneau's \packname{ulem} package makes its own arrangements 
% in this area, so sectional headings that are underlined using 
% \packname{sectsty} and \packname{ulem} have correct hanging 
% indentation even if you do use |\\| to end a line early.
%
% \section{The KOMA-script classes}
% 
% If you just want to change the fount used for all sectional headings, 
% you shouldn't use \packname{sectsty} with any of the KOMA-script 
% classes. Instead, you should redefine the \comname{sectfont} command 
% provided by the KOMA-script classes. This is akin to using 
% \packname{sectsty}'s \comname{allsectionsfont} command.
% 
% For example, the default definition is:
%\begin{verbatim}
%  \newcommand*\sectfont{\sffamily\bfseries}
%\end{verbatim}
% you might want to change from this bold sanserif to medium italic 
% roman.  To do this, you could add the following line to your document 
% preamble:
%\begin{verbatim}
%  \renewcommand*\sectfont{\rmfamily\mdseries\itshape}
%\end{verbatim}
% If you'd like different sectional headings to be printed with 
% different styles of type to each other, or if you'd like to underline 
% sectional headings or play other games that you can't do with the 
% KOMA-script \comname{sectfont} command, then \packname{sectsty} might 
% be of use with the KOMA-script classes.
% 
% You should note that the modifications applied by \packname{sectsty} 
% commands happen immediately after the \comname{sectfont} command is 
% executed.
% 
% The documentation for this package is written with the standard 
% \LaTeX\ classes in mind, so might not tie up exactly to the 
% KOMA-script classes. Despite that, and despite differences in 
% behaviour when things go wrong, \packname{sectsty} should work as 
% expected with the KOMA-script classes.
% 
%
%\section{All the commands}\label{sec:command_list}
% 
% The full list of commands is:
% \begin{description}
% \item[\comname{allsectionsfont}\comarg{commands}] Changes the style of 
% all sectional headings by executing \comarg{commands} before 
% printing each heading.
% 
% \item[\comname{partfont}\comarg{commands}] Changes the style of 
% `part' headings only by executing \comarg{commands} before 
% printing each heading; this affects both the title of the part and the 
% part number.
% 
% \item[\comname{chapterfont}\comarg{commands}] Changes the style of 
% `chapter' headings only by executing \comarg{commands} before 
% printing each heading; this affects both the title of the chapter and 
% the chapter number.
% 
% \item[\comname{sectionfont}\comarg{commands}] Changes the style of  
% `section' headings only by executing \comarg{commands} before 
% printing each heading.
% 
% \item[\comname{subsectionfont}\comarg{commands}]Changes the style of 
% `subsection' headings only by executing \comarg{commands} before 
% printing each heading.
% 
% \item[\comname{subsubsectionfont}\comarg{commands}]Changes the style 
% of  `subsubsection' headings only by executing \comarg{commands} before 
% printing each heading.
% 
% \item[\comname{paragraphfont}\comarg{commands}]Changes the style of 
% `paragraph' headings only by executing \comarg{commands} before 
% printing each heading; you should not use text positioning commands 
% for this heading.
% 
% \item[\comname{subparagraphfont}\comarg{commands}]Changes the style of the 
% `subparagraph' heading only by executing \comarg{commands} before 
% printing each heading; you should not use text positioning 
% commands for this heading.
% 
% \item[\comname{minisecfont}\comarg{commands}]]Changes the style of the 
% `minisec' heading only by executing \comarg{commands} before 
% printing each heading.  This command always works, but since these 
% headings only exist in the KOMA-script classes, it's useless with the 
% standard \LaTeX\ classes.
% \end{description}
% 
% There are also these commands:
% \begin{description}
% \item[\comname{partnumberfont}\comarg{commands}]Changes the style of 
% `part' heading numbers only; this does not affect the title of the 
% part heading.
% 
% \item[\comname{parttitlefont}\comarg{commands}]Changes the style of 
% `part' heading titles only; this does not affect the number of the 
% part heading.
% 
% \item[\comname{chapternumberfont}\comarg{commands}]Changes the style 
% of `chapter' heading numbers only; this does not affect the 
% title of the chapter heading.
% 
% \item[\comname{chaptertitlefont}\comarg{commands}]Changes the style of 
% `chapter' heading titles only; this does not affect the number 
% of the chapter heading.
% \end{description}
%
% And finally, an anomalous helper command:
% \begin{description}
% \item[\comname{nohang}]For use in multiple-line headings: this 
% command stops lines beyond the first having hanging indentation, 
% which looks pretty daft with centred headings.
% \end{description}
%
% \section{Some notes}
%
% The way \packname{sectsty} works is by re-defining all the commands 
% that produce the sectional headings.  The change arranges things so 
% that the fount selection commands you specify are executed immediately 
% before the sectional heading is printed.  You can change sizes, for 
% example, with the normal \LaTeX\ size changing commands.
% 
% You can include almost any \LaTeX\ commands in the argument to one of 
% \packname{sectsty's} commands.  Whether any particular command will 
% work properly or have the effect you want is a different matter.  If 
% you come across anything interesting you can do with this package that 
% I've not mentioned and you think someone else might be interested in, 
% you could let me know and I'll put it in the documentation.
% 
% If you use long section names you might like to make all sectional 
% headings \comname{raggedright}:
%\begin{verbatim}
%    \allsectionsfont{\raggedright}
%\end{verbatim}
% This means that \LaTeX\ won't try and justify sectional headings and 
% should manage to avoid a hyphentated sectional heading which tends to 
% look pretty bad.
%
% If you use \packname{sectsty} and get a complaint that you are using
% an old version of \LaTeX, there's probably no need to worry.
% \packname{Sectsty} will probably work correctly with any version of
% \LaTeXe\ after June 1996; because the earliest version I've tested
% \packname{sectsty} with is the June 1998 release of \LaTeX, that's the
% version I've specified as being needed. \packname{Sectsty} is not
% meant to work with \LaTeX~2.09; it's a good idea to get \LaTeXe\ if at
% all possible.
%
% \section{Underlining}
% 
% Some people have to underline sectional headings because of 
% regulations governing thesis submission and things like that. If 
% you're not forced to use underlining, it's probably best to avoid it: 
% underlining is usually considered bad typographical practice 
% (well-placed horizontal rules are a different matter). On top of that, 
% underlining sectional headings with \packname{sectsty} is not as 
% trivial a job as I'd like -- you've either got to get another package 
% or accept quite a lot of limitations.
% 
% To underline a sectional heading with \packname{sectsty}, you need to 
% put the \comname{underline} command as the last command in a 
% \comname{\itinangle{section}font} command.  For example:
%\begin{verbatim}
%   \usepackage{sectsty}
%   \allsectionsfont{\sffamily\underline}
%\end{verbatim}
% will give you underlined sanserif headings.
% 
% There are two main problems with this way of doing things: firstly, 
% the standard \LaTeX\ \comname{underline} command produces a one line 
% box in LR mode that can't be split across lines. This means that long 
% headings can't be split into two or more lines and will always result 
% in overfull \comname{hbox}es. Secondly, the underline rule is placed 
% underneath the lowest extent of the text and affects vertical spacing. 
% This is particularly ugly in the case of \comname{paragraph} and 
% \comname{subparagraph} headings which are on the same line as the 
% first line of text of the section.
% 
% Both these problems can be avoided by using the \packname{ulem} 
% package (see section~\vref{ulemsource} for how to get it):
%\begin{verbatim}
%   \documentclass{article}
%   \usepackage{sectsty}
%   \usepackage[normalem]{ulem}
%   \allsectionsfont{\sffamily\underline}
%\end{verbatim}
% Don't forget that the \comname{underline} command must always be the 
% last item in the \comname{\itinangle{section}font} command. This 
% example uses the familiar \comname{underline} command as before, but 
% because \packname{ulem} has been loaded, \packname{sectsty} 
% automatically redefines \comname{underline} inside sectional headings 
% to use \packname{ulem}'s underline code. The \comname{underline} 
% command has its normal meaning outside sectional headings, so you won't 
% get any nasty surprises.
% 
% I prefer the results you get using the \packname{ulem} package, but 
% you might prefer the appearance of underlined sectional headings 
% produced without \packname{ulem}'s help. If so, and you're not using 
% \comname{paragraph} or \comname{subparagraph} sections, or section 
% headings that need to be split over two lines, there's no need to use 
% \packname{ulem}.
% 
% \packname{Sectsty} always plays some dirty tricks which involve 
% re-defining the \comname{underline} command inside sectional headings 
% only. These tricks work differently if \packname{ulem} has been 
% loaded, but it doesn't matter whether you load \packname{ulem} before 
% or after \packname{sectsty}.
% 
% Despite these fun and games, the \comname{underline} command always 
% has its usual definition outside sectional headings and will work 
% normally in the rest of your document.
%
% \subsection{A detailed look at underlining}
% 
% It is possible to underline sectional headings in other ways.  This 
% section explains how, and also explains a little more about 
% underlining sectional headings with \packname{sectsty}.
% 
% The \packname{secsty} package lets you use two different commands to 
% underline sectional headings: \comname{underline} and 
% \comname{ulemheading}. Both commands suffer from the same restriction 
% in use: they must always be the last command in the argument to the
% \comname{\itinangle{section}font} command.  Both commands can be used 
% whether or not you've loaded \packname{ulem}: they are defined 
% differently depending on whether or not the \packname{ulem} package 
% has been loaded.  The decision on which definition to use is made at 
% the \comname{begin\ttlb document\ttrb} command, so you can load 
% \packname{ulem} before or after \packname{sectsty}.
% 
% If you want to use underlined headings, I strongly suggest you get the 
% \packname{ulem} package as well.  Without the \packname{ulem} package, 
% you get identical results (with a few problems) in sectional headings 
% using both \comname{underline} and \comname{ulemheading}.
%
% \packname{Sectsty} re-defines the \comname{underline} command inside 
% sectional headings.  This re-definition is what allows underlining to 
% work correctly in all of the standard sectional headings, and allows 
% the same command to behave differently if you've use the 
% \packname{ulem} package.  \TeX's usual grouping rules mean that the 
% \comname{underline} command is restored to its usual meaning at the 
% end of each sectional heading: the re-definition used by 
% \packname{sectsty} should have no effect on the rest of your document.
%
% Assuming for the moment that you're not using \packname{ulem}, you can 
% get a straightforward single underline using the normal \LaTeX\ 
% underline command like this:
%\begin{verbatim}
%   \allsectionsfont{\underline}
%\end{verbatim}
% This has a few problems. Most noticeably, it won't allow sectional 
% headings to break at the end of the line, so long headings will extend 
% beyond the right hand edge of the text. This is because the standard 
% \LaTeX\ \comname{underline} command puts its argument into a box made 
% in LR mode, so headings underlined this way will be one line headings 
% no matter what you do.
% 
% Another problem is that the underline rule used sits below the lowest 
% possible extent of the text it's underlining, and so increases the 
% space between the underlined heading and the text below. This is 
% especially noticeable if you're using \comname{paragraph} or 
% \comname{subparagraph} headings. And remember that the 
% \comname{underline} command must be the last in this list, like this:
%\begin{verbatim}
%   \allsectionsfont{\sffamily\underline}
%\end{verbatim}
% If you put \comname{sffamily} (or anything else) after 
% \comname{underline}, it won't work properly.
% 
% \subsubsection{Underlining with the \packname{ulem} package}
% 
% The \packname{ulem} package has some nice commands for improved 
% underlining in normal text. The main advantages are that the underline 
% rule is positioned better (so it doesn't mess up the line spacing), 
% and it allows long underlined headings to break normally at the end of 
% the line. All you need to do is load \packname{ulem}, and 
% \packname{sectsty} will do the rest. Try the following example as it 
% is here:
%\begin{verbatim}
%   \documentclass{article}
%   \usepackage{sectsty}
%   \usepackage[normalem]{ulem}
%   \allsectionsfont{\sffamily\raggedright\underline}
%   \begin{document}
%   \section{A very long sectional heading title that will 
%            have to be split over two lines}
%   \end{document}
%\end{verbatim}
% You'll notice that the long section heading was split over two 
% lines.  Now try this:
%\begin{verbatim}
%   \documentclass{article}
%   \usepackage{sectsty}
%   \allsectionsfont{\sffamily\raggedright\underline}
%   \begin{document}
%   \section{A very long sectional heading title that will 
%            have to be split over two lines}
%   \end{document}
%\end{verbatim}
% You'll notice that the underlining rule is positioned differently, and 
% the heading could not be split over two lines.
% 
% If you want to use in sectional headings some of the other types of 
% underlining allowed by the \packname{ulem} package, you can use the 
% \comname{ulemheading} command, as in this example to give double 
% underlining and raggedright sectional headings:
%\begin{verbatim}
%   \usepackage{sectsty,ulem}
%   \allsectionsfont{\raggedright\ulemheading{\uuline}}
%\end{verbatim}
% The \comname{ulemheading} command is meant to be used only inside 
% sectional headings like this. It takes two arguments: the first 
% argument is the \packname{ulem} package command to generate a 
% particular style of underlining; the second argument is the text to be 
% underlined, and is provided by the command that generates the 
% sectional heading. All you have to do is provide the first argument 
% and ensure that you put the \comname{ulemheading} at the end of the 
% \comname{\itinangle{section}font} command's argument, as in this 
% example to give you wavy underlined sans-serif headings:
%\begin{verbatim}
%   \usepackage{sectsty,ulem}
%   \allsectionsfont{\sffamily\ulemheading{\uwave}}
%\end{verbatim}
% The full list of modifications allowed by the \comname{ulemheading} 
% command is:
% \begin{center}
% \begin{tabular}{ll}
%   \ttbs ulemheading\ttlb\ttbs uline\ttrb  & single underline  \\
%   \ttbs ulemheading\ttlb\ttbs uuline\ttrb & double underline  \\
%   \ttbs ulemheading\ttlb\ttbs uwave\ttrb  & wavy underline    \\
%   \ttbs ulemheading\ttlb\ttbs sout\ttrb   & strike out with \texttt{-} \\
%   \ttbs ulemheading\ttlb\ttbs xout\ttrb   & cross out with \texttt{/}  \\
% \end{tabular}
% \end{center}
% It's possible to define more by following the directions in the 
% \packname{ulem} package.
% 
% If you typeset a document that uses \comname{ulemheading} on a system 
% where the \packname{ulem} package is unavailable, the document will be 
% processed but the output will be different. If you've not loaded the 
% \packname{ulem} package, \comname{ulemheading} will produce 
% underlining exactly the same as if you'd used the \comname{underline} 
% command: \comname{ulemheading} is defined to ignore the first argument 
% and pass the heading text to the normal underlining code. This means 
% you can produce a document using \packname{ulem}'s fancy underlining, 
% and process it on a \LaTeX\ system without \packname{ulem} by making a 
% single modification: commenting out the \comname{usepackage\ttlb 
% ulem\ttrb} command. The results will of course be different, but the 
% document will typeset.
% 
% \subsubsection{More notes on \packname{ulem} and 
% underlining}\label{ulemsource}
% 
% The \packname{ulem} package is available via anonymous ftp from the 
% Comprehensive \TeX\ Archive Network (CTAN). 
% You can find a list of CTAN sites and a Web interface to CTAN at 
% \texttt{http://www.tug.org/ctan.html}. The following ftp urls work now 
% (August 1998):
% \begin{center}
%{\footnotesize\begin{tabular}{@{}l@{}}
% \ttfamily
% ftp://ftp.dante.de/tex-archive/macros/latex/contrib/other/misc/ulem.sty\\
% \ttfamily
% ftp://ftp.tex.ac.uk/tex-archive/macros/latex/contrib/other/misc/ulem.sty\\
% \ttfamily
% ftp://ctan.tug.org/tex-archive/macros/latex/contrib/other/misc/ulem.sty\\
%\end{tabular}}
% \end{center}
% The \packname{ulem} package was written by Donald Arseneau, who 
% contributed some code and lots of useful advice to \packname{sectsty}.
% 
% It doesn't matter if you load \packname{ulem} before or after 
% \packname{sectsty}, because \packname{sectsty} waits until the 
% \comname{begin\ttlb document\ttrb} command before checking to see if 
% \packname{ulem} has been loaded.
% 
% \packname{Sectsty} uses a cunning trick to re-define the 
% \comname{underline} command inside sectional headings only; 
% \comname{underline} will work normally outside sectional headings.  
% The trick is cunning because the re-definition is different if the 
% \packname{ulem} package is in use in that document: the commands that 
% make this trick work wait until the \comname{begin\ttlb document\ttrb} 
% command has been executed, so it doesn't matter if you load 
% \packname{ulem} before or after \packname{sectsty}.
%
% The \comname{underline} and \comname{ulemheading} commands produce 
% identical results if the \packname{ulem} package is not loaded; they 
% will both use \LaTeX's normal underlining mechanism.  If you do load 
% \packname{ulem}, \comname{underline} will produce nicer results, and 
% \comname{ulemheading} will allow you to use any of \packname{ulem}'s 
% different underlining styles.
% 
% The \packname{ulem} package changes \LaTeX's emphasis commands so that 
% they use underlining rather than italics for emphasis.  If you don't 
% want this, you should load \packname{ulem} with the |normalem| option:
%\begin{verbatim}
%   \usepackage[normalem]{ulem}
%\end{verbatim}
%
% \section{Other things you can do with \packname{sectsty}}
% 
% Here are a few other things you can do using \packname{sectsty}; the 
% techniques for modifying section heading numbers work with or without 
% \packname{sectsty}. If you find that you can already get 
% \packname{sectsty} to do what you want to do, it might be an idea to 
% leave reading this section until later.
% 
% If you are going to read on, an apology: the \packname{sectsty} 
% package was originally meant to be a very simple thing to use. Various 
% requests from people who wanted to do various things mean that it's no 
% longer as simple to use as I'd like. This can't be helped: some people 
% \emph{need} underlining, and that's that. Unfortunately, the 
% documentation has ended up much more complicated that I'd like. This 
% section makes it even worse. I hope that the use people get from the 
% over long documentation outweighs the extra hassle it causes.
% 
% \subsection{Suppressing a page number}
% It's occasionally useful to be able to suppress page numbering on the 
% first page of a chapter. You can do this by saying:
%\begin{verbatim}
%   \chapterfont{\thispagestyle{empty}}
%\end{verbatim}
% This works because the argument to the \comname{chapterfont} command 
% is (obviously) executed on the page that the chapter begins on. As 
% luck has it, it's executed after the \comname{thispagestyle\ttlb 
% plain\ttrb} command issued by the \comname{chapter} command, so the 
% page style selected by the \comname{chapterfont} command is the one 
% that's used.
% 
% \subsection{Rules around sectional headings}
% 
% I've included a `unofficial' command, \comname{sectionrule}, in 
% \packname{sectsty} that can put a solid rule across the entire width 
% of the page, above and below a sectional heading. It's probably a good 
% idea to visit the library and study some typography books before using 
% this command. The command must be used as the last command in a 
% \comname{\itinangle{section}font} command, and has this syntax:
% \begin{center}
% \begin{tabular}{ll}
% \comname{sectionrule} & \comarg{raise top by}\comarg{top rule height}\\
%                 & \comarg{raise bottom by}\comarg{bottom rule height}\\
% \end{tabular}
% \end{center}
% \comarg{raise top by} is the length that the top rule is raised above 
% the baseline of the top line of the heading;
% \comarg{top rule height} is the height (thickness) of the top rule;
% \comarg{raise bottom by} is the length that the bottom rule is raised 
% above the baseline of the bottom line of the heading (a negative 
% length places the rule underneath the last line); and
% \comarg{bottom rule height} is the height (thickness) of the bottom 
% rule.
% 
% The \comname{sectionrule} command works like this:
%\begin{verbatim}
%   \sectionfont{\sectionrule{3ex}{3pt}{-1ex}{1pt}}
%\end{verbatim}
% What this example does is place two rules across the full width of the 
% text. One is a 3\,pt rule 3\,ex above the baseline of the top line of 
% the heading, and the other is a 1\,pt rule 1\,ex below the baseline of 
% the bottom line of the heading.
% 
% The vertical space before and after sectional headings can be affected 
% by these rules: the vertical space around a heading is placed before 
% and after \emph{everything} that is printed for the sectional heading, 
% so if a rule is the topmost item in the sectional heading, then the 
% vertical space will be measured to that rule.
% 
% Setting the height of either rule to 0\,pt will make it invisible, 
% although such a rule can still have an effect on spacing if you raise 
% or lower it.
% 
% The \comname{sectionrule} command has a few problems: in particular, 
% it can't place rules around centred headings, and it doesn't work 
% properly with run in headings such as the standard \comname{paragraph} 
% and \comname{subparagraph} headings. You might like to try the 
% \packname{titlesec} package if \packname{sectsty} can't help you do 
% what you want.
% 
% Because \comname{sectionrule} must be the last command in a 
% \comname{\itinangle{section}font} command, it can't be used with 
% underlined section headings: the underlining commands must 
% also be placed last, so you can't have both underlining and rules 
% around a sectional heading.
% 
% I wrote the \comname{sectionrule} command and it will be staying in 
% \packname{sectsty}. I call it `unofficial' because \packname{sectsty} 
% is meant to be very simple, and this command takes things a long way 
% away from my original `design concept'; this is why it's not 
% mentioned in the bulk of the documentation above.
% 
% \subsection{A box around sectional headings}
% 
% You can put a sectional heading inside a frame using the standard 
% \LaTeX\ \comname{fbox} command like this:
%\begin{verbatim}
%   \sectionfont{\noindent\fbox}
%\end{verbatim}
% 
% This has two limits: it doesn't work with \comname{chapter} or 
% \comname{part} headings, and it only works with single line headings. 
% The reason for this last problem is that the \comname{fbox} command 
% typesets text in LR mode and will therefore always produce a single 
% line of text.
%
% I've heard that other box making commands can be used to place a frame 
% around a sectional heading in a similar way (\comname{colorbox} 
% apparently works). If you use any box making command like this, you 
% will need to add a \comname{noindent} as with \comname{fbox}. This is 
% because the box making command switches \TeX\ from vertical mode to 
% horizontal mode, which inserts a paragraph indent unless there's a 
% \comname{noindent} at that point. There is a \comname{noindent} 
% command buried deep inside the code that produces sectional headings, 
% but too late on to help with this.
% 
% Another way of putting a box round a sectional heading gets round the 
% one-line limit of the simple approach above:
%\begin{verbatim}
%   \makeatletter
%   
%   \newcommand{\sectbox}[1]{%
%     \noindent\protect\fbox{%
%       \@tempdima=\hsize
%       \advance\@tempdima by-2\fboxsep
%       \advance\@tempdima by-2\fboxrule
%       \protect\parbox{\@tempdima}{%
%         \smallskip
%         % extra commands here
%         #1\smallskip
%         }}}
%   
%   \makeatother
%   
%   \sectionfont{\sectbox}
%\end{verbatim}
% Again, this doesn't work properly with \comname{chapter} or 
% \comname{part} headings; another limit is that the \comname{sectbox} 
% command must be the last command in the 
% \comname{\itinangle{section}font} command.
% 
% This technique has two significant differences to the first 
% suggestion: firstly, it puts a bit of extra vertical space between the 
% text and the frame, which improves the appearance of the heading; 
% secondly, it places the text of the heading inside a \comname{parbox} 
% that stretches across the full width of the text.  This means that 
% long headings can be broken across lines, and also that the 
% surrounding frame extends across the full width of the text, rather 
% than just enclosing the text of the heading.
% 
% While you can use fount changing commands as usual with the 
% \comname{sectbox} command -- 
% \comname{sectionfont\ttlb\comname{sffamily}\comname{sectbox}\ttrb} 
% will work as expected -- the use of \comname{parbox} means that 
% \comname{raggedright} and similar commands won't work in 
% \comname{\itinangle{section}font} commands. There is a way round this 
% problem: put the appropriate command in the definition of 
% \comname{sectbox} at the place marked \verb|extra commands here|. For 
% example, you could say:
%\begin{verbatim}
%   \makeatletter
%   
%   \newcommand{\sectbox}[1]{%
%   \noindent\protect\fbox{%
%   \@tempdima=\hsize
%   \advance\@tempdima by-2\fboxsep
%   \advance\@tempdima by-2\fboxrule
%   \protect\parbox{\@tempdima}{%
%   \smallskip
%   \raggedright% extra commands here
%   #1 \smallskip
%   }}}
%   
%   \makeatother
%   
%   \sectionfont{\sectbox}
%\end{verbatim}
% and you'd get raggedright headings within the box.  Both 
% \comname{raggedleft} and \comname{centering} also work, although you 
% might like to use \comname{nohang} with \comname{centering}.
% 
% \subsection{Changes to section numbers}
% 
% The two suggestions below don't require \packname{sectsty}; I'm 
% including them because if you're using \packname{sectsty}, you 
% might want to do something like this.
% 
% The suggestions modify the \comname{@seccntformat} command. This is 
% the internal \LaTeX\ command which prints the number part of all 
% sectional headings except chapter and part headings. It's quite in 
% order to change this sort of command: one of the reasons this command 
% exists in the first place is so that people can change it to modify 
% the output they get with \LaTeX.  You can find out more about it 
% by \LaTeX ing \filename{classes.dtx}, part of the standard \LaTeX\ 
% distribution.
% 
% The best place in general for the modifications I suggest in this 
% section is in a class or package file. If you put the modifications 
% there, you won't need the surrounding \comname{makeatletter} and 
% \comname{makeatother} commands.
% 
% If you find yourself wanting to do more stuff along these lines, it 
% might be an idea to look at the \packname{titlesec} package from CTAN.
% 
% \subsubsection{Printing the section number in the left margin}
%
% This is a quick hack I stumbled over by accident one day and I hope 
% someone else finds it useful. I haven't tested it thoroughly, so do be 
% aware that it might produce unwanted effects; I can't see that it will 
% do anything untoward, but I think it's best to be paranoid when 
% dealing with computers.
% 
% Putting this code in the preamble of your document:
%\begin{verbatim}
%   \makeatletter
%   \def\@seccntformat#1{\protect\makebox[0pt][r]{\csname
%                        the#1\endcsname\quad}}
%   \makeatother
%\end{verbatim}
% will typeset the number of each section in the left margin, with the 
% start of each instance of sectional heading text aligned with the left 
% hand edge of the body text. It doesn't affect chapter or part 
% headings. This code won't affect the normal paragraph and subparagraph 
% headings. If you change the normal form of these headings by telling 
% \LaTeX\ to print section numbers with them, paragraph headings will 
% work as you'd expect, but subparagraph headings will have the section 
% number to the left of the normal position although not in the left 
% margin.
% 
% \subsubsection{Putting a full stop (period) after the section number}
% 
% Requests on how to do this appear in \texttt{news://comp.text.tex} 
% quite often.  One solution is:
%\begin{verbatim}
%   \makeatletter
%   \def\@seccntformat#1{\csname the#1\endcsname.\quad}
%   \makeatother
%\end{verbatim}
% This will put a full stop after sectional numbers in sectional headers 
% other than part and chapter headings. It doesn't affect 
% cross-references or table of contents entries.
% 
% An interesting extension to the simple original command allows you to 
% control the style of numbering you get with each level of sectional 
% heading independently:
%\begin{verbatim}
%   \makeatletter
%   \def\@seccntformat#1{\@ifundefined{#1@cntformat}%
%   {\csname the#1\endcsname\quad}%  default
%   {\csname #1@cntformat\endcsname}% individual control
%   }
%   \def\section@cntformat{\thesection.\quad}
%   \def\subsection@cntformat{\thesubsection.\quad}
%   \makeatother
%\end{verbatim}
% this example gives you a full stop after section and subsection 
% headings, and has no effect on other levels.
% 
% \section{Compatibility with other packages}
% 
% The \packname{sectsty} package works by blindly re-defining the 
% various sectioning commands, so any package that requires
% that \LaTeX's sectioning commands are precisely as they are defined 
% in the standard classes will have trouble working with 
% \packname{sectsty}.
% 
% The \packname{fncychap} package, for example, re-defines the code 
% that produces chapter headings.  If you use \packname{fncychap} with 
% \packname{sectsty}, you will have to load \packname{fncychap} after 
% \packname{sectsty}:
%\begin{verbatim}
%    \usepackage{sectsty}
%    \usepackage{fncychap}
%\end{verbatim}
% You'll find that \packname{sectsty} will have no effect on chapter 
% headings when you use it like this.
% 
% Some packages perform interesting tricks to add code to the standard 
% sectioning commands.  These packages might well work quite happily 
% with \packname{sectsty}, but they must be loaded after 
% \packname{sectsty}: because \packname{sectsty} re-defines the 
% sectioning commands, any earlier changes will be thrown away.
% 
% In particular, the \packname{minitoc} package modifies the sectioning 
% commands (rather than just re-defining them like \packname{sectsty} 
% does), but if you say:
%\begin{verbatim}
%   \usepackage{sectsty,minitoc}
%\end{verbatim}
% to load \packname{minitoc} after \packname{sectsty}, everything should 
% work perfectly.
%
% \StopEventually{}
%
% \iffalse
% 2002/02/25 v2.0.2 Changed email address and fiddled with scribbles 
%     round the edges.  No code changes.
% 1999/04/12 v2.0.1 changed licence conditions to lppl.txt; stopping 
%     it typesetting code by default (silly boy).  Released.
% 1999/04/07 v2.0 bit the bullet.  Released
% 1999/04/06 v1.9.7 Added KOMA-script note.  Unreleased.
% 1999/03/08 v1.9.6 Fixed \sectbox definition.  Commented out the 
%     redundant chapfudge defs.  Unreleased.
% 1999/02/07 v1.9.5 Fixed showkeys problem thanks to Bernd Schandl.  
%     More playing with underlining code.  Unreleased.
% 1999/01/22 v1.9.4 Playing with underlining code.  Unreleased.
% 1999/01/20 v1.9.3 Changed \SS@sectlevel to \SSsectlevel so that it 
%     can be used inside documents.  It's 1999, not 1998.  Hunted down 
%     and killed yet another spurious space.  Well, killed it anyway.  
%     God knows where it actually was.  Doc mods.  First bash at 
%     getting \sectionrule to work with the KOMA-script classes.  
%     Unreleased.
% 1999/01/18 v1.9.2 added grouping to \chapter and \part commands.  
%     Why didn't I do this ages ago?  Hunted down and killed a 
%     spurious space.  Added grouping to \minisec too, and made its 
%     underlining stuff same as part and chapter stuff.  Changed 
%     \SE@ to \SS@.  Unreleased.
% 1999/01/15 v1.9.1 added debugging stuff.  Unreleased.
% 1999/01/13 v1.9 added stuff for KOMA-script classes.  Untested,  
%     undocumented, and unreleased.  This will transmogrify into v2.0 
%     when it's ready for release.
% 1999/01/06 v1.8.7 Added warning if sectsty isn't going to do 
%     anything because article, report, or book haven't been loaded.  
%     Released.
% 1999/01/03 v1.8.6 More \fbox doc bits.  Added \ttbs command and 
%     changed \comname definition to use it.  Untested.  Unreleased.
% 1998/12/29 v1.8.5 Added doc note about \fbox.  Unreleased.
% 1998/12/11 v1.8.4 Fixed \nohang bug (how the hell did *that* 
%     happen?).  Some documentation mods.  Released
% 1998/12/10 v1.8.3 Documention mods.  Unreleased
% 1998/12/10 v1.8.2 Documention mods. Released
% 1998/12/09 v1.8.1 Documentation mods and changed syntax of 
%     \sectionrule command.  Modified doc stuff so code comes out in 
%     9pt and codeline numbers in 7pt, as standard.  Unreleased.
% 1998/12/08 v1.8 Major \sectionrule mods - should now work with 
%     raggedleft and chapter/part headings as well.  Documentation 
%     mods.  Unreleased
% 1998/12/06 v1.7.2 Documentation mods.  Unreleased.
% 1998/12/01 v1.7.1 Documentation mods.  Unreleased.
% 1998/11/29 v1.7 Stopped being such a bloody fool and added \nohang.  
%     Added note about rule under chapter and part headings.  
%     Unreleased
% 1998/11/19 v1.6 Probably dealt with centering/underline multiline 
%     problem.  Taken Donald Arseneau's name out of the copyright 
%     notice.  Some doc changes.  Unreleased
% 1998/11/18 v1.5.3 Minor doc changes.  Released?
% 1998/11/16 v1.5.2 Minor doc changes.  Re-positioned \strut in 
%     \SS@ulemsectuline.  Unreleased.
% 1998/11/15 v1.5.1 Added \strut to \SS@ulemsectuline.  Some doc 
%     changes.  Unreleased.
% 1998/11/14 v1.5 Changed \sectionrule command and documented it.  
%     Changed \@svec fix to \let.  Not released.
% 1998/11/12 v1.4.4 added \sectionrule command.  Iffy. No doc changes.  
%     Unreleased.
% 1998/11/11 v1.4.3 Moved the version history; added fix for 
%     underlining *-form heading problem; minor documentation mods; 
%     started to document way of putting a full width rule underneath 
%     a section heading and ran into trouble; unreleased.
% 1998/08/24 v1.4.2 Yet more documentation mods; unreleased
% 1998/08/20 v1.4.1 Documentation mods; unreleased
% 1998/08/05 v1.4 more underlining modifications and finished docs
% 1998/07/15 v1.3 added sectional heading underlining stuff and added 
%      some more documentation.  Unreleased.
% 1998/06/28 v1.2 removed \selectfont commands which are redundant 
%      and stop you using commands that take the sectional heading as 
%      an argument.  This is to allow you to underline sectional 
%      headings, as is often required in theses etc.
% 1998/05/28 v1.1.1 fixed problem with \OnlyDescription and 
%      corrected \CheckSum (kicks self vigorously)
% 1998/05/27 v1.1 Fixed bugs in chapter/part code, corrected a 
%      documentation bug, and added a few more notes (thanks to
%      Bernd Schandl <bschand@math.clemson.edu>).  And removed the 
%      spurious spaces from the other sectional headings (grr).
% 1998/05/26 v1.0 Made into dtx/ins pair for general release
% 1998/05/13 v0.2 Changed more than a little
% 1996/12/08 v0.1 original version
%\fi
%
% \iffalse
% This code is used to switch to the usual fount sizes for 
% typesetting the code; because this document is typeset in 11pt rather 
% than 10pt, the code would normally be typeset in a larger than usual 
% fount leading to lots of overfull \hboxes.  I've bunged it here so 
% the casual reader can see what's going on - it's executed just 
% before the first code is typeset.
%
% Because this document is set in 11pt, need to select a smaller than 
% usual size for \MacroFont to get the macros set in 9pt, and code line 
% numbers set in 7pt.
%
% Yes, I know it's ugly.  It was a bit of a battle to get it to work, 
% and now that it does work, I'm loathe to change anything.
%\fi 
%
% \makeatletter
% \def\macro@font{\fontencoding \encodingdefault \fontfamily \ttdefault 
% \fontseries \mddefault \fontshape \updefault \footnotesize}
% \let\MacroFont\macro@font
% 
% \def\theCodelineNo{\rmfamily%
% \@setfontsize\scriptsize\@viipt\@viiipt%
% \arabic{CodelineNo}}
% \makeatother
%
% 
% \section{The code itself}
% 
%
% Who am I, and what do I need?  This package will probably work with 
% any version of \LaTeXe, but I've only tested it with the June 
% 1998 release and some later ones.
%
%    \begin{macrocode}
\ProvidesPackage{sectsty}[2002/02/25 v2.0.2 Commands to change all 
sectional heading styles]
\NeedsTeXFormat{LaTeX2e}[1998/06/01]
%    \end{macrocode}
% 
% \subsection{Options}
% 
% \subsubsection{Control how much stuff is reported}
% 
% This lot is for my benefit at the moment.  Maybe the full range of 
% values will have some meaning one day.
% 
% \begin{macro}{\SS@ocl}
% \comname{SS@ocl}\comarg{number}\comarg{if okay to blather}\comarg{if 
% not okay to blather}
% 
% (ocl stands for On Chat Level)
% 
% If \comarg{number} (1-4) is greater than the current chat level, then 
% blather away. If not, do the other thing. So use 4 for stuff to be 
% printed all the time, and 1 for other stuff.
% 
%    \begin{macrocode}
\long\def\SS@ocl#1#2#3{\ifnum #1>\SS@chatlevel #2\else #3\fi}
%    \end{macrocode}
% \end{macro} 
%
% \begin{macro}{\SS@oclto}
%
% On Chat Level TypeOut -- used for debugging reports (etc).
% 
%    \begin{macrocode}
\def\SS@oclto#1#2{\SS@ocl{#1}{\typeout{#2}}{}}
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\SS@chatlevel}
% By default, don't make much fuss.
%    \begin{macrocode}
\def\SS@chatlevel{3}
%    \end{macrocode}
% 
% Maybe I'll activate the other options one of these days, but only if 
% the messages are meant for people other than me.
% 
%    \begin{macrocode}
% \DeclareOption{verbose}{\def\SS@chatlevel{1}}% chatty
% \DeclareOption{silent}{\def\SS@chatlevel{3}}%  yorkshire
% 
% \DeclareOption{errorshow}{\def\SSchatlevel{3}}%  yorkshire
% \DeclareOption{warningshow}{\def\SS@chatlevel{2}}%  taciturn
% \DeclareOption{infoshow}{\def\SS@chatlevel{1}}%  chatty
% \DeclareOption{debugshow}{\def\SS@chatlevel{0}}%  garrulous
% 
\DeclareOption{garrulous}{\def\SS@chatlevel{0}}
\DeclareOption{chatty}{\def\SS@chatlevel{1}}
\DeclareOption{taciturn}{\def\SS@chatlevel{2}}
\DeclareOption{yorkshire}{\def\SS@chatlevel{3}}
%    \end{macrocode}
% \end{macro}
% 
%    \begin{macrocode}
\ProcessOptions
%    \end{macrocode}
% 
%
% \subsection{Underlining}
% 
% Stuff for underlining sectional headings.  I didn't write much of 
% this myself.
% 
%\begin{macro}{\@svsec}
% First thing to do\ldots\ Define |\@svsec| to prevent underlining 
% extras throwing a wobbly when you try to underline a |\section*| or 
% similar. |\@svsec| is referred to by the underlining code, but it 
% normally only exists inside the non star form of the commands 
% generating sectional headings.
%    \begin{macrocode}
\let\@svsec\relax
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\nohang}
% A hack: you should get hanging indentation on subsequent lines of all 
% sectional headings, but this isn't always appropriate.  
% \comname{nohang} suppresses the hanging indentation.  If you're using 
% centred or raggedright headings, a bug in \comname{@centercr} means 
% the hanging indentation is suppressed if you end lines with |\\|.
%    \begin{macrocode}
\newcommand{\nohang}{\let\@hangfrom\@empty}
%    \end{macrocode}
%\end{macro}
% 
% And then add some stuff so that:
%\begin{verbatim}
%   \section{Algorithm according to \cite{knuth}}
%\end{verbatim}
% works when using the \packname{showkeys} package.  Problem reported by 
% and solved by Bernd Schandl.
%\begin{macro}{\SS@origunderline}
% start by saving the original definition of \comname{underline}
%    \begin{macrocode}
\let\SS@origunderline\underline
%    \end{macrocode}
%\end{macro}
%
% Then check to ensure that the \comname{underbar} command is as it 
% should be by default.  This matters: \comname{underbar} is defined 
% inside sectional headings to use \comname{orig@underline} rather than 
% \comname{underline}, because \comname{underline} is redefined under 
% such circumstances; this breaks the \comname{underbar} command used 
% by \packname{showkeys}.  If \comname{underbar}'s definition has 
% changed, I need to know about it.
%
%    \begin{macrocode}
\CheckCommand*{\underbar}[1]%
  {\underline{\sbox\tw@{#1}\dp\tw@\z@\box\tw@}}
%    \end{macrocode}
% 
% \subsubsection{Main underlining code}
% The first command is for underlining sectional headings created 
% with |\@startsection|.
% 
%\begin{macro}{\SS@ulemsectuline}
% 
% |\SS@ulemsectuline| is a hack that modifies the behaviour of sections 
% created using the |\@startsection| command. It allows you to underline 
% sectional headings with fewer problems than otherwise. First argument 
% is the \packname{ulem} underlining command; second argument is the 
% section heading text to underline.
%    \begin{macrocode}
\newcommand*{\SS@ulemsectuline}[2]{%
  \ifhmode% run-in head
    \begingroup%
    \def\hskip##1\relax##2\@@par{\endgroup\@@hskip##1\relax#1{##2}}%
  \else% stand alone head
    % \ifx\\\@centercr\let\@hangfrom\@empty\fi% deal with \@hangfrom prob
    \protected@edef\@svsec{\noexpand#1{\@svsec\strut}}% added strut
    \def\interlinepenalty##1##2\@@par{\@@interlinepenalty##1#1{##2}\@@par}%
    \fi%
  #2\@@par}% added strut here then removed it (stupid boy)
\let\@@hskip\hskip
\let\@@interlinepenalty\interlinepenalty
%    \end{macrocode}
%\end{macro}
% 
% \begin{macro}{\SS@chapuline}
% 
% A simple command that underlines everything up to the next |\par|.  
% It's used to underline chapter and part headings.  The |\part| 
% commands need a bit of extra modification for this to work.  This 
% command is now obsolete, because I turned my brain on and added 
% grouping to the chapter and part code, so I don't have to use 
% \comname{par} as an argument delimiter any more.
%    \begin{macrocode}
% \def\SS@chapuline#1\par{\uline{#1}\par}
%    \end{macrocode}
%\end{macro}
%
% \begin{macro}{\SS@underline}
% Save the definition of |\underline| in |\SS@underline| so \LaTeX's 
% normal |\underline| command is available in sectioning commands when 
% |\underline| has been re-defined.  For some reason, the construction
% |\let\SS@underline\underline| didn't work right so I started doing 
% it this way.  This way is now essential, because I need to add 
% |\strut|s to keep the underlines lined up (|\SS@ulemsectuline| 
% underlines the numbers and words of a heading separately, which 
% means the underlining would have a discontinuity unless I forced all 
% both the number and title boxes to have the same depth by adding a 
% |\strut| to each).
% 
% First check the definition of |\underline| in |latex.ltx| 
% hasn't changed; then define |\SS@underline| to be the same with added 
% struts.
%    \begin{macrocode}
\CheckCommand*{\underline}[1]{%
  \relax
  \ifmmode\@@underline{#1}%
  \else $\@@underline{\hbox{#1}}\m@th$\relax\fi}
%
\def\SS@underline#1{%
  \relax
  \ifmmode\@@underline{\strut#1}%
  \else $\@@underline{\hbox{\strut#1}}\m@th$\relax\fi}
%    \end{macrocode}
% \end{macro}
%
%\begin{macro}{\SS@ulemunderlinechapfudge}
%\begin{macro}{\SS@ulemheadingchapfudge}
%\begin{macro}{\SS@normunderlinechapfudge}
% 
% Three remarkable similar commands, written to deal with the problem of 
% underlining the number part of KOMA-script chapter headings.  I'm sure 
% there's a better way of doing it, but this appears to work and my head 
% hurts now.
%
% \comname{SS@ulemheadingchapfudge} is the only one which is still 
% used.  I've not changed the name to anything more sensible out of 
% sheer inertia.
% 
%    \begin{macrocode}
% \def\SS@ulemunderlinechapfudge#1{%
%   \ifSS@komascript%
%     \ifnum\SSsectlevel=1% chapter level
%       \ifx\SS@headingpart\SS@nopartid%
%         \SS@oclto{1}{Koma-script chapter number part}%
%         \let\SS@savechapterformat\chapterformat%
%         \def\chapterformat{\uline{\SS@savechapterformat}}%
%         \def\@tempcmda{#1}%
%       \else%
%         \SS@oclto{1}{Koma-script chapter title part}%
%         \def\@tempcmda{\uline{#1}}%
%       \fi%
%     \else%
%       \SS@oclto{1}{Koma-script not chapter}%
%       \def\@tempcmda{\uline{#1}}%
%     \fi%
%   \else%
%     \SS@oclto{1}{Not Koma-script}%
%     \def\@tempcmda{\uline{#1}}%
%   \fi%
%   \@tempcmda
% }%

\def\SS@ulemheadingchapfudge#1#2{%
  \ifSS@komascript%
    \ifnum\SSsectlevel=1% chapter level
      \ifx\SS@headingpart\SS@nopartid%
        \SS@oclto{1}{Koma-script chapter number part}%
        \let\SS@savechapterformat\chapterformat%
        \def\chapterformat{#1{\SS@savechapterformat}}%
        \def\@tempcmda{#2}%
      \else%
        \SS@oclto{1}{Koma-script chapter title part}%
        \def\@tempcmda{#1{#2}}%
      \fi%
    \else%
      \SS@oclto{1}{Koma-script not chapter}%
      \def\@tempcmda{#1{#2}}%
    \fi%
  \else%
    \SS@oclto{1}{Not Koma-script}%
    \def\@tempcmda{#1{#2}}%
  \fi%
  \@tempcmda
}%

% \def\SS@normunderlinechapfudge#1{%
%   \ifSS@komascript%
%     \ifnum\SSsectlevel=1% chapter level
%       \ifx\SS@headingpart\SS@nopartid%
%         \SS@oclto{1}{Koma-script chapter number part}%
%         \let\SS@savechapterformat\chapterformat%
%         \def\chapterformat{\SS@underline{\SS@savechapterformat}}%
%         \def\@tempcmda{#1}%
%       \else%
%         \SS@oclto{1}{Koma-script chapter title part}%
%         \def\@tempcmda{\SS@underline{#1}}%
%       \fi%
%     \else%
%       \SS@oclto{1}{Koma-script not chapter}%
%       \def\@tempcmda{\SS@underline{#1}}%
%     \fi%
%   \else%
%     \SS@oclto{1}{Not Koma-script}%
%     \def\@tempcmda{\SS@underline{#1}}%
%   \fi%
%   \@tempcmda
% }%
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%\begin{macro}{\underline}
%\begin{macro}{\ulemheading}
% Two commands:
%  |\underline{text}|
%                        used for normal underlining in all headings
%  |\ulemheading{ulem underline command}{text}|
%                        used for fancy underlining in all headings
%  
% Basic idea:
%
% \comname{SS@makeulinesect} defines \comname{underline} and 
%                                    \comname{ulemheading} 
% appropriately for |\@startsection| headings.
% 
% |\SS@makeulinechap| defines |\underline| and |\ulemheading| appropriately 
% for chapter and modified part headings.
%
%    \begin{macrocode}
\AtBeginDocument{%
  \@ifundefined{UL@box}%
    {% if ulem has not been loaded
    \SS@oclto{1}{ulem not loaded; underlining setup}%
    \def\SS@makeulinesect{%
% \def\underline##1{\noindent\SS@underline{##1}}%
    \def\underbar##1{\SS@origunderline{\sbox\tw@{##1}\dp\tw@\z@\box\tw@}}%
    \def\underline{\SS@ulemsectuline{\SS@underline}}%
    \def\ulemheading##1{\SS@ulemsectuline{\SS@underline}}}%
%
    \def\SS@makeulinepartchap{%
%     \def\underline##1\par{\SS@underline{##1}\par}
%     \def\ulemheading##1##2\par{\SS@underline{##2}\par}}%
%     \def\underline##1{\SS@underline{##1}}% pre KOMA-script
%     \def\ulemheading##1##2{\SS@underline{##2}}}% pre KOMA-script
    \def\underbar##1{\SS@origunderline{\sbox\tw@{##1}\dp\tw@\z@\box\tw@}}%
%     \let\underline\SS@normunderlinechapfudge% 7/2/99
    \def\underline##1{\SS@ulemheadingchapfudge{\SS@underline}{##1}}%
%     \def\ulemheading##1##2{\SS@normunderlinechapfudge{##2}}% 7/2/99
    \def\ulemheading##1##2{\SS@ulemheadingchapfudge{\SS@underline}{##2}}}%
%
%   \def\SS@makeulinepart{%
%   \def\underline##1\par{\SS@underline{##1}\par}
%   \def\ulemheading##1##2\par{\SS@underline{##2}\par}}%
    }% endif ulem has not been loaded
%
    {% If ulem has been loaded
    \SS@oclto{1}{ulem loaded; underlining setup}%
    \def\SS@makeulinesect{%
    \def\underbar##1{\SS@origunderline{\sbox\tw@{##1}\dp\tw@\z@\box\tw@}}%
    \def\underline{\SS@ulemsectuline{\uline}}%
    \def\ulemheading##1##2{\SS@ulemsectuline{##1}{##2}}}%
%
    \def\SS@makeulinepartchap{%
%     \let\underline\SS@chapuline
%     \def\ulemheading##1##2\par{##1{##2}\par}}%
%     \let\underline\uline% pre KOMA-script
%     \def\ulemheading##1##2{##1{##2}}}% pre KOMA-script
    \def\underbar##1{\SS@origunderline{\sbox\tw@{##1}\dp\tw@\z@\box\tw@}}%
%     \let\underline\SS@ulemunderlinechapfudge% 7/2/99
    \def\underline##1{\SS@ulemheadingchapfudge{\uline}{##1}}%
    \let\ulemheading\SS@ulemheadingchapfudge}
    }% endif ulem has been loaded
}% end \AtBeginDocument
%    \end{macrocode}
%\end{macro}
%\end{macro}
%
%\begin{macro}{\SS@rr}
% Stolen from \filename{latex.ltx}; this command is used to remove the 
% \comname{leftskip} and \comname{parindent} changes from the definition 
% of \comname{raggedright} in \comname{@start\-section} headings so run-in 
% headings can be indented as specified when you say 
% \comname{raggedright}.
%    \begin{macrocode}
\def\SS@rr{\def\raggedright{%
  \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip}}
%   \leftskip\z@skip% part of the original def
%   \parindent\z@}% part of the original def
%    \end{macrocode}
%\end{macro}
% 
% \subsection{Stuff for putting rules around headings}
% 
% Start out with some supporting commands\ldots
%
%\begin{macro}{\ifSS@komascript}
% 
% I can think of several reasons to know if one of the KOMA-Script 
% classes has been loaded, so let's have a new if for the job. This was 
% written for the \comname{sectionrule} command, which needs to know one 
% way or another, and since \comname{@ifclassloaded} can't be used 
% outside the preamble, this seemed like a sensible solution. The 
% alternative involved hideous contortions or horrible inefficiency as 
% far as I could tell.
% 
%    \begin{macrocode}
\newif\ifSS@komascript
\SS@komascriptfalse
\@ifclassloaded{scrartcl}{\SS@komascripttrue}{}
\@ifclassloaded{scrreprt}{\SS@komascripttrue}{}
\@ifclassloaded{scrbook} {\SS@komascripttrue}{}
%    \end{macrocode}
%\end{macro}

%\begin{macro}{\SS@sectid}
% A command to allow detection of the current section level.  0=part, 
% 1=chapter, 2=section, and so on.
%    \begin{macrocode}
\newcommand{\SS@sectid}[1]{\gdef\SSsectlevel{#1}}
%    \end{macrocode}
%\end{macro}
%
%\begin{macro}{\SS@nopart}
%\begin{macro}{\SS@titlepart}
%\begin{macro}{\SSnopartid}
%\begin{macro}{\SStitlepartid}
%\begin{macro}{\SSifnumberpart}
%\begin{macro}{\SSiftitlepart}
% A set of commands to allow detection of what part of a chapter or 
% part heading is being typeset (the number part or the title part). 
% This is quite important for bunging rules around the Koma-script 
% chapter headings, if nothing else.
%
%    \begin{macrocode}
\newcommand{\SS@nopart}{\global\let\SS@headingpart\SS@nopartid}
\newcommand{\SS@titlepart}{\global\let\SS@headingpart\SS@titlepartid}
% 
\newcommand{\SS@nopartid}{number part}
\newcommand{\SS@titlepartid}{title part}
% 
\newcommand{\SSifnumberpart}{%
  \ifx\SS@headingpart\SS@nopartid
      \expandafter\@firstoftwo
    \else
      \expandafter\@secondoftwo
  \fi}
% 
\newcommand{\SSiftitlepart}{%
  \ifx\SS@headingpart\SS@titlepartid
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}
%    \end{macrocode}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\ifraggedleft}
% With a bit of luck, the following command detects if \LaTeX\ is 
% currently doing raggedleft typesetting -- this test is used by the 
% rule commands below. The tests are based on this stuff from 
% |latex.ltx|:
%\begin{verbatim}
% \def\centering{%
%   \let\\\@centercr
%   \rightskip\@flushglue\leftskip\@flushglue
%   \parindent\z@\parfillskip\z@skip}
% \def\raggedright{%
%   \let\\\@centercr\@rightskip\@flushglue \rightskip\@rightskip
%   \leftskip\z@skip
%   \parindent\z@}
% \def\raggedleft{%
%   \let\\\@centercr
%   \rightskip\z@skip\leftskip\@flushglue
%   \parindent\z@\parfillskip\z@skip}
%\end{verbatim}
% 
% If raggedleft is `on', the first argument is executed.  If it's 
% off, the second argument is executed.  This isn't the most elegant 
% code possible, but it does have the virtue that I understand it.
%    \begin{macrocode}
\def\ifraggedleft#1#2{%
  \edef\@tempcmda{\the\rightskip}%
  \edef\@tempcmdb{\the\z@skip}%
  \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
  \edef\@tempcmda{\the\leftskip}%
  \edef\@tempcmdb{\the\@flushglue}%
  \if@tempswa
    \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
    \fi
  \if@tempswa#1\else#2\fi}
%    \end{macrocode}
%\end{macro}
% \begin{macro}{\ifcentering}
% 
% A similar command to detect if centering is `on'; again, first 
% argument is executed if centering is on, second argument is executed 
% if it's not. This isn't the most elegant code possible, but it does 
% have the virtue that I understand it.
% 
%    \begin{macrocode}
% \def\ifcentering#1#2{%
%   \edef\@tempcmda{\the\rightskip}%
%   \edef\@tempcmdb{\the\@flushglue}%
%   \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
%   \edef\@tempcmda{\the\leftskip}%
%   \edef\@tempcmdb{\the\@flushglue}%
%   \if@tempswa
%     \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
%     \fi
%   \if@tempswa#1\else#2\fi}
\def\ifcentering{%
  \edef\@tempcmda{\the\rightskip}%
  \edef\@tempcmdb{\the\@flushglue}%
  \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
  \edef\@tempcmda{\the\leftskip}%
  \edef\@tempcmdb{\the\@flushglue}%
  \if@tempswa
    \ifx\@tempcmda\@tempcmdb\@tempswatrue\else\@tempswafalse\fi
    \fi
  \if@tempswa\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%    \end{macrocode}
%\end{macro}
% 
% \subsubsection{The main heading rule code}
% 
%\begin{macro}{\sectionrule}
% A rather dodgy command that will stick a rule across the full width of 
% the text, around a sectional heading, unless it's a run-in heading or 
% centred. Must be used as the last command in a |\...font| command;
%\begin{verbatim}
% \sectionrule{<top rule raise height>}   {<top rule height>}
%             {<bottom rule raise height>}{<bottom rule height>}.
%\end{verbatim}
% 
%    \begin{macrocode}
\newcommand{\sectionrule}[5]{%
  \ifcentering{%
    \PackageError{sectsty}%
    {Can't use \protect\sectionrule\space with \protect\centering}%
    {The \protect\sectionrule\space command doesn't work properly
    with sectional headings that\MessageBreak are centred, so I'll
    carry on as if you'd not used the \protect\sectionrule\space 
    command.}#5}%
    {\ifSS@komascript
      \ifnum\SSsectlevel>1
%       use normal sectionrule if Koma-script and not part/chapter
        \SS@oclto{1}{KOMA-script; normal section rule}%
        \SS@sectionrule{#1}{#2}{#3}{#4}{#5}%
      \else
%       use strange sectionrule if Koma-script and part/chapter
        \SS@oclto{1}{KOMA-script; part/chap section rule}%
        \SS@komapartchaprule{#1}{#2}{#3}{#4}{#5}%
      \fi
    \else
%     use normal sectionrule if not Koma-script
      \SS@oclto{1}{No KOMA-script; normal section rule}%
        \SS@sectionrule{#1}{#2}{#3}{#4}{#5}%
    \fi}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SS@sectionrule}
%
% This gets called by |\sectionrule| unless in a part or chapter 
% heading, and picks one of two commands to place the rules depending on 
% whether the heading's raggedleft or not.
%
%    \begin{macrocode}
\def\SS@sectionrule#1#2#3#4#5{%
  \ifraggedleft
    {\SS@rlsectionrule{#1}{#2}{#3}{#4}{#5}}%
    {\SS@normsectionrule{#1}{#2}{#3}{#4}{#5}}}
%    \end{macrocode}
%\end{macro}
%\begin{macro}{\SS@normsectionrule}
%\begin{macro}{\SS@rlsectionrule}
% These are the commands that do the dirty work for 
% \comname{SS@sectionrule} and actually place the rules around the 
% headings. \comname{SS@normsectionrule} does for raggedright and fully 
% justified headings; \comname{SS@rlsectionrule} does for raggedleft 
% headings.
%    \begin{macrocode}
\def\SS@normsectionrule#1#2#3#4#5{%
  \let\SS@@par\@@par\let\@@par\relax% very dodgy
  \noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}%
    #5\hfill\makebox[0pt][r]{\rule[#3]{\hsize}{#4}}%
  \let\@@par\SS@@par\@@par}
% 
\def\SS@rlsectionrule#1#2#3#4#5{%
  \let\SS@@par\@@par\let\@@par\relax% very dodgy
  \noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}\hfill%
    #5\makebox[0pt][r]{\rule[#3]{\hsize}{#4}}%
  \let\@@par\SS@@par\@@par}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\ifSS@starform}
%\begin{macro}{\secdef}
%
% Some code to help the rule drawing commands find out if the star form 
% of a chapter or part heading is being typeset. This information is 
% needed to get rules around chapters right in scrreprt and scrartcl.
%
%    \begin{macrocode}
\newif\ifSS@starform
% 
\def\secdef#1#2{\@ifstar{\SS@starformtrue#2}{\SS@starformfalse\@dblarg{#1}}}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
%\begin{macro}{\SS@komapartchaprule}
% 
% Some more commands for shoving rules around headings. They work just 
% like \comname{SS@sectionrule} and friends, but for part and chapter 
% headings
% 
%    \begin{macrocode}
% \def\SS@partchaprule#1#2#3#4#5{%
% \ifraggedleft{\SS@rlpartchaprule{#1}{#2}{#3}{#4}{#5}}%
% {\SS@normpartchaprule{#1}{#2}{#3}{#4}{#5}}}
\def\SS@komapartchaprule#1#2#3#4#5{%
  \ifraggedleft
    {\SS@rlkomapartchaprule{#1}{#2}{#3}{#4}{#5}}%
    {\SS@normkomapartchaprule{#1}{#2}{#3}{#4}{#5}}%
}
%    \end{macrocode}
%\end{macro}
% 
%\begin{macro}{\SS@normkomapartchaprule}
%\begin{macro}{\SS@komapartchaprule}
% 
% Called by \comname{SS@komapartchaprule}: these are the commands that 
% do the dirty work of placing the rules around the headings. 
% \comname{SS@normkomapartchaprule} does for raggedright and fully 
% justified headings; \comname{SS@rlkomapartchaprule} does for 
% raggedleft headings.
% 
%    \begin{macrocode}
% \def\SS@normpartchaprule#1#2#3#4#5\par{%
% \noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}%
% #5%
% \hfill\makebox[0pt][r]{\rule[#3]{\hsize}{#4}}%
% \par}
\def\SS@normkomapartchaprule#1#2#3#4#5{%
  \SS@oclto{1}{SS@normkomapartchaprule}%
  \ifSS@starform
    \SS@normsectionrule{#1}{#2}{#3}{#4}{#5}%
  \else
    \SSifnumberpart
  	  {\noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}#5}%
  	  {#5\hfill\makebox[0pt][r]{\rule[#3]{\hsize}{#4}}}%
  \fi
}
%    \end{macrocode}
% 
%    \begin{macrocode}
% \def\SS@rlpartchaprule#1#2#3#4#5\par{%
% \noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}\hfill%
% #5%
% \makebox[0pt][r]{\rule[#3]{\hsize}{#4}}%
% \par}
\def\SS@rlkomapartchaprule#1#2#3#4#5{%
  \SS@oclto{1}{SS@rlkomapartchaprule}%
  \ifSS@starform
    \SS@rlsectionrule{#1}{#2}{#3}{#4}{#5}%
  \else
    \SSifnumberpart
      {\noindent\makebox[0pt][l]{\rule[#1]{\hsize}{#2}}\hfill#5}%
      {#5\makebox[0pt][r]{\rule[#3]{\hsize}{#4}}}%
  \fi
}
%    \end{macrocode}
%\end{macro}
%\end{macro}
% 
% \subsection{The new author commands}
%
% The extra commands are below.  Note that the |\SSsectlevel| is 
% defined to be 0 in part headings, 1 in chapter headings, 2 in section 
% headings, and so on.  You might find this useful if you want to play 
% interesting games. \comname{minisec} is a KOMA-script sectioning 
% command which is one level lower than \comname{subparagraph}.
%
%    \begin{macrocode}
\newcommand*{\partfont}          [1]
   {\gdef\SS@partnumberfont{\SS@sectid{0}\SS@nopart\SS@makeulinepartchap#1}
    \gdef\SS@parttitlefont{\SS@sectid{0}\SS@titlepart\SS@makeulinepartchap#1}}
\newcommand*{\partnumberfont}    [1]
   {\gdef\SS@partnumberfont{\SS@sectid{0}\SS@nopart\SS@makeulinepartchap#1}}
\newcommand*{\parttitlefont}     [1]
   {\gdef\SS@parttitlefont{\SS@sectid{0}\SS@titlepart\SS@makeulinepartchap#1}}
\newcommand*{\chapterfont}       [1]
   {\gdef\SS@chapnumfont{\SS@sectid{1}\SS@nopart\SS@makeulinepartchap#1}
    \gdef\SS@chaptitlefont{\SS@sectid{1}\SS@titlepart\SS@makeulinepartchap#1}}
\newcommand*{\chapternumberfont} [1]
   {\gdef\SS@chapnumfont{\SS@sectid{1}\SS@nopart\SS@makeulinepartchap#1}}
\newcommand*{\chaptertitlefont}  [1]
   {\gdef\SS@chaptitlefont{\SS@sectid{1}\SS@titlepart\SS@makeulinepartchap#1}}
\newcommand*{\sectionfont}       [1]
   {\gdef\SS@sectfont{\SS@sectid{2}\SS@rr\SS@makeulinesect#1}}
\newcommand*{\subsectionfont}    [1]
   {\gdef\SS@subsectfont{\SS@sectid{3}\SS@rr\SS@makeulinesect#1}}
\newcommand*{\subsubsectionfont} [1]
   {\gdef\SS@subsubsectfont{\SS@sectid{4}\SS@rr\SS@makeulinesect#1}}
\newcommand*{\paragraphfont}     [1]
   {\gdef\SS@parafont{\SS@sectid{5}\SS@rr\SS@makeulinesect#1}}
\newcommand*{\subparagraphfont}  [1]
   {\gdef\SS@subparafont{\SS@sectid{6}\SS@rr\SS@makeulinesect#1}}
\newcommand*{\minisecfont}  [1]
   {\gdef\SS@minisecfont{\SS@sectid{7}\SS@rr\SS@makeulinepartchap#1}}
% 
\newcommand*{\allsectionsfont}   [1] {\partfont{#1}
                                      \chapterfont{#1}
                                      \sectionfont{#1}
                                      \subsectionfont{#1}
                                      \subsubsectionfont{#1}
                                      \paragraphfont{#1}
                                      \subparagraphfont{#1}
                                      \minisecfont{#1}}
% 
\allsectionsfont{\relax}
%    \end{macrocode}
% 
% \subsection{The re-defined sectioning commands}
%
% For obscure reasons, this is where I test to see if 
% \packname{sectsty} is being used with a class it'll work with. This 
% test isn't infallible, but it does let you know if \packname{sectsty} 
% will do nothing at all.
%
%    \begin{macrocode}
\@tempswafalse
%
\@ifclassloaded{article} {\@tempswatrue\SS@oclto{1}{article detected}} {}
\@ifclassloaded{report}  {\@tempswatrue\SS@oclto{1}{report  detected}} {}
\@ifclassloaded{book}    {\@tempswatrue\SS@oclto{1}{book    detected}} {}
\@ifclassloaded{letter}  {}                                            {}
\@ifclassloaded{slides}  {}                                            {}
%
\@ifclassloaded{scrartcl}{\@tempswatrue\SS@oclto{1}{scrartcl detected}} {}
\@ifclassloaded{scrreprt}{\@tempswatrue\SS@oclto{1}{scrreprt detected}} {}
\@ifclassloaded{scrbook} {\@tempswatrue\SS@oclto{1}{scrbook  detected}} {}
% \@ifclassloaded{handout} {} {}

\if@tempswa\else
    \PackageError{sectsty}%
    {The sectsty package doesn't work with\MessageBreak
    this document class}%
    {The sectsty package only works with the following classes:
    \MessageBreak
    the standard LaTeX document classes\MessageBreak
    article, report, and book; and\MessageBreak
    the KOMA-Script classes\MessageBreak
    scrartcl, scrbook, and scrreprt.}
\fi
%    \end{macrocode}
%
% \subsubsection{Section code for article, book, and report classes}
%
%    \begin{macrocode}
\@tempswafalse
%
\@ifclassloaded{article} {\@tempswatrue\SS@oclto{1}{article detected}} {}
\@ifclassloaded{report}  {\@tempswatrue\SS@oclto{1}{report  detected}} {}
\@ifclassloaded{book}    {\@tempswatrue\SS@oclto{1}{book    detected}} {}
\@ifclassloaded{letter}  {}              {}
\@ifclassloaded{slides}  {}              {}
%
\@ifclassloaded{scrartcl}{} {}
\@ifclassloaded{scrreprt}{} {}
\@ifclassloaded{scrbook} {} {}
% \@ifclassloaded{handout} {} {}
%    \end{macrocode}
%
% Code from |article.cls| and |report.cls| June 1996; same as book code.  
% Execute this only if the book, report, or article classes have been 
% loaded.
%    \begin{macrocode}
\if@tempswa
\SS@oclto{1}{section->subparagraph modifications for article, report, 
and book classes}%
\renewcommand\section{\@startsection {section}{1}{\z@}%
      {-3.5ex \@plus -1ex \@minus -.2ex}%
      {2.3ex \@plus.2ex}%
%     {\normalfont\Large\bfseries}}
      {\normalfont\Large\bfseries\SS@sectfont}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
      {-3.25ex\@plus -1ex \@minus -.2ex}%
      {1.5ex \@plus .2ex}%
%     {\normalfont\large\bfseries}}
      {\normalfont\large\bfseries\SS@subsectfont}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
      {-3.25ex\@plus -1ex \@minus -.2ex}%
      {1.5ex \@plus .2ex}%
%     {\normalfont\normalsize\bfseries}}
      {\normalfont\normalsize\bfseries\SS@subsubsectfont}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
      {3.25ex \@plus1ex \@minus.2ex}%
      {-1em}%
%     {\normalfont\normalsize\bfseries}}
      {\normalfont\normalsize\bfseries\SS@parafont}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
      {3.25ex \@plus1ex \@minus .2ex}%
      {-1em}%
%     {\normalfont\normalsize\bfseries}}
      {\normalfont\normalsize\bfseries\SS@subparafont}}
\fi
%    \end{macrocode}
%
% End re-defining section|->|subparagraph commands for article, 
% report, and book classes
%
% \subsubsection{Section code for scrartcl, scrbook, and scrreprt classes}
%
%    \begin{macrocode}
\@tempswafalse
%
\@ifclassloaded{article} {} {}
\@ifclassloaded{report}  {} {}
\@ifclassloaded{book}    {} {}
\@ifclassloaded{letter}  {}              {}
\@ifclassloaded{slides}  {}              {}
%
\@ifclassloaded{scrartcl}{\@tempswatrue\SS@oclto{1}{scrartcl detected}} {}
\@ifclassloaded{scrreprt}{\@tempswatrue\SS@oclto{1}{scrreprt detected}} {}
\@ifclassloaded{scrbook} {\@tempswatrue\SS@oclto{1}{scrbook  detected}} {}
% \@ifclassloaded{handout} {} {}
%    \end{macrocode}
% 
% Code from |scrclass.dtx| 1998/07/17 v2.5e. Execute this only if the 
% scrartcl, scrreprt, or scrbook classes have been loaded.
%
%    \begin{macrocode}
\if@tempswa
\SS@oclto{1}{section->minisec modifications for scrartcl, scrreprt, 
and scrbook classes}%
\renewcommand\section{\@startsection{section}{1}{\z@}%
  {-3.5ex \@plus -1ex \@minus -.2ex}%
  {2.3ex \@plus.2ex}%
  {\raggedsection\normalfont\size@section\sectfont\SS@sectfont}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\raggedsection\normalfont\size@subsection\sectfont\SS@subsectfont}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
  {-3.25ex\@plus -1ex \@minus -.2ex}%
  {1.5ex \@plus .2ex}%
  {\raggedsection\normalfont\size@subsubsection\sectfont\SS@subsubsectfont}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
  {3.25ex \@plus1ex \@minus.2ex}%
  {-1em}%
  {\raggedsection\normalfont\size@paragraph\sectfont\SS@parafont}}
\renewcommand\subparagraph{\@startsection{subparagraph}{5}{\parindent}%
  {3.25ex \@plus1ex \@minus .2ex}%
  {-1em}%
  {\raggedsection\normalfont\size@subparagraph\sectfont\SS@subparafont}}
\renewcommand\minisec[1]{\@afterindentfalse \vskip 1.5ex
  {\parindent \z@ \raggedsection\sectfont\SS@minisecfont {#1}\par\nobreak}%
  \@afterheading}%
  \fi
%    \end{macrocode}
%
% \subsection{Re-defined chapter code}
%
% \subsubsection{Chapter command for report class}
%
%% Code from |report.cls| June 1996
%    \begin{macrocode}
\@ifclassloaded{report}{%
\SS@oclto{1}{chapter modifications for report class}%
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
        \huge\bfseries\SS@chapnumfont{\@chapapp\space \thechapter}%
        \par\nobreak
        \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \raggedright \normalfont
    \Huge \bfseries \SS@chaptitlefont {#1}\par\nobreak
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries \SS@chaptitlefont {#1}\par\nobreak
    \vskip 40\p@
  }}%
}{}
%    \end{macrocode}
%
%% End code re-defining chapter stuff for report class
%
% \subsubsection{Chapter command for book class}
%
%% Chapter code from |book.cls| 1997/10/10 v1.3x
%
%    \begin{macrocode}
\@ifclassloaded{book}{%
\SS@oclto{1}{chapter modifications for book class}%
\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \huge\bfseries\SS@chapnumfont {\@chapapp\space \thechapter}%
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \raggedright \normalfont
    \Huge \bfseries \SS@chaptitlefont {#1}\par\nobreak
    \vskip 40\p@
  }}
\def\@makeschapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries \SS@chaptitlefont  {#1}\par\nobreak
    \vskip 40\p@
  }}%
}{}
%    \end{macrocode}
%
%% End code redefining chapter stuff from book.cls
% 
% \subsubsection{Chapter command for scrreprt class}
% 
% Code from \filename{scrreprt.cls} 1998/07/17 v2.5e.
% 
%% Begin code redefining chapter stuff from scrreprt.cls
%
%    \begin{macrocode}
\@ifclassloaded{scrreprt}{%
\SS@oclto{1}{chapter modifications for scrreprt class}%
\def\@makechapterhead#1{\chapterheadstartvskip%
  {\size@chapter{\sectfont\SS@chapnumfont
    \@hangfrom{\ifnum \c@secnumdepth >\m@ne%
               \chapterformat\fi}%
      {\raggedsection \interlinepenalty \@M \SS@chaptitlefont {#1}\par}}%
    \nobreak\chapterheadendvskip
  }}
\def\@makeschapterhead#1{\chapterheadstartvskip%
  {\parindent \z@ \raggedsection
    \normalfont
    \size@chapter\sectfont\SS@chaptitlefont {#1}\par
    \nobreak\chapterheadendvskip
  }}
}{}
%    \end{macrocode}
% 
%% End code redefining chapter stuff from scrreprt.cls
% 
% \subsubsection{Chapter command for scrbook class}
% 
% Code from \filename{scrbook.cls} 1998/07/17 v2.5e.
% 
%% Begin code redefining chapter stuff from scrbook.cls
%
%    \begin{macrocode}
\@ifclassloaded{scrbook}{%
\SS@oclto{1}{chapter modifications for scrbook class}%
\def\@makechapterhead#1{\chapterheadstartvskip%
  {\size@chapter{\sectfont\SS@chapnumfont
    \@hangfrom{\ifnum \c@secnumdepth >\m@ne%
                 \if@mainmatter \chapterformat\fi\fi}%
       {\raggedsection \interlinepenalty \@M \SS@chaptitlefont {#1}\par}}%
    \nobreak\chapterheadendvskip
  }}
\def\@makeschapterhead#1{\chapterheadstartvskip%
  {\parindent \z@ \raggedsection
    \normalfont
    \size@chapter\sectfont\SS@chaptitlefont {#1}\par
    \nobreak\chapterheadendvskip
  }}%
  }{}
  %    \end{macrocode}
% 
%% End code redefining chapter stuff from scrbook.cls
% 
% \subsection{Re-defined part code}
%
% \subsubsection{Part command for book class}
%
%% Part code from book.cls 1997/10/10 v1.3x
%\begin{macro}{\part}
%
% This code adds the |\SS@...font| hooks; there used to be some other 
% additions but there aren't any more because they were silly.
%
% \begin{macrocode}
\@ifclassloaded{book}{%
\SS@oclto{1}{part modifications for book class}%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries\SS@partnumberfont {\partname~\thepart}%
       \par
       \vskip 20\p@
     \fi
     \centering \normalfont
     \Huge \bfseries \SS@parttitlefont {#2}\par}%
    \@endpart}
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \normalfont \Huge \bfseries \SS@parttitlefont {#1}\par}%
    \@endpart}
}{}
%    \end{macrocode}
%
%% End code redefining part stuff from |book.cls|
%
% \subsubsection{Part command for article class}
%
%% Part code from |article.cls| 1997/10/10 v1.3x
%
%    \begin{macrocode}
\@ifclassloaded{article}{%
\SS@oclto{1}{part modifications for article class}%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \Large\bfseries\SS@partnumberfont {\partname~\thepart}%
       \par\nobreak
     \fi
     \raggedright \normalfont
     \huge \bfseries \SS@parttitlefont {#2}%
     \markboth{}{}\par}%
    \nobreak
    \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \huge \bfseries \SS@parttitlefont {#1}\par}%
     \nobreak
     \vskip 3ex
     \@afterheading}
}{}
%    \end{macrocode}
%
%% End code redefining part stuff from |article.cls|
%
% \subsubsection{Part command for report class}
%
%% Part code from |report.cls| 1997/10/10 v1.3x
%
%    \begin{macrocode}
\@ifclassloaded{report}{%
\SS@oclto{1}{part modifications for report class}%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}%
      \addcontentsline{toc}{part}{\thepart\hspace{1em}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \markboth{}{}%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \huge\bfseries\SS@partnumberfont {\partname~\thepart}%
       \par
       \vskip 20\p@
     \fi
     \centering \normalfont
     \Huge \bfseries \SS@parttitlefont {#2}\par}%
    \@endpart}
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \Huge \bfseries \SS@parttitlefont {#1}\par}%
    \@endpart}
}{}
%    \end{macrocode}
%
%% End code redefining part stuff from report.cls
%
% \subsubsection{Part command for scrbook and scrreprt classes}
%    \begin{macrocode}
\@tempswafalse
%
\@ifclassloaded{scrreprt}{\@tempswatrue}{}
\@ifclassloaded{scrbook} {\@tempswatrue}{}
%
%% Part code from |scrbook.cls| 1998/07/17 v2.5e
\if@tempswa%
\SS@oclto{1}{part modifications for scrreprt and scrbook classes}%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >-2\relax
      \refstepcounter{part}\@maybeasf%
      \addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    \chaptermark{}
    {\centering
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >-2\relax
       \size@partnumber\sectfont\SS@partnumberfont\partformat
       \par
       \vskip 20\p@
     \fi
     \size@part\sectfont\SS@parttitlefont {#2}\par}%
    \@endpart}
\def\@spart#1{%
    {\centering
     \interlinepenalty \@M
     \normalfont
     \size@part\sectfont\SS@parttitlefont {#1}\chaptermark{}\par}%
    \@endpart}%
    \fi
%    \end{macrocode}
%% End part code from |scrbook.cls| 1998/07/17 v2.5e
%
% \subsubsection{Part command for the scrartcl classes}
%
%% Part code from |scrartcl.cls| 1998/07/17 v2.5e
%    \begin{macrocode}
\@ifclassloaded{scrartcl}{%
\SS@oclto{1}{part modifications for scrartcl classes}%
\def\@part[#1]#2{%
    \ifnum \c@secnumdepth >\m@ne
      \refstepcounter{part}\@maybeasf%
       \addcontentsline{toc}{part}{\protect\numberline{\thepart}#1}%
    \else
      \addcontentsline{toc}{part}{#1}%
    \fi
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \ifnum \c@secnumdepth >\m@ne
       \size@partnumber\sectfont\SS@partnumberfont\partformat
       \par\nobreak
     \fi
     \size@part\sectfont\SS@parttitlefont {#2}%
     \sectionmark{}\par}%
     \nobreak
     \vskip 3ex
    \@afterheading}
\def\@spart#1{%
    {\parindent \z@ \raggedright
     \interlinepenalty \@M
     \normalfont
     \size@part\sectfont\SS@parttitlefont {#1}\sectionmark{}\par}%
     \nobreak
     \vskip 3ex
    \@afterheading}%
    }{}
%    \end{macrocode}
% 
%\end{macro}
% The end
%    \begin{macrocode}
\endinput
%    \end{macrocode}
%
% \Finale
%\iffalse
%<*package>
%% 
%% End of file `sectsty.dtx'.
%% \fi