Quantcast
Channel: chapter no newpage and headings - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

chapter no newpage and headings

$
0
0

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:

  1. 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.

  2. On the page where the chapter starts, I am missing my headers.

  3. 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?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles



Latest Images