I need to include a bunch of PDFs as files after and before other regular chapters. I want each PDF to be a numbered chapter, be included in the toc, and to appear in the header-line (of fancyhdr), but not the actual 'Chapter X. A fancy chapter' to be printed, since that would print the 'Chapter X', then a blank page, then the pdfs.
All of this works fine with a solution I found on another question ( Start a new chapter without heading )
\documentclass{scrbook} %report}
\usepackage{hyperref}
\makeatletter
\newcommand{\unchapter}[1]{%
\begingroup
\let\@makechapterhead\@gobble % make \@makechapterhead do nothing
\chapter{#1}
\endgroup
}
\makeatother
\pagestyle{headings}
\begin{document}
\tableofcontents
\chapter{Regular}\label{sec:regular}
\section{Something}\label{sec:something}
Text
\unchapter{No chapter head}\label{sec:nohead}
Text\newpage
text: check the heading
\chapter{This is regular again}\label{sec:head}
References: \\
Regular: \ref{sec:regular}\\
Something: \ref{sec:something}\\
No chapter head: \ref{sec:nohead}\\
Regular again: \ref{sec:head}
\end{document}
However, I face a problem when I want to refer to the chapter, since that then refers to the last (sub-)section. I.e. the example references of the last chapter look like this:
References:
Regular: 1
Something: 1.1
No chapter head: 1.1
Regular again: 3
The links also lead to section 1.1. So I assume makechapterhead is somehow necessary for the references to work, but I couldn't find what it does.
I did find \refstepcounter{chapter}, but that only increments Regular again: 3
to 4, so it seems the counter is correctly incremented by the \unchapter, but the reference just doesn't know there was a change?
I also tried sprinkling some clearpage, new page, chaptermark, all over it to no avail.