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'm writing a longer text and redefined the Design of a Chapter start page using titlesec. For example

\documentclass[cleardoublepage=empty,fontsize=11pt,a4paper,twoside,DIV=calc]{scrbook}

\usepackage[no-math]{fontspec}
\usepackage{xunicode,xcolor} 
\usepackage{hyperref,titlesec,scalefnt}

\titleformat{\chapter}[display]%
    {\relax\huge\color{blue}}%
    {\Huge\raggedleft{\textcolor{blue!25}{\scalefont{4}\thechapter}}}{0pt}{}
\titlespacing{\chapter}{0pt}{\baselineskip}{\baselineskip}

\begin{document}
    \begin{mainmatter}
        \chapter{Eins}
    \end{mainmatter}
    \begin{backmatter}
        \chapter{Ein Beispiel}
    \end{backmatter}
\end{document}

Which sets the chapter number in light blue and huge to the right (see Chapter 1). But if i change into the backmatter to add an appendix chapter (which should be apendix A), the whole titlesec (from the second block) definition is lost. I would like to have A as the “appendix number” and set to the right, as the chapter number before (and of course “A An Example” to the toc).

How can i achieve, that the numbering is set to A (and shown) and that the titlesec-definition is not lost?

share|improve this question
    
This should be useful (I hope you understand German): Incompatibilities between KOMA-Script and titlesec. –  Speravir Oct 26 '12 at 17:46
    
Actually, i am german, so thanks for the links. I looked at some of the topics earlier, but i can't find a way to get the chapter number to the right with the koma script ”replacements“ for \titleformat –  Ronny Oct 26 '12 at 18:07
add comment

2 Answers

up vote 2 down vote accepted

\backmatter (which, BTW is -- like \frontmatter -- a switch, not an environment) will turn off sectioning numbering, including the numbering of appendices. Use \appendix instead of \backmatter.

\documentclass{scrbook}

\usepackage[no-math]{fontspec}
\usepackage{xunicode,xcolor} 
\usepackage{hyperref,titlesec,scalefnt}

\titleformat{\chapter}[display]%
    {\relax\huge\color{blue}}%
    {\Huge\raggedleft{\textcolor{blue!25}{\scalefont{4}\thechapter}}}{0pt}{}
\titlespacing{\chapter}{0pt}{\baselineskip}{\baselineskip}

\begin{document}

\mainmatter
\chapter{Eins}

\appendix
\chapter{Ein Beispiel}

\end{document}
share|improve this answer
    
Yah, okay, that's easier than mine :) –  cgnieder Oct 26 '12 at 21:23
    
Actually, the frontmatter environment works fine, page numbers are roman, the PDF TOC is correct and the backmatter environment also does, what you mentioned. But i couldn't find any documentation of these environments, you're right. I wasn't aware, that backmatter turns numbering off. I thought Appendicies belong to the backmatter and was used to see them Numbered in roman numerals. So this solution is easier than i thought. –  Ronny Oct 27 '12 at 6:17
    
And - actually - that also solved my second problem concerning the pagestyle, that was also changed in the backmatter and now just works fine (“A. An Example” as it should be). –  Ronny Oct 27 '12 at 6:22
add comment

May I suggest not to use titlesec but to redefine \chapterformat and use \setkomafont{chapter}?

In order to get your requirements for the back matter we need \backmatter not to set \@mainmatterfalse but to reset the chapter counter instead.

Here is one way:

\documentclass[cleardoublepage=empty,fontsize=11pt,a4paper,twoside,DIV=calc]{scrbook}

\usepackage[no-math]{fontspec}
\usepackage{xunicode,xcolor} 
\usepackage{hyperref,scalefnt}
\usepackage{lipsum}% for dummy text

\makeatletter
% the chapter format:
\KOMAoption{chapterprefix}{true}
\renewcommand*\chapterformat{%
    \hbox to \linewidth{\hfill{\normalfont\Huge\color{blue!25}\scalefont{4}\thechapter}}%
  }
\setkomafont{chapter}{\normalfont\Huge\color{blue!25}}

% redefinition of \backmatter:
\renewcommand*\backmatter{%
  \if@openright\cleardoubleoddpage\else\clearpage\fi
  \setcounter{chapter}{0}%
  \renewcommand*\thechapter{\Alph{chapter}}%
  \@ifundefined{hypersetup}
    {}{\renewcommand*\theHchapter{\Alph{chapter}}}%
}
\makeatother

\begin{document}
\frontmatter
\tableofcontents

\mainmatter
\chapter{Eins}
\lipsum

\backmatter
\chapter{Ein Beispiel}
\lipsum

\end{document}
share|improve this answer
    
I tried to use \setkomafont but wasn't able to reproduce for example the \raggedleft - well you did :) . Though locksteps solution is easier and nicer. –  Ronny Oct 27 '12 at 6:19
    
You could combine his and mine. This way you'd need one package less... –  cgnieder Oct 27 '12 at 6:49
    
On the other hand, the code with titlesec is shorter, well nicer at least for the chapter number (and i use for example titletoc anyways). But maybe i'll give it a try. –  Ronny Oct 27 '12 at 7:06
    
Well, "nicer" is a subjective attribute but if you need titletoc anyway you can quite as well use it, of course. –  cgnieder Oct 27 '12 at 7:32
    
Of course, that's just subjective. –  Ronny Oct 27 '12 at 8:28
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.