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.

Somehow I my attempt to change the placement of \chapter seems not to work. I would like to that my chaptertitle begins right at the top of the page. Do I need to change the plain pagestyle?

\documentclass[paper=15cm:23cm, headinclude=true, numbers=enddot, draft]{scrbook}

\usepackage[ngerman]{babel}

\usepackage[automark]{scrpage2}   
\renewcommand*{\headfont}{% 
\normalfont\sffamily\scshape} 
\renewcommand*{\chaptermarkformat}{} 
\renewcommand*{\sectionmarkformat}{}

\usepackage{titlesec}
\setkomafont{chapter}{\huge\normalfont\sffamily\bfseries}

%Position of Chaptertitle
\titlespacing{\chapter}{0pt}{-50pt}{20pt}

\begin{document}
\chapter{This first chapter}
Hi there.
\end{document}
share|improve this question
    
First: It would be really better, if you’d provide a full MWE! Second: As you live in Berlin and have a German comment in your code I suppose this answer of mine could be helpful: About KOMA-Script and titlesec incompatibility. –  Speravir Apr 14 '12 at 0:02
    
OMG, the most obvious \usepackage[ngerman]{babel} I’ve overlooked. What are tocloft and etoolbox for? If not needed here, leave them out. –  Speravir Apr 14 '12 at 1:03
add comment

2 Answers

up vote 5 down vote accepted

If you define both the \titleformat and the \titlespacing, then you can have complete control:

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage{titlesec}

\setkomafont{chapter}{\huge\normalfont\sffamily\bfseries}

%Position of Chaptertitle
\titleformat{\chapter}
            {\usekomafont{chapter}}
            {\thechapter.\hspace{1em}}
            {0pt}
            {}
\titlespacing{\chapter}{0pt}{-50pt}{20pt}
\begin{document}
\chapter{This first chapter}
Hi there.
\end{document}

I am not sure at the moment why you cannot just use \titlespacing, but it probably has to do with the way KOMA redefines the section styles. Note that you do not need to use the advanced interface – it suffices to issue any of the of titlesec commands that actually touch the format. Thus, you can also use the easy setup, specifying one of the class options rm, sf, tt, md, bf, up, it, sl, sc as described in the manual:

\documentclass{scrbook}
\usepackage[ngerman]{babel}
\usepackage[sf,bf]{titlesec}

% This is optional when the easy-setup is used:
%\setkomafont{chapter}{\huge\normalfont\sffamily\bfseries}
%\titleformat*{\chapter}{\usekomafont{disposition}\usekomafont{chapter}}

% Position of Chapter title
\titlespacing{\chapter}{0pt}{-50pt}{20pt}
\begin{document}
\chapter{This first chapter}
Hi there.
\end{document}
share|improve this answer
    
I deleted the redundant \usepackage{disposition}. I could have deleted alternatively the more specific \usepackage{chapter} as well. –  Speravir Apr 14 '12 at 18:31
    
@Speravir I assume you meant to say \usekomafont{disposition}. Are you sure this conforms with the default KOMA behaviour? The English documentation seems to indicates that both disposition and chapter should be used to emulate the default behaviour. (Maybe this is a translation ambiguity?) –  mforbes Apr 14 '12 at 20:41
    
Yes, I meant this one. disposition is the generic element for several other elements, which use it’s definition. Whether \usekomafont{disposition} is needed, depends of a redefinition by \setkomafont or \addtokomafont of disposition or a dependent element. Here inside \usekomafont{chapter} the whole default definition of disposition is already included, so it could be removed. (Side remark: There is an alias for disposition named sectioning, where I as a not natural English speaker understand much better, what it is meant for.) –  Speravir Apr 15 '12 at 0:40
add comment

The following code works fine.

I introduced titlesecs command \titleformat, which is made for such efforts.

Notes:

  • I’ve added a font package (kpfonts is only an example, but an excellent), because without that your definition for the pagehead didn’t work.

  • I’d use the pagestyle scrheadings, so I’ve added the according command.

  • Together with KOMA-Script it is recommended to use the package’s own font switch commands also for scrpage2 influenced font attributes (see KOMA-Script manual, section for scrpage2).

  • On the other hand this KOMA-Script own font switch for “chapter” does not work here with \titleformat; it seems, it’s another KOMA-Script and titlesec incompatibility. But there is cure by the use of \usekomafont inside the \titleformat definition (thanks to mforbes for this idea). Note, that the documentclass option headings=big, which also should set the chaptertitle to \huge, does not work either!

  • I’ve changed your absolut values for title separation into relative ones: \baselineskip and em instead of pt.

      \documentclass[%
      paper=15cm:23cm,%
      headinclude=true,%
      numbers=enddot,%
      draft,%
    ]{scrbook}%
    \usepackage[T1]{fontenc}
    %\usepackage[utf8]{inputenc}
    
    \usepackage{kpfonts}
    
    \usepackage[ngerman,latin]{babel}% option "latin" only because of use of "lipsum"
    
    \usepackage[automark]{scrpage2}
    \pagestyle{scrheadings}
    \renewcommand*{\chaptermarkformat}{}% no numbering in the pagehead
    \renewcommand*{\sectionmarkformat}{}
    %%% works, but is not recommended together with KOMA-Script:
    %\renewcommand*{\headfont}{
    %\normalfont\sffamily\scshape}
    %%% This is the recommended way:
    \setkomafont{pagehead}{\normalfont\sffamily\scshape}
    
    \usepackage{titlesec}
    \setkomafont{chapter}{\normalfont\sffamily\bfseries\huge}
    
    \titleformat{\chapter}
                {\usekomafont{chapter}}
                {\thechapter.}
                {1em}
                {\filleft}
    
    %Position of Chaptertitle
    \titlespacing{\chapter}{0pt}{-3\baselineskip}{2\baselineskip}%
    
    \usepackage{lipsum}
    
    \begin{document}
    
    \chapter{Lipsum Lapsum Lepsum Lopsum Lupsum Lypsum}
    \lipsum[1-5]
    
    \chapter{Lorem Ipsum}
    \lipsum[6-10]
    
    \end{document}
    
share|improve this answer
    
I meant something different. But Thanks! –  algomachine Apr 14 '12 at 8:05
    
I noticed. Please see my updated answer. I hope the other information is also useful for you. –  Speravir Apr 14 '12 at 18:42
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.