Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
@ARTICLE{greenwade93,
  author  = "George Greenwade",
  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}
\addbibresource{ECM.bib}

\usepackage{forest, philex}

\begin{document}
\chapter[\cite{greenwade93}]{\citetitle{greenwade93}}
\sectionmark{version for header}
\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?

share|improve this question
    
Just an idea: is it possible to "memorise" the result of the \cite{} inside a string variable? –  BonyHoax Apr 11 at 12:03
2  
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

3 Answers 3

up vote 5 down vote accepted

@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}
@ARTICLE{greenwade93,
  author  = "George Greenwade",
  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}
\addbibresource{\jobname.bib}

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

\begin{document}
\chapter[\cite{greenwade93}]{\citetitle{greenwade93}}
\sectionmark{version for header}
\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.

share|improve this answer

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}}
\chapter[\citegreen]{\citetitle{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.

Load the package

\usepackage[overload]{textcase}

You can just use

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

then.

MWE

\documentclass{book}
\usepackage{filecontents}
\usepackage[overload]{textcase}
\begin{filecontents}{\jobname.bib}
@ARTICLE{greenwade93,
  author  = "George Greenwade",
  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}
\addbibresource{\jobname.bib}
\begin{document}
  \chapter[\cite{greenwade93}]{\citetitle{greenwade93}}
  Lorem
  \newpage
  Ipsum
\end{document}
share|improve this answer

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

@ARTICLE{GREENWADE93,
  author  = "George Greenwade",
  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:
(biblatex)                GREENWADE93
(biblatex)                Please verify the spelling and rerun
(biblatex)                LaTeX afterwards.
share|improve this answer
    
Yes, you're right, it also works for me. But for other reasons, I can't change the whole list of entries of my bibliography database. So I can't really use this trick :/ –  BonyHoax Apr 11 at 11:23
    
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
    
I'm not sure I understand what you mean. I don't know what you mean by "static" bib-file (like I always use the same file, which is not modified?), and I don't know what a regex is. And your pattern symbols are chinese for me :) –  BonyHoax Apr 11 at 11:40
    
With "static" I mean you're working on your bibfile per hand and it doesn't get created dynamically by a program etc. Then you can use regex as a workaround (- so this is no latex solution). With using the patterns I wrote you can easily make all your refnames uppercase. Look for a text editor which features Regex, like Notepad++. The rest the internet will tell you. –  musicman Apr 11 at 11:52
    
Oh ok. So no, I don't have a static bib-file. I'm not sure yet if it's the final version, so I can modify it by hand. So your solution may be useful. But I would prefer not to have to modify it, in case I have to generate it again. –  BonyHoax Apr 11 at 12:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.