改变章节命令会导致参考书目被视为章节

改变章节命令会导致参考书目被视为章节

我已经重新定义了章节命令来自动标记所有章节:

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

这很好,但我发现它会导致使用创建的参考书目比布拉特克斯\bibliography命令,被错误地渲染为章节而不是参考书目。参考书目标题页乱七八糟(显示“章节 WHATEVERCHAPTERNUMBER: *”),目录将“*”列为章节。否则,参考书目会正确呈现。有人知道是什么原因造成的吗?我会对一个 hacky 解决方案感到满意,比如块中的 if 语句,renewcommand它可以防止在处理参考书目时只调用原始章节命令。

最小工作示例

参考书目是通过模板生成的。我从模板文件中提取了以下代码来创建一个最小的工作示例。编译以下代码不会生成目录,但会生成名为“*”的章节形式的参考书目:

\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}

您还需要将其放入 bibtex 文件中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}
}

答案1

我发现自动生成的标签绝对不会给你带来任何好处。但文档是你的,如果你觉得方便的话,可以调用

\ref{chap:TheStoryOfLife}

那么这是你的问题,不是我的问题。;-)

但是错误在于重新定义\chapter,因此无法识别*其后的 。您必须重新定义\@chapter当没有 * 出现时调用的内部命令。

另一个错误是在不是字母\@mkboth的上下文中使用。@

\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}

filecontents*环境只是为了使示例自成一体。

相关内容