9

A quick question: Is it possible to change the name of a part/chapter/section with some sort of command?

For example, I have a chapter called "Important Things". I created this chapter with the command \chapter{Important Things}. This prints the title of the chapter and adds an entry in the ToC.

I guess that the information about the chapter name is stored and can somehow be accessed by a command like \chaptername or \chaptertitle or something similar. So let's assume that "Important Things" is the current "value" of the chapter-name. What if I now want to change this "value" into "Unimportant Things". For this I cannot use \chapter{Unimportant Things}, because if I use that, then I change the value of the chapter-name but I also print a chapter heading.

Maybe I could also ask the following: Can I create a part/chapter/section without printing a heading and without having an entry in the ToC?

I am not sure if I made myself clear.

I've been asked for a MWE. There you see that the page headers after the new part continue to bear the section title and chapter title of the previous part.

%!TEX TS-program = lualatexmk
\documentclass{scrbook}
\usepackage{fmtcount}
\usepackage[noindentafter]{titlesec}
\addtokomafont{part}{\thispagestyle{empty}\Huge\textsc}
\addtokomafont{partnumber}{\Huge\textsc}
\renewcommand*{\partformat}{\partname~\numberstring{part}}

\titleformat{\chapter}[display]{\fillast}{\Large\textsc{\chaptertitlename~\numberstring{chapter}}}{1ex minus .1ex}{\LARGE\emph}
\titlespacing{\chapter}{1pc}{*3}{*20}[1pc]

\titleformat{\section}[block]{\fillast\large}{\thesection}{.5em}{\large\textsc}
\titlespacing{\section}{1pc}{*6}{*2}[1pc]

\titleformat{\subsection}[block]{\fillast\itshape}{\thesubsection}{.5em}{}
\titlespacing{\subsection}{1pc}{*3}{*2}[1pc]

\titleformat{\subsubsection}[block]{\fillast}{}{0pt}{}
\titlespacing{\subsubsection}{1pc}{*3}{*2}[1pc]

\usepackage{titleps} \newpagestyle{chapter_and_section}{ \sethead[\thepage][\emph{\chaptertitle}][]{}{\emph{\sectiontitle}}{\thepage} \setfoot[][][]{}{}{} } \pagestyle{chapter_and_section} \newpagestyle{first_page_of_chapter}{ % here is the definition of the first page of a chapter \sethead[][][]{}{}{} \setfoot[][\thepage][]{}{\thepage}{} } \assignpagestyle{\chapter}{first_page_of_chapter}

\begin{document} \addpart{Some Things} \chapter{Some Stuff} \section{More Stuff} Text.\newpage Text.\newpage Text.\newpage Text.\newpage \addpart{Important Things} Text.\newpage Text.\newpage Text.\newpage Text.\newpage \end{document}

  • 1
    \chapter[Important Things]{Unimportant Things} prints Unimportant Things as title chapter but Important Things in table of contents and headings. Does it works for you? – Ignasi Jan 22 '15 at 07:53
  • No, not really. I am not looking for that. I want Important Things in the ToC and as the heading of the Chapter. I just want to change afterwards the name of the chapter into Unimportant Things. – ClintEastwood Jan 22 '15 at 07:55
  • \markboth{whatever you want}{something else}? – Johannes_B Jan 22 '15 at 08:01
  • titleps does not like \markboth, as I heard (http://tex.stackexchange.com/a/89911/12277) – ClintEastwood Jan 22 '15 at 08:03
  • I bet with a minimal working example, we can find the reason and not just treat the symptom. If this would be the standard behaviour, someone would have reported that by now. – Johannes_B Jan 22 '15 at 08:16
  • You shouldn't use titleps with KOMA-script. KOMA comes with its very own scrlayer-scrpage that is designed to be compatible. – Johannes_B Jan 22 '15 at 08:33
  • Your option here is to issue \sethead[\thepage][][]{}{}{\thepage} immediately after \addpart to clear the headers of \chaptertitle and \sectiontitle. However, heed @Johannes_B's suggestion of the class-specific header/footer options... – Werner Jan 22 '15 at 08:34
  • @Johannes_B : I know, but I was not able to achieve the formatting I wanted with the KOMA tools and it was so easy with titleps. – ClintEastwood Jan 22 '15 at 08:34
  • Or in other words, titleps is for extending the generic standard classes and doesn't take account for all the features and special stuff by KOMA. – Johannes_B Jan 22 '15 at 08:34
  • @Werner : This overrides the header also for possible later chapters and sections, so that I would have to reconfigure the header again when I add a chapter or section after the part. All that is possible but not elegant. It would be easier if I could just add after \addpart something like \clearsectionname or \sectionname{}. – ClintEastwood Jan 22 '15 at 08:38
  • 1
    Just looked at the example, should be fairly easy with an up-to-date KOMA. Give me a bit :-) – Johannes_B Jan 22 '15 at 10:25

1 Answers1

8

Using the interface of scrlayer-scrpage provided by the KOMA-bundle, this should be what you are after:

\documentclass{scrbook}
\usepackage{scrlayer-scrpage}
\ohead{\pagemark}
\cehead{\leftmark}
\cohead{\rightmark}

\renewcommand{\chaptermarkformat}{}
\renewcommand{\sectionmarkformat}{}

\begin{document}
\addpart{Some Things}
\chapter{Some Stuff}
\section{More Stuff}
Text.\newpage
Text.\newpage
Text.\newpage
Text.\newpage
\addpart{Important
Things}
Text.\newpage
Text.\newpage
Text.\newpage
Text.\newpage
\end{document}

Only KOMA

Taking into account the other stuff with the ambition not to use packages like titlesec or titleps which are incompatible to KOMA-script, which has its own interface.

Here should be what you want using only KOMA-script stuff. I should mention that it uses features that have just been introduced with KOMA-script v. 3.15.

Below, i tried to put the stuff and thinking process into blocks. For example, first adjusting the space above chapters, and at last the space below chapters.

\documentclass{scrbook}
%\usepackage{fmtcount}%not needed
\usepackage{blindtext}

\addtokomafont{part}{\Huge\textsc}
\renewcommand{\partpagestyle}{empty}
\addtokomafont{partnumber}{\Huge\textsc}

%dealing with chapters
\KOMAoption{chapterprefix}{true}
\let\raggedchapter\centering%Center all chapterheads
\addtokomafont{disposition}{\normalfont}%removes the bold face
\renewcommand{\chapterheadstartvskip}{\vspace{3ex}}
\addtokomafont{chapterprefix}{\Large\scshape}
\renewcommand{\chapterheadmidvskip}{\par\nobreak\vspace{1ex minus .1ex}}
\setkomafont{chapter}{\LARGE\emph}
\renewcommand{\chapterheadendvskip}{\vspace{20ex}}

%dealing with (sub/subsub)sections
\let\raggedsection\centering%Center all sectioningheads
%all levels have something in common, let's save typing:
\RedeclareSectionCommands[beforeskip=-3ex,
afterskip=2ex]{section,subsection,subsubsection}
\addtokomafont{section}{\large\textsc}
\RedeclareSectionCommand[beforeskip=-6ex]{section}
\addtokomafont{subsection}{\itshape}

\usepackage[automark]{scrlayer-scrpage}
\ohead{\pagemark}
\cehead{\leftmark}
\cohead{\rightmark}
\renewcommand{\chaptermarkformat}{}
\renewcommand{\sectionmarkformat}{}
\ofoot*{}%Clear the outer foot
\cfoot[\pagemark]{}%pagemark in the center only on plain pages
\addtokomafont{pagehead}{\itshape}
%italics instead of slanted


\setkomafont{descriptionlabel}{\usekomafont{disposition}\scshape}
%descriptionlabels will now look a bit pleasing with respect to the headings

\begin{document}
\addpart{Some Things}
\blinddocument
\addpart{Important Things}
\blinddocument
\end{document}

Since you aren't used to the interface, it might be a bit intimidating. But i myself spent more time in the titlesec documentation to look up which space is where. You should have no trouble figuring out where to change which space/skip.

Addendum:

The pagehead was set to itshape but it looked almost identical before?
Everytime one can set or add to a komafont it will be preset somewhere. For the pagehead it is \normalfont\slshape.

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
  • This only works for the formatting in my MWE, which is a minimal working example. In the full document, the formatting is more complex, because the first page of each chapter has a different formatting than the rest having an empty header and only the page number centered in the footer. This I could not achieve with KOMA (I guess it is possible though, but it was so easy with titleps and I also love titlesec). – ClintEastwood Jan 22 '15 at 08:44
  • You can specify the specs in the question and i'll show you how it workds. titlesec is another package that extends the generic standard classes, beiing not aware of the KOMA extension it breaks stuff. You get respective warnings. The interface to change the appearance of sections with KOMA-script has changed, you can open a new question for that. It will be interesting for others as well. – Johannes_B Jan 22 '15 at 08:57
  • I'd be delighted and grateful if you want to give it a shot. – ClintEastwood Jan 22 '15 at 09:37
  • Please see the update. – Johannes_B Jan 22 '15 at 11:48
  • Well, i forgot one thing. You wanted to have the headers with \emph which is almost always \itshape. The example above uses \slshape. You can use \addtokomafont{pagehead}{\itshape} ;-) Fairly easy, isn't it? ;-) – Johannes_B Jan 22 '15 at 11:53
  • @ClintEastwood Well spotted. I edited the answer, but didn't use empty brackets, i used i feature introduced in v. 3.14 in september :-) I reordered the code a bit, it might be easier to understand my thinking process. – Johannes_B Jan 22 '15 at 14:12
  • I tweaked a few things and now your solution is just what I needed! If I could I'd buy you a cup of coffee. Thanks! – ClintEastwood Jan 22 '15 at 15:43
  • We could change the title of the original question, cause it was somehow an xy-topic. Maybe something like: »Customize KOMA section headings without titlesec« – Johannes_B Jan 22 '15 at 15:49
  • good idea. I just did. Do you know by any chance why a starred command (such as \section*{Title}) does not create a label to be displayed in the header? – ClintEastwood Jan 22 '15 at 15:57
  • \addsec ;-) and friends – Johannes_B Jan 22 '15 at 15:58
  • but that creates an entry in the ToC... this is why I used the starred command. – ClintEastwood Jan 22 '15 at 15:59
  • 1
    Usually that what users want. Just do \addsecmark{your section title}. Might be worth a new question ;-) – Johannes_B Jan 22 '15 at 16:00
  • No, no, “packages like titlesec or titleps which are meant as enhancement to the generic standard classes” is not exact. They might not work with some classes, indeed, but that doesn't mean these packages should be reserved only for the standard classes. – Javier Bezos Jan 24 '15 at 19:05
  • Hi @JavierBezos, didn't know you are a member here :-) You are right, my statement isn't correct completely. Do you have suggestions how to state it better? ~sec and ~ps provide features for classes that don't come with an own interface? – Johannes_B Jan 24 '15 at 19:39
  • Yes, I am. I'd say just they are not compatible. Another possibility is «KOMA doesn't take account for all the features and special stuff by titleps» ;-). – Javier Bezos Jan 30 '15 at 18:18
  • @JavierBezos Oh, that was an evil mind trick :-) But sure, KOMA isn't really aware of the botmark thing. – Johannes_B Jan 30 '15 at 20:10
  • @Johannes_B I have a problem of making chapter headings span \textwidth, so I would be grateful if you could consider my question. – Diaa Nov 29 '16 at 13:27
  • How do I get document title instead of section on odd page? – Damitr Aug 11 '20 at 19:12
  • @damitr Please ask a new question. – Johannes_B Aug 12 '20 at 02:47