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.

Me again... very close to the layout I'm looking for already, but not quite there yet. ;-)

For chapter headers, I am trying to get this look for chapter headings:

I.C.E.'s Rolemaster

I.e.,

  • \thechapter centered,
  • with a solid black box (the same height as the numbers) to the left and to the right, spanning the width of the text area.
  • The name of the chapter on the next line, also centered, without the boxes.

I got the "Chapter" string removed, I got the ".0" appended to the chapter number (thanks to Stefan for helping with that one), and contentet myself with writing \chapter{MYCHAPTER} instead of trying to get LaTeX doing the uppercasing for me. I get "1.0 MYCHAPTER" written for a chapter header - so far so good.

But now I am stuck. I read and googled, and found plenty of examples using \@startsection for adding boxes around headers, lines above and lines below and backdrops behind them, getting increasingly more complex and daunting - but couldn't figure out how to do those black boxes to the left and the right of the chapter numbers.

Help?

share|improve this question
add comment

2 Answers 2

up vote 8 down vote accepted

With the titlesec package I can get you some of the way there:

\usepackage{titlesec}
\titleformat{\chapter}[display]{\normalfont\huge\bfseries}{\hrulefill\thechapter.0\hrulefill}{20pt}{\Huge\center}

I've basically copied the standard definition, but changed the third mandatory argument to \hrulefill\thechapter.0\hrulefill. What \hrulefill does is fill the available horizontal space with a rule.

With a \rule you could create your thick rules as follows: \rule{10em}{1ex} which would give a rule 10em long and 1ex thick. I don't know how to get a "thick" \hrulefill though.

I hope this goes some way towards solving your problem.

share|improve this answer
2  
See this answer to another question for making a "thick" \hrulefill. –  You Aug 9 '11 at 12:03
    
You could as well redefine \thechapter: \renewcommand{\thechapter}{\arabic{chapter}.0}. –  ℝaphink Aug 9 '11 at 12:19
    
@Raphink: Already did so. –  DevSolar Aug 9 '11 at 12:55
add comment

Seamus and You got me on the right track. This is a combination of their hints:

% Ignore-The-Height (ith), used to avoid additional vspace
% e.g. with umlauts. See http://tex.stackexchange.com/questions/29911.
\newcommand{\ith}[1]
    {\leavevmode\smash{\uppercase{#1}}}

% Variable-width rulers, default width 14pt
\newcommand*\varhrulefill[1][14pt]
    {\leavevmode\leaders\hrule height#1\hfill\kern0pt}

\usepackage{titlesec}

\titleformat{\chapter}[display]
    {\normalfont\huge\bfseries}
    {\varhrulefill\enskip\thechapter\enskip\varhrulefill}
    {12pt}
    {\center\ith}
  • I changed the default height of \varhrulefill from You's link to 14pt as that is my desired default size;
  • I added a \enskip to push the boxes a bit away from the chapter numbers;
  • I added an \uppercase to the after command so I actually don't have to write the chapter title in uppercase myself.
  • I came back two months later to include this improvement and the general evolution of the solution to this answer.

The result is pretty much exactly what I were looking for:

enter image description here

Thanks, guys. You are awesome.

share|improve this answer
    
I give the "correct answer" to Seamus because he got me on the right track. –  DevSolar Aug 9 '11 at 12:19
add comment

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.