Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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
    
no problem at all –  John Salvatierrez Dec 5 '12 at 21:56
    
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

1 Answer 1

up vote 7 down vote accepted

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:

enter image description here

\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}
share|improve this answer
    
...why on earth didn't I think of that? by the way, do you happen to know if titlesec modifies the abstract title and whatnot? Just out of curiosity, as renewcommand does what I need it to do. –  John Salvatierrez Dec 5 '12 at 21:54
1  
@carmelodevisu: titlesec.sty does not reference \abstractname. I doubt it would change anything, since it's designed to give the user the ability to change that. Other packages might change this since their goal is to (say) language-specific. See, for example, How to change the name of document elements like “Figure”, “Contents”, “Bibliography” etc.? –  Werner Dec 5 '12 at 22:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.