1

I'm trying to figure out how to make the usebib package case-insensitive on the keys in my .bib file. I've figured out how to patch \KV@split to patch \KV@@sp@def when \setkeys is defined by keyval rather than 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.}
}%

So, for example, this works and produces Foo as expected:

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

However, if I load xkeyval at the beginning, then I get Package usebib Error: Undefined key `foo' or empty value for `author'. because xkeyval does not use \KV@split. How do I make this work even when using xkeyval? (And/or is there a better way to do this?)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.