I have a document (scrbook
class), in which I want some chapters not to start on a new page. I therefore defined the following:
%define a chapter that does not add space at the top of the page
\usepackage{etoolbox}
\makeatletter
\let\chapterNoSpace\chapter
\patchcmd\chapterNoSpace{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
\patchcmd{\chapterNoSpace}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}
\makeatother
This does nearly what I want. However, there are three problems:
I need to add a new paragraph before any
\chapterNoSpace
command, or it will put the chapter directly on the same line as the last text.On the page where the chapter starts, I am missing my headers.
If the command coincides with a new page, the headers are missing on the page before and there is a spurious
\vskip
before the heading, which looks odd.
I added a minimal script below.
\documentclass[11pt, a4paper, twoside, openany]{scrbook}
%headers
\usepackage{fancyhdr}\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\thepart.\ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\thepart.\thechapter.\ #1}}
\fancyhf{}
\fancyhead[LE,RO]{\thepage}
\fancyhead[LO]{\rightmark}
\fancyhead[RE]{\leftmark}
\fancypagestyle{plain}{\fancyhead{}\renewcommand{\headrulewidth}{0pt}}
%Define a chapter that doesn't start on new page
\usepackage{etoolbox}
\makeatletter
\let\chapterNoSpace\chapter
\patchcmd\chapterNoSpace{\if@openright\cleardoublepage\else\clearpage\fi}{}{}{}
%\renewcommand*{\chapterheadstartvskip}{\vspace*{1cm}}
%\patchcmd\chapterNoSpace{\chapterheadstartvskip}{\vspace{1cm}}{}{}
\patchcmd{\chapterNoSpace}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{}
\makeatother
\begin{document}
\part{Part 1}
\chapter{Normal chapter 1}
text text text text text text
\chapter{Normal chapter 2}
text text text text text
\chapterNoSpace{Chapter on same page 1}
text text text
\chapterNoSpace{Chapter on same page 2 with line brake above}
text text text
\chapter{Normal chapter 3}
text text text
\end{document}
Any suggestions?
\documentclass
to\end{document}
– egreg Jun 4 '14 at 8:58\documentclass[openany]{scrbook}
should also do, without redefinition of\chapter
, however, for all chapters then... – user31729 Jun 4 '14 at 9:49