我正在写一个文档,其中每个章节都是一篇论文的阅读记录。所以我想将章节名称作为论文的标题,将章节标题作为书目参考的简短引用。
以下是我目前所做的:
\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.