1

I have a strange problem with fancyhdr and report (KOMA) together with child documents. Individually for each child document, the headers are like I want them to be, but when I compile them all through my master document, all headers are lost and I am left with the default style (empty header, page number in footer)

I have checked that all options are identical for all children and the master.

I am using Lyx 2.0.5 and the document class is 'report (KOMA)' for all children and the master.

EDIT: Just tried to compile it using the standard 'report' document class and now it worked. This must mean that the problem is related to the KOMA script.

This is my preamble

\usepackage[small,bf,margin=10pt]{caption}
\usepackage[dutch,british]{babel}
\usepackage{graphicx}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage{fancyhdr}

\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}}
\fancyhead[LO]{\rightmark}

\renewcommand{\chaptermark}[1]{\markboth{\thechapter.\ #1}{}}
\fancyhead[RE]{\bfseries \leftmark}

\fancyhead[RO,LE]{\bfseries \thepage}
\renewcommand{\headrulewidth}{0.4pt}

As mentioned, it works fine for the individual documents, but not for the master.

Does anyone know what could be the problem?

  • KOMA works well with scrpage2. I recommend to use it instead of fancyhdr. – Marco Daniel Jun 24 '13 at 18:52
1

I found the cause of the problem.

The first child document was a document containing front matter. For that reason I had set \pagestyle{plain} to avoid headers and footers on the first pages with Table of Contents, preface, abstract etc.

I was not aware that this command is not for a single page only, but for the rest of the document or until a new command is given. On the first page after the front matter I then set \pagestyle{fancy} to include fancyhdr headers and footers and everything worked fine.

This was of course the reason why it worked with the child documents individually - there was no pagestyle change.

|improve this answer|||||
  • To change the behaviour of a single page you have to use \thispagestyle. See this answer of mine. – karlkoeller Jun 24 '13 at 18:55
  • Good point, forgot that. In my case, however, I needed to change the behaviour of several pages (all of the front matter), so it's probably easier with the two \pagestyle{} – Kaspar H Aug 4 '13 at 14:33

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.