4

Using fancyhdr to format my headers, I want them to display the current chapter name in small caps. So with no surprise I’ve ended up doing something like this:

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} % Clears the standard fancy style header
\fancyhead[CO]{\textsc{\nouppercase{\leftmark}}} % Displays current chapter name in small-caps on odd-numbered pages

Which of course works quite well, but the point is that I want no standard uppercase at all in the headers: in other words, I want a chapter called “The Chapter ABC” to be treated as “the chapter abc” during the small-caps-isation process. Is there any way to achieve this? I tried different solutions with things such as \MakeLowercase or \MakeTextLowercase, but they all appear ineffective within \fancyhead{}.

I’m obviously looking for a solution easier and more “automatic” than the one consisting in manually renaming the header with \fancyhead{} after each \chapter{}, which is the one I’m currently using...

Thanks a lot to everyone willing to help me!

  • Can you add some details about the document class you're using? – egreg Oct 12 '16 at 14:34
  • what you are asking for is a contradiction. "small caps" by definition have the shape of uppercase letters. what you really want (as indicated by your example) is all lowercase. if you would extend your code to be a full compilable example, beginning with \documentclass and ending with \end{document}, i'm sure someone here can provide a suitable answer. in the meantime, get rid of the \textsc; it is only doing something that you don't want. – barbara beeton Oct 12 '16 at 14:34
  • @barbarabeeton I suspect what OP means is to force the original case to lowercase before rendering as SC. Something like memoirs \chapterstyle{bringhurst} – Brent.Longborough Oct 12 '16 at 15:11
  • 1
    @Brent.Longborough -- yes, it's pretty obvious that is what the op means. what's really the point here is understanding of the vocabulary, which is faulty. – barbara beeton Oct 12 '16 at 15:14
2

Redefine \chaptermark to avoid \MakeUppercase; I also instruct to use \footnotesize for the number, or it would appear too big.

\documentclass{book}
\usepackage{fancyhdr}
\usepackage{lipsum} % just for the example

\pagestyle{fancy}
\fancyhead{} % Clears the standard fancy style
\fancyhead[CO]{\scshape\MakeLowercase{\leftmark}}

\makeatletter
\renewcommand{\chaptermark}[1]{%
  \markboth{%
    \ifnum\c@secnumdepth>\m@ne
      \@chapapp\ {\footnotesize\thechapter}. \ %
    \fi
  #1%
  }{}%
}
\makeatother

\begin{document}

\chapter{This title has Upper Case Letters}

\lipsum[1-30]

\end{document}

enter image description here

2

Update \chaptermark; here's the default definition (from report.cls, but it would be similar in book.cls):

\def\chaptermark#1{%
  \markboth {\MakeUppercase{%
    \ifnum \c@secnumdepth >\m@ne
        \@chapapp\ \thechapter. \ %
    \fi
    #1}}{}}%

We update it to use \scshape and \MakeLowercase directly:

\renewcommand{\chaptermark}[1]{\markboth{\scshape\MakeLowercase{%
  \ifnum\c@secnumdepth > \m@ne \@chapapp\ \thechapter.\ \fi #1}}{}}

Here is a complete minimal example:

enter image description here

\documentclass{report}

\usepackage{fancyhdr,graphicx}
\pagestyle{fancy}
\fancyhead{} % Clears the standard fancy style header
\makeatletter
\fancyhead[CO]{\leftmark} % Displays current chapter name in small-caps on odd-numbered pages
\renewcommand{\chaptermark}[1]{\markboth{\scshape\MakeLowercase{%
  \ifnum\c@secnumdepth > \m@ne \@chapapp\ \protect\resizebox{!}{1.15ex}{\thechapter}.\ \fi #1}}{}}
\makeatother

\usepackage{lipsum}% Just for this example

\begin{document}

\setcounter{chapter}{16}% Just for this example
\chapter{A Chapter}

\lipsum

\end{document}

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.