Annoying problem with fancyhdr and auto-generated chapters

I have been facing an annoying little problem. I'm using `fancyhdr` to customize the headings on my thesis but according to the package documentation it is unable to remove the "uppercasedness" of the headings on chapters like Bibliography, Index and so on, because `\MakeUppercase` is explicitly given independently by those packages. It suggests redefining `\thebibliography` and searching `natbib.sty` I found

``````\providecommand{\MakeUppercase}{\uppercase}
``````

followed by its usage inside the `\bibsection` redefinition.

I have tried playing around with that for a while, trying to redefine `\bibsection` in my preamble, but that only ended up messing the Bibliography's title.

Moreover, this is not just about the Bibliography: other non-numbered chapters (all of them, actually) suffer from this.

For the problem at hand I came up with a kind of solution, which is to redefine \MakeUppercase:

``````\renewcommand{\MakeUppercase}{}
``````

That solves my immediate problem. But I'm not comfortable with that, because I might need to use uppercase letters in this or in any other document. Since I always use lowercase in the headings, this might be an issue.

What would a better solution do? Would I need to actually redefine commands related to each aspect, Bibliography, Index, Table of Contents, and so on?

-
By "what if I need to use that command elsewhere in the document?", do you mean for manual use, or automated use? There may be ways around this if you can provide a complete minimal working example (MWE). –  Werner Dec 6 '12 at 4:29
My version of `natbib.sty` uses `\MakeUppercase` more than once in the definitions of `\bibsection` which is used for the heading. And redefining `\bibsection` is imho the easiest to get rid of the `\MakeUppercase` in the header. –  Ulrike Fischer Dec 6 '12 at 8:55
@Werner, this is a hypothetical question, because I don't want to get rid of a command just because it is being used somewhere I don't want it to. This is not a problem that needs solving, mind you, it is a question about how this should be done, especially in automated use. –  Francisco Dec 6 '12 at 10:42
@Ulrike, after posting I did find its use in natbib.sty. In fact I played around a bit with the definition of `\bibsection` but to be honest I didn't try very hard. Also, this problem is not really only about the bibliography; other non-numbered chapters would still be problematic even if I corrected natbib's definition. –  Francisco Dec 6 '12 at 10:44
Use a better class. This should get rid of many of the uppercase problems. –  Ulrike Fischer Dec 6 '12 at 10:57

The command `\MakeUppercase` is a standard command of LaTeX, defined in the kernel and thus the `\providecommand` here is never executed as the command is already there. I can't remember if we added `\MakeUppercase` after the initial release of LaTeX2e in 1994; it is quite likely and if so that may explain why at one time such a `\providecommand` made sense.

Being a general purpose command disabling it is not the correct choice (other than in an emergency) as it means to that any uppercasing in each and every place is being disabled and that may result not just in the desired effect to get rid of it in the running headers but also in places where uppercasing would still be justified.

A better solution would therefore, as Ulrike remarked, to use a class that doesn't do thing uppercasing or supports customising it. The hardwired use of `\MakeUppercase` in the classes shipped with LaTeX is unfortunate, but for compatibility reasons we made decision long ago (see ltnewsXX.pdf can't remember the number) that these classes aren't being changed because of questionable designs or missing features. Instead better and more flexible classes should be provided as alternatives. Such classes exist, e.g., the KomaScript classes such as `scrreprt.cls` and many others.

If you are set on disabling `\Makeuppercase` then you should do it slightly differently:

``````\renewcommand\Makeuppercase[1]{#1}
``````

Reason for using an argument is that without it the argument braces that are typically around its argument will survive and result in a group that delimit the scope and that may (unlikely but possible) have side effects.

-
My opinion is that it was wrong to inflict `\MakeUppercase` to all users of the standard classes. The "dreaded" `\MakeUppercase` found its way in a good number of packages that wanted to be compatible with the standard classes; `natbib` is one of them. –  egreg Apr 12 '13 at 12:59
@egreg yes it was. It is a horrible design. But 2e was successful because we manged to be backward compatible to 2.09 and even today it is possible to format documents from the late '80 with some exceptions. But the mistake we made back then was not to modularize the standard classes back then and from day one support a proper customization layer. What I'm saying above is that for those classes and 2e this is now too late to do introduce this. –  Frank Mittelbach Apr 12 '13 at 13:23
Hardwiring formatting instructions in `\markboth`, `\markright` or `\@mkboth` is usually disputable. Alas, font families don't provide an "all caps" font which would solve many problems. –  egreg Apr 12 '13 at 13:29
@egreg yes, agreed too. As to all caps: back in the days we decided against adding a "case axis to NFSS" as it would have resulted in a huge mess because of missing fonts and would have blown the limited memory back then as well, but in theory this is what is missing and small caps shouldn't be a shape on the same level as italic. –  Frank Mittelbach Apr 12 '13 at 13:34

In this answer I am going to give the steps to redefine commands like `\thebibliography` or `\tableofcontents` in order to remove the uppercased headings. I believe this is the best possible solution if you don't want to change classes.

These commands are defined for each class. For example, in the `book.cls` file from the base package, the definition for the `\tableofcontents` command is give by

``````\newcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{%
\MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
``````

If I want to have lowercase headings for a Table of Contents in the standard book class, I just need to redefine this command on the preamble of my book, removing the `\MakeUppercase` from the marks:

``````\makeatletter
\renewcommand\tableofcontents{%
\if@twocolumn
\@restonecoltrue\onecolumn
\else
\@restonecolfalse
\fi
\chapter*{\contentsname
\@mkboth{%
\contentsname}{\contentsname}}%
\@starttoc{toc}%
\if@restonecol\twocolumn\fi
}
\makeatother
``````

And that's it. I used the table of contents because the code is shorter, but this also works for other classes and similar unnumbered chapters/sections like the bibliography, list of tables or list of figures. To avoid cluttering the preamble, you can put all the new definitions on a `.sty`.

-