我正在尝试弄清楚如何使 usebib 包在我的 .bib 文件中的键上不区分大小写。我已经弄清楚了当定义为而不是时如何进行\KV@split
修补:\KV@@sp@def
\setkeys
keyval
xkeyval
\let\KV@@sp@def@orig=\KV@@sp@def
\def\KV@@casenormalize{%
\long\def\KV@@sp@def##1##2{\lowercase{\KV@@sp@def@orig{##1}{##2}}\let\KV@@sp@def=\KV@@sp@def@orig}%
}
\pretocmd{\KV@split}{\KV@@casenormalize}{}{%
\PackageWarning{usebib}
{Unpatchable command \string\KV@split. Fields will be case-sensitive.}
{The version of the keyval package does not have a definition of \string\KV@split\space that is compatible with patching for case normalization.}
}%
例如,它可以正常工作并产生Foo
预期的结果:
\documentclass{article}
\usepackage{usebib}
\newbibfield{author}
\usepackage{etoolbox}
\usepackage{filecontents}
\begin{filecontents}{foo.bib}
@misc{foo,
Author = {Foo}
}
\end{filecontents}
\makeatletter
\let\KV@@sp@def@orig=\KV@@sp@def
\def\KV@@casenormalize{%
\long\def\KV@@sp@def##1##2{\lowercase{\KV@@sp@def@orig{##1}{##2}}\let\KV@@sp@def=\KV@@sp@def@orig}%
}
\pretocmd{\KV@split}{\KV@@casenormalize}{}{%
\PackageWarning{usebib}
{Unpatchable command \string\KV@split. Fields will be case-sensitive.}
{The version of the keyval package does not have a definition of \string\KV@split\space that is compatible with patching for case normalization.}
}%
\makeatother
\bibinput{foo}
\begin{document}
\usebibentry{foo}{author}
\end{document}
但是,如果我xkeyval
在开始时加载,那么我会得到Package usebib Error: Undefined key `foo' or empty value for `author'.
因为xkeyval
不使用\KV@split
。即使在使用时,我如何使其工作xkeyval
?(和/或有更好的方法来做到这一点?)