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 have redefined the chapter command to autolabel all chapters:

\renewcommand\chapter[1]{
  \capitalizewords[q]{#1}
  \noblanks[q]{\thestring}
  \origchapter{#1}\label{chap:\thestring}}

This works great, except I find that it causes a bibliography, created with biblatex and the \bibliography command, to be rendered incorrectly as a chapter rather than as the bibliography. The bibliography title page is messed up (says "Chapter WHATEVERCHAPTERNUMBER: *") and the table of contents lists "*" as a chapter. Otherwise the bibliography is rendered correctly. Anyone know what is causing this? I will be happy with a hacky solution, like an if statement in the renewcommand block that prevents just calls the original chapter command when it's handling the bibliography.

Minimal Working Example

The bibliography is being generated with a template. I have extracted the following code from the template file to create a minimal working example. Compiling the code below won't produce a table of contents, but it does produce the Bibliography as a Chapter named "*":

\documentclass[11pt]{report}
\usepackage{amsmath}
\usepackage{stringstrings}
\usepackage[noadjust,verbose,sort]{cite} %   arranges reference citations neatly

\begin{document}

\newcommand{\ls}[1]
   {\dimen0=\fontdimen6\the\font
    \lineskip=#1\dimen0
    \advance\lineskip.5\fontdimen5\the\font
    \advance\lineskip-\dimen0
    \lineskiplimit=.9\lineskip
    \baselineskip=\lineskip
    \advance\baselineskip\dimen0
    \normallineskip\lineskip
    \normallineskiplimit\lineskiplimit
    \normalbaselineskip\baselineskip
    \ignorespaces
   }

\def\thebibliography#1{
\ls{1}
\chapter*{Bibliography\@mkboth
  {BIBLIOGRAPHY}{BIBLIOGRAPHY}}
  \markright{}
  %\thispagestyle{myheadings} % commented out to force page numbers to bottom center (8/11/07 change by C. St. Jean)
  %\thispagestyle{empty}
  \pagebreak
  \vskip 50pt
  \vspace*{0.61 in}%{0.75in}
  \centerline{\Large \bf Bibliography}\par \nobreak
  %\vskip 40pt
  \vskip 55pt
  \list
  {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \usecounter{enumi}}
    \def\newblock{\hskip .11em plus .33em minus .07em}
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}

\let\origchapter=\chapter
\renewcommand\chapter[1]{
  \capitalizewords[q]{#1}
  \noblanks[q]{\thestring}
  \origchapter{#1}\label{chap:\thestring}}

  % \tableofcontents

  \chapter{The Story of Life}
  Let there be light! \cite{Amaral:2007ua}

  \bibliographystyle{plain}
  \bibliography{testbib}

\end{document}

You'll also need to put this in a bibtex file testbib.bib

@article{Amaral:2007ua,
author = {Amaral, DG and Lavenex, P.},
title = {{Hippocampal neuroanatomy}},
journal = {The Hippocampus Book},
year = {2007},
volume = {1},
number = {3},
pages = {37--114}
}
share|improve this question
    
Which document class do you use? Do you use biblatex or bibtex? The reason I ask is that with biblatex, one would use the command \printbibliography rather than \bibliography to make LaTeX insert the formatted bibliography (including sectioning header). –  Mico Nov 22 '13 at 2:37
    
@Mico I'm using bibtex and a document class of report –  Sean Mackesey Nov 22 '13 at 2:42
    
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Marco Daniel Nov 22 '13 at 8:35
    
@MarcoDaniel MWE added. Thanks for the suggestion and your help! –  Sean Mackesey Nov 22 '13 at 23:24
    
So how do you want the bibliography to be rendered? Like a regular \chapter* (just a chapter heading but no Chapter X title)? –  Werner Nov 22 '13 at 23:43
show 2 more comments

1 Answer 1

up vote 3 down vote accepted

I find that you gain absolutely nothing with automatically generated labels. But the document is yours and, if you find convenient to call

\ref{chap:TheStoryOfLife}

then it's your problem and not mine. ;-)

However, the error is in redefining \chapter, so that it can't recognize the * after it. You have to redefine the internal command \@chapter which is called when no * appears.

Another error is using \@mkboth in a context where @ is not a letter.

\begin{filecontents*}{\jobname.bib}
@article{Amaral:2007ua,
author = {Amaral, DG and Lavenex, P.},
title = {{Hippocampal neuroanatomy}},
journal = {The Hippocampus Book},
year = {2007},
volume = {1},
number = {3},
pages = {37--114}
}
\end{filecontents*}

\documentclass[11pt]{report}
\usepackage{amsmath}
\usepackage{stringstrings}
\usepackage[noadjust,verbose,sort]{cite} %   arranges reference citations neatly

\begin{document}

\newcommand{\ls}[1]
   {\dimen0=\fontdimen6\the\font
    \lineskip=#1\dimen0
    \advance\lineskip.5\fontdimen5\the\font
    \advance\lineskip-\dimen0
    \lineskiplimit=.9\lineskip
    \baselineskip=\lineskip
    \advance\baselineskip\dimen0
    \normallineskip\lineskip
    \normallineskiplimit\lineskiplimit
    \normalbaselineskip\baselineskip
    \ignorespaces
   }

\makeatletter
\def\thebibliography#1{%
  \ls{1}%
  \chapter*{Bibliography\@mkboth{BIBLIOGRAPHY}{BIBLIOGRAPHY}}%
  \pagebreak
  \vskip 50pt
  \vspace*{0.61 in}%{0.75in}%
  \centerline{\Large \bfseries Bibliography}\par \nobreak
  \vskip 55pt
  \list
  {[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
    \advance\leftmargin\labelsep
    \usecounter{enumi}}%
    \def\newblock{\hskip .11em plus .33em minus .07em}%
    \sloppy\clubpenalty4000\widowpenalty4000
    \sfcode`\.=1000\relax}

% redefine \@chapter
\let\orig@chapter=\@chapter
\def\@chapter[#1]#2{%
  \capitalizewords[q]{#2}%
  \noblanks[q]{\thestring}%
  \orig@chapter[#1]{#2}\label{chap:\thestring}%
}
\makeatother

\tableofcontents

\chapter{The Story of Life}
Let there be light! \cite{Amaral:2007ua}

\bibliographystyle{plain}
\bibliography{\jobname}

\end{document}

The filecontents* environment is just to make the example self-contained.

share|improve this answer
add comment

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.