\cite{} 作为章节标题的名称

\cite{} 作为章节标题的名称

我正在写一个文档,其中每个章节都是一篇论文的阅读记录。所以我想将章节名称作为论文的标题,将章节标题作为书目参考的简短引用。

以下是我目前所做的:

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

但如您所见,标题打印的是 bib key,而不是真正的简短引文。有没有办法打印Greenwade, 1993,而不是greenwade93

答案1

@moewe 已经解释了为什么会发生这种情况。一个无软件包的解决方案(好吧,几乎无软件包)是\MakeUppercase从定义中删除\chaptermark(我坚持认为这从一开始就是一个设计错误):

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

使用\patchcmd比做更容易

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

我从中复制了定义book.cls并删除了可怕的\MakeUppercase

答案2

更新

如果您正在使用当前版本的 LaTeX 内核,则大小写更改代码将自动保持\cite不变。

\documentclass{book}

\begin{filecontents}{\jobname.bib}
@ARTICLE{greenwade93,
  author  = "George Greenwade",
  title   = "The {Comprehensive} {TeX} {Archive} {Network} ({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}

如果你正在使用大小写转换器无法处理的命令(例如\autocite\textcite),你可以使用

\AddToNoCaseChangeList{\autocite \textcite}

旧答案

您遇到的问题是因为 的可选参数\chapter被传递给\MakeUppercase。这将导致\cite{greenwade93}命令显示为\cite{GREENWADE93},但当然biblatex找不到该引用键的条目。

TeX 常见问题列表:大小写转换奇怪现象实际上描述了针对这种情况的几种补救措施。

您可以定义一个辅助命令\citegreen

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

\protect调用\citegreen\chapter

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

或者,\citegreen可以通过定义变得健壮

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

无需辅助宏的解决方案是使用 David Carlisle 的textcase带有选项的包overload。这将\MakeUppercase被一个稍微复杂一些的\MakeTextUppercase宏所取代,该宏可以按预期处理上述命令。

加载包

\usepackage[overload]{textcase}

你可以使用

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

然后。

平均能量损失

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

答案3

我不知道为什么,但是如果你只在 refname 中使用大写字母,它就可以起作用:

@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"
}

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

我找到了它,因为我的日志告诉我:

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.

相关内容