0

I have a 400 page document in Lyx 2.1, book(standard class), using default settings. The \chapter headings appear in all caps in the header, but the \chapter* headings (which I manually add to the TOC and including headings using \markboth) appear as normal italic lowercase. Is there a simple way of making them both the same?

I do know that the fancyhdr (or something similar) package was invented for this purpose, but the book is going for printing tomorrow (large commercial publisher) and I cannot risk any major change as it has already been proof-read. I would like to simple change the few headings that need to be changed without any reformatting.

Many thanks in advance.

10001
  • 1

2 Answers2

1

Here is a solution that will add a running header to all unnumbered chapters, so handle with care. It uses package etoolbox to prepend the markboth command you would do manually. Be careful, this code is bound to fail. Best to set the headers manually.

Just to point that out, the right way to uppercase something is to use \MakeUppercase{<content>}.

Btw: A KOMA-class has it's own commands to take care of things like that. I once summed it up in Correct use of hyperref and addcontentsline. There are other tripwires one can hit.

\documentclass{book}
\usepackage{blindtext}
\usepackage{etoolbox}
\makeatletter
%The following adds a running header for ALL unnumbered chapters
\pretocmd{\@schapter}{%pre
\markboth{\MakeUppercase{#1}}{}%
\typeout{Are your sure you want to mark a head here?}%
}{\typeout{Succes}
}{%Fail
\typeout{FAIL}}
\makeatother
\begin{document}
\tableofcontents
\chapter{a numbered chapter}
\blindtext[10]
\section{a section}
\blindtext[10]
\chapter*{an unnumbered chapter}
\addcontentsline{toc}{chapter}{a unnumbered chapter}
\blindtext[10]
\section{a section}
\blindtext[10]
\chapter*{another unnumbered chapter}
\addcontentsline{toc}{chapter}{another unnumbered chapter}
\blindtext[10]
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
0

Refer pdf doc "Page Layout in Latex" written by Piet van Oostrum. He says if you want get your chapter headings in Uppercases you have to use the following command

\renewcommand{\chaptermark}[1]{%
\markboth{\MakeUppercase{%
\chaptername\ \thechapter.%
\ #1}}{}}

in the preamable after the line \pagestyle{fancy}

Default:
The header text is turned into all uppercase in book.cls

As per Leslie Lamport book style you must have used the following in preamble \renewcommand{\chaptermark}[1]{\markboth{#1}{}} just to eliminate chapter numbers and the uppercaseness. Make it a comment and add the above said command to get the chapter title in capital letters. a

Johannes_B
  • 24,235
  • 10
  • 93
  • 248
murugan
  • 1,669
  • The OP clearly states that fancyhdr isn't used. I think there will be no line \pagestyle{fancy}. – Johannes_B Aug 26 '14 at 06:28
  • Be careful, chaptermark will typeset the number (counter) of \thechapter. Since an unnumbered chapter doesn't have a number (and hence no refstepcounter occurs) the number of the previous Chap will be typeset. This will be confusing. – Johannes_B Aug 26 '14 at 08:34