# titlesec: why is contents a section?

I've been playing around with the titlesec package combined with the scrartcl class. I find the headings titles of scrartcl a bit ugly, but I do like the fact that I can scale font sizes to 8pt.

Anyway that's not the point. I'm defining sections to be of the form

1.8 --- Sectionname.

But Contents is treated like a Section, and I am thus left with the most ugly

--- Contents.

How to fix that? Am I using the titlesec package improperly?

MWE:

  \documentclass{article}
\usepackage[compact]{titlesec}
\titleformat{\section}[block] % section
{\scshape}
{\thesection}
{0pt}{\filcenter \hspace{.3em}---\hspace{.3em}}[]
\titlespacing*{\section}
{0em} %left
{0em} %before
{1em} %after/below
\begin{document}
\tableofcontents
\section{this a secti}
ion.
\end{document}


p.s. I also found myself doing things like \renewcommand{\abstractname}{\normalfont\scshape Abstract}, am I a bad person?

• I have edited the formatting of your question, I hope you don't mind; in particular, you can use backticks  to mark your inline code – Corentin Dec 5 '12 at 21:52
• for anyone interested: instead of using a renewcommand for the abstractname, scrartcl comes with a \sectfont command, and one can renew that to uniformly change style. – John Salvatierrez Dec 6 '12 at 5:39

You should include the --- as part of the numbered component of the sectional heading, not the text part. This way it will only show when the section is numbered:

\documentclass{article}
\usepackage[compact]{titlesec}% http://ctan.org/pkg/titlesec
\titleformat{\section}[block] % section
{\scshape}
{\thesection\hspace{.3em}---\hspace{.3em}}
{0pt}{\filcenter}[]
\titlespacing*{\section}
{0em} %left
{0em} %before
{1em} %after/below
\begin{document}
\tableofcontents
\section{This a section}
This is some regular text.
\end{document}
`