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

Answer by esdd for chapter no newpage and headings

$
0
0

Update: Maybe better with KOMA-Script version 3.16

\documentclass[open=any]{scrbook}%headers\usepackage[automark,headsepline]{scrlayer-scrpage}\clearpairofpagestyles\ohead*{\pagemark}\ihead{\headmark}\addtokomafont{pagehead}{\normalfont}%Define a chapter that doesn't start on new page\usepackage{etoolbox}\makeatletter\let\chapterNoSpace\chapter \patchcmd\chapterNoSpace{\if@openright\cleardoublepage\else\clearpage\fi}{\par\vspace{\baselineskip}}{}{}\patchcmd{\chapterNoSpace}{\thispagestyle{\chapterpagestyle}}{}{}{}\makeatother\RedeclareSectionCommand[beforeskip=0pt]{chapter}\usepackage{blindtext}% dummy text\usepackage{showframe}% to show the page layout\begin{document}\part{Part 1}\chapter{Normal chapter 1}\blindtext[20]\chapter{Normal chapter 2}text\chapterNoSpace{Chapter on same page 1}\Blindtext[3]\chapterNoSpace{Chapter on same page 2 with line brake above}\blindtext\chapter{Normal chapter 3}\blindtext\blinddocument\end{document}

enter image description here


Old answer: Changing your patch to

\patchcmd\chapterNoSpace{\if@openright\cleardoublepage\else\clearpage\fi}{\par}{}{}\patchcmd{\chapterNoSpace}{\thispagestyle{\chapterpagestyle}}{\thispagestyle{fancy}}{}{}

will solve 1. und 2.

If you want that all chapters adding less space as normal at the top of the page you can use

\renewcommand*\chapterheadstartvskip{\vspace*{0pt}}

Code:

\documentclass[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}{\par}{}{}\patchcmd{\chapterNoSpace}{\thispagestyle{\chapterpagestyle}}{\thispagestyle{fancy}}{}{}%\renewcommand*\chapterheadstartvskip{\vspace*{0pt}}\makeatother\usepackage{blindtext}% dummy text\begin{document}\part{Part 1}\chapter{Normal chapter 1}\blindtext[20]\chapter{Normal chapter 2}text\chapterNoSpace{Chapter on same page 1}\Blindtext[3]\chapterNoSpace{Chapter on same page 2 with line brake above}\blindtext\chapter{Normal chapter 3}\blindtext\blinddocument\end{document}

Note that it is not recommanded to use fancyhdr together with KOMA-Script classes. Try scrlayer-scrpage instead.


Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>