tags:

views:

367

answers:

2

In this question I asked, how to produce rules under sections. The answer provided using sectsty does what I wish, but triggers a problem: If I use the package sectsty the \part-command produces an error:

! Undefined control sequence.
\NR@part ...elax \refstepcounter {part}\@maybeasf 
                                                  \addcontentsline {toc}{par...
l.8 \part{partname}

If I use book-documentclass instead of scrbook, it works all right. But I use much features of Komascript, so I don't want to switch. Knows anyone a solution, how I can use both together?

EDIT: Following simple example reproduces the problem:

\documentclass{scrbook}
   \usepackage{sectsty}
\begin{document}
   \part{test} % crash and burn here
\end{document}
A: 

So... what class are you using? The standard book class or the srcbook in komascript?

If you're using the standard book class, sectsty has specific commands for the \part command:

\partnumberfont{hcommandsi} Changes the style of part' heading numbers only; this does not aect the title of the part heading. \parttitlefont{hcommandsi} Changes the style of part' heading titles only; this does not aect the number of the part heading. \partfont{hcommandsi} Changes the style of `part' headings only by executing {hcommandsi} before printing each heading; this aects both the title of the part and the part number.

If you're using the KOMA-script class, the sectsty documentation states:

If you just want to change the fount used for all sectional headings, you shouldn't use sectsty with any of the KOMA-script classes. Instead, you should redene the \sectfont command provided by the KOMA-script If you'd like dierent sectional headings to be printed with dierent 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 \sectfont command, then sectsty might be of use with the KOMA-script classes. You should note that the modications applied by sectsty commands happen immediately after the \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 dierences in behaviour when things go wrong, sectsty should work as expected with the KOMA-script classes.

from: Sectsty Documentation Chapter Four

EDIT: If all you want is a line under your section and chapters, but still want to use the \part command, why not just ditch sectsty, and re-define the sectioning commands in koma-script using \hrule?

Mica
You don't understand my problem. Redefining the section works fine - as long as I don't use the \part-command and srcbook-class. In this moment the \part triggers the above written problem.
Mnementh
So you're using the sectsty package with the KOMA-script srcbook class? Is that correct?
Mica
Yep. I added an example reproducing the problem.
Mnementh
also check out http://zoonek.free.fr/LaTeX/LaTeX_samples_section/0.html example #13.
Mica
+1  A: 

The problem is that sectsty was written to work with an older version of scrbook. If you look at the sectsty.sty file at line 553, you'll find that it uses some code from scrbook.cls v2.5e from 1998. That's where the problem is occurring. If you splice in the relevant section of the latest version of scrbook.cls (v3.04a, 2009/07/24) into sectsty.sty, it all seems to work ok. I've done this and put the file here. Note that I haven't tested this other than to make sure it runs ok on your example code.

Rob Hyndman
That brings up the question, if sectsty is under further development and will release future version.
Mnementh
I tested your solution and it worked fine. Thanks.
Mnementh