1
\newcommand{\Chapter}[1]{{\let\cleardoublepage\relax\chapter{#1}}}

works fine. How can I do the same for the stared (*) version inside a .cls-file?

(Could be interesting for others: Is there any difference to defining it in the main document?)

  • You are not redefining \chapter, \Chapter is a just wrapper command. Are you sure, that your \cleardoublepage is not \relaxed for ever? Other issue: What about \chapter[short]{long}? – user31729 Sep 21 '14 at 17:21
  • What's your base class? Many classes (report, book, memoir, scrreprt, scrbook know option openany. Then chapters can also start on even pages. This option would make the "chapter" hack of the question obsolete. – Heiko Oberdiek Sep 21 '14 at 17:34
  • @ Heiko: I know. I use scrbook. I want the cleardoublepage normally and want to disable it just once. – PhilippVerpoort Sep 21 '14 at 17:40
  • @ChristianHupfer: At least in my case, the relax works only for that very one chapter. Haven't thought about \chapter[short]{long}, yet. – PhilippVerpoort Sep 21 '14 at 17:43
  • @ChristianHupfer: Sorry, I'm new to StackExchange. I just ticked the accept mark to my other questions. Anything else, I'm doing wrong? I thought, I had read everything. :-/ – PhilippVerpoort Sep 21 '14 at 17:49
3

You have indicated that you wanted to redefine \chapter and \chapter*. For this I suggest to take a look at a deeper level in your class and it's no beginners' task.

You could anyway build a macro which has incorporated a starred version and uses the command \chapter written in your class.

A very basic way goes as follows:

\documentclass{scrbook}

\newcommand{\MyChapter}{%
    \let\cleardoublepage\empty
    \clearpage
    \chapter
}

\begin{document}

\tableofcontents

\MyChapter{Introduction}
some text

\MyChapter[My Introduction]{Introduction}
some text

\MyChapter*{Introduction}
some text

\end{document}

The command \MyChapter erases \cleardoublepage, it executes \clearpage and \chapter. It will have all of your old \chapter's features, because \chapter is executed last and takes as arguments whatever you put after \MyChapter.

However the latter is NOT a good practice, since command \cleardoublepage is rendered useless, and erasing latex commands can often cause bad functioning.

IMHO a "decent" practice could be saving \cleardoublepage and restoring it later:

\documentclass{scrbook}

\newcommand{\ResCdp}{%
    \let\cleardoublepage\cdp
}

\newcommand{\MyChapter}{%
    \let\cdp\cleardoublepage
    \let\cleardoublepage\empty
    \clearpage
    \chapter
}

\begin{document}

\tableofcontents

\MyChapter{Introduction}\ResCdp
some text

\MyChapter[My Introduction]{Introduction}\ResCdp
some text

\cleardoublepage

\MyChapter*{Introduction}\ResCdp
some text

\end{document}

which is somewhat difficult to read/write but does the trick safely.

To avoid using this \ResCdp without erasing \cleardoublepage and keeping all \chapter's features would take many more efforts.

  • That's, I think, a good solution. Still, not perfect, as you would have to invoke the \ResCdp manually after each use of \MyChapter and it would of course be very comfortable to include this into the new command, but this seems to be very difficult. I'll accept this as an answer to my question. – PhilippVerpoort Nov 8 '14 at 14:32
  • The most difficult part is that \chapter uses a lot of different commands written in the class to achieve scrbook's goals.As a fact, each command is often used inside of others, and usually we cannot change one of them without affecting the rest of them. I never took a look inside scrbook.cls nor used it, but for instance with the book class you can achieve your goal redefining a sub command named \@chapter, which is not available at user level (as implied by the use of @ in the command sequence name). Doing this is no big deal. Big deal is knowledge and training. So keep it up! :) – RicoRally Nov 8 '14 at 15:57
2

You have indicated that you use the scrbook document class. If you want to redefine \chapter (and \chapter*) to execute \clearpage instead of \cleardoublepage, I suggest you load the etoolbox package and use its \patchcmd macro to modify the chapter macro:

\usepackage{etoolbox}
\patchcmd{\chapter}{\cleardoublepage}{\clearpage}{}{}
  • I tried this a lot of time -- it will fail, as far as I know, due the special way this kind of commands are defined – user31729 Sep 21 '14 at 17:42
  • Sorry, maybe I'm getting it wrong, but... even if it were working, wouldn't that add \cleardoublepage rather than remove it? – PhilippVerpoort Sep 21 '14 at 17:53
  • @ChristianHupfer - Thanks for this. I've updated the answer. The code works with the book and scrbook classes. – Mico Sep 21 '14 at 17:53
  • 1
    @Mico: Well, thanks... that unknown guy "H." will add some bon mots, the new term has just started ;-) – user31729 Sep 21 '14 at 17:58
  • 1
    @doublerainbow64 - The patch works for both starred and unstarred chapters. By the way, I doubt it's a good idea to have some chapters perform \clearpage while others perform \cleardoublepage -- choose one or the other for your document. – Mico Sep 21 '14 at 18:20
0

In case of scrbook use option openany and insert \cleardoublepages manually.

It's not exactly the answer to the question, still, I decided to use this method.

  • 1
    The question is not well posed; if your aim is opening chapter on either even or odd pages, the correct method is issuing the openany option. – egreg Sep 21 '14 at 21:01
  • My intention was to somehow define new commands, one including the \cleardoublepage and one using \clearpage only. It does not really matter, whether you create a new command to omit the \cleardoublepage or use option openany and create a new command using an additional \cleardoublepage. The question was about how to define the stared version of \chapter. Since the insert of a \cleardoublepage is certainly not as disturbing as the \let...\relax command, I decided that I can live without a macro for this. However, the question about how to define one remains unanswered to me. – PhilippVerpoort Sep 22 '14 at 9:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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