# A \cite{} as name for a chapter header

I'm writing a document where each chapter is a reading record of a paper. So I want the name of the chapter to be the title of the paper, and the header of the chapter to be the short citation of the bib reference.

Here is what I've done so far :

\documentclass{book}
\usepackage{filecontents}
\usepackage{lipsum}

\begin{filecontents}{ECM.bib}
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1993",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
\end{filecontents}

\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{french}{french-apa}

\usepackage{forest, philex}

\begin{document}
\lipsum

\end{document}


But as you can see, the header prints the bib key instead of the real short citation. Is there a way to print Greenwade, 1993, instead of greenwade93?

-
Just an idea: is it possible to "memorise" the result of the \cite{} inside a string variable? –  BonyHoax Apr 11 at 12:03
The problem is that the optional argument to \chapter (the one in square brackets) is uppercased, that leads to the argument to the cite command also being uppercased and subsequently biblatex trying to find the entry key "GREENWADE93" (all uppercase letter). –  moewe Apr 11 at 14:55
A work-around would be \newcommand{\citegreen}{\cite{greenwade93}} and then \chapter[\protect\citegreen]{\citetitle{greenwade93}} or \DeclareRobustCommand{\citegreen}{\cite{greenwade93}} and \chapter[\citegreen]{\citetitle{greenwade93}} as per UK TeX FAQ: Case-changing oddities. –  moewe Apr 11 at 18:21

@moewe has already explained why this happens. A package free solution (well, almost package free) is to remove \MakeUppercase from the definition of \chaptermark (which I insist was a design error to begin with):

\documentclass{book}
\usepackage{filecontents}
\usepackage{lipsum}

\begin{filecontents}{\jobname.bib}
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1993",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
\end{filecontents}

\usepackage[style=apa,backend=biber]{biblatex}
\DeclareLanguageMapping{french}{french-apa}

\usepackage{forest, philex,etoolbox}
\makeatletter
\patchcmd{\chaptermark}{\MakeUppercase}{\@firstofone}{}{}
\makeatother

\begin{document}
\lipsum

\end{document}


Using \patchcmd is easier than doing

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


where I copied the definition from book.cls and removed the dreaded \MakeUppercase.

-

The problem you experience is because the optional argument to \chapter is passed to \MakeUppercase. That will cause the \cite{greenwade93} command to come out as \cite{GREENWADE93}, but of course biblatex cannot find the entry to that cite key.

The UK List of TeX FAQs: Case-changing oddities actually describes several remedies for that situation.

You could define a helper command \citegreen

\newcommand{\citegreen}{\cite{greenwade93}}


And \protect the call to \citegreen in \chapter

\chapter[\protect\citegreen]{\citetitle{greenwade93}}


Alternatively, \citegreen can be made robust by definition

\DeclareRobustCommand{\citegreen}{\cite{greenwade93}}


A solution without a helper macro is to use David Carlisle's textcase package with the overload option. This will replace \MakeUppercase by a slightly more sophisticated \MakeTextUppercase macro that deals with the commands above as expected.

\usepackage[overload]{textcase}


You can just use

\chapter[\cite{greenwade93}]{\citetitle{greenwade93}}


then.

MWE

\documentclass{book}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1993",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}
\end{filecontents}

\usepackage[style=apa,backend=biber]{biblatex}
\begin{document}
Lorem
\newpage
Ipsum
\end{document}

-

I don't know why, but if you use uppercase only in the refname, it works:

@ARTICLE{GREENWADE93,
title   = "The {C}omprehensive {T}ex {A}rchive {N}etwork ({CTAN})",
year    = "1993",
journal = "TUGBoat",
volume  = "14",
number  = "3",
pages   = "342--351"
}


and

\chapter[\cite{GREENWADE93}]{\citetitle{GREENWADE93}}


I found it, because my log gives me:

Package biblatex Warning: The following entry could not be found
(biblatex)                in the database:

If you have a "static" bib-file it's a very easy regex. In case you can need it: You can search for pattern (^@.*?\{)(.*?,) and replace it with \1\U\2 –  musicman Apr 11 at 11:29