[Tex/LaTex] harvard citation management package: How to uppercase the authors in the citation call-out

bibtexcapitalizationcitingharvard-style

I have been using the harvard citation management package with the following configuration:

\usepackage{harvard}
\citationmode{abbr} \citationstyle{dcu}
\bibliographystyle{dcu}

Database:

@BOOK{Campbell(1996),
  AUTHOR =       {J. Y. Campbell and A. W. Lo and A. C. MacKinlay},
  TITLE =        {The econometrics of financial markets},
  PUBLISHER =    {Princeton University Press},
  YEAR =         {1996},
  address =      {},
}

@BOOK{Hamilton(1994),
    AUTHOR =    {J. D. Hamilton},
    TITLE = {Time series analysis},
    PUBLISHER = {Princenton University Press},
    YEAR =  {1994},
    address =   {},
}

I have been trying without success to uppercase the authors' names in the citation callouts (I mean all the letters, not only the first) in the text. Is there any automatic way to do that?

Today, when I use \citeasnoun{Campbell(1996)}, I will get Campbell et al. (1996). On the other hand, when I use \cite{Hamilton(1994), I will get (Hamilton, 1994).

I want when I use \citeasnoun{Campbell(1996)}, I will get CAMPBELL et al. (1996). On the other hand, when I use \cite{Hamilton(1994), I will get (HAMILTON, 1994).

Best Answer

So long as you don't have special characters such as \ss or \i in the author names, this should work without requiring changing .bst files.

\begin{filecontents*}{\jobname.bib}
@BOOK{Campbell(1996),
  AUTHOR    = {J. Y. Campbell and A. W. Lo and A. C. MacKinlay},
  TITLE     = {The econometrics of financial markets},
  PUBLISHER = {Princeton University Press},
  YEAR      = {1996},
}
@BOOK{Hamilton(1994),
  AUTHOR    = {J. D. Hamilton},
  TITLE     = {Time series analysis},
  PUBLISHER = {Princeton University Press},
  YEAR      = {1994},
}
@BOOK{U+R,
  AUTHOR    = {A. Uthor and W. Riter},
  TITLE     = {All about everything},
  PUBLISHER = {Best Company},
  YEAR      = {2015},
}
\end{filecontents*}

\documentclass{article}
\usepackage{harvard}

\usepackage{xpatch}
\xpatchcmd{\harvarditem}{\immediate}{\nextify\immediate}{}{}
\makeatletter
\def\nextify{\expandafter\n@xtify\next}
\def\n@xtify#1#2#3#4{%
  \def\n@xtify@i{#1}%
  \def\n@xtify@ii{#2}%
  \def\n@xtify@iv{#4}%
  \n@xtify@etal#3 et~al.\n@xtify@etal
  \let\next\@empty
  \xappto\next{%
    {\expandonce{\n@xtify@i}}%
    {\expandonce{\n@xtify@ii}}%
    {\expandonce{\n@xtify@iii}}%
    {\expandonce{\n@xtify@iv}}%
  }%
}
\def\n@xtify@etal#1 et~al.#2\n@xtify@etal{%
  \if\relax\detokenize{#2}\relax
    \uppercase{\def\n@xtify@iii{#1}}%
  \else
    \uppercase{\def\n@xtify@iii{#1 \etal}}%
  \fi
}
\def\etal{et~al.}
\makeatother

\citationmode{abbr}
\citationstyle{dcu}

\begin{document}

\citeasnoun{Campbell(1996)}

\cite{Hamilton(1994)}

\cite{U+R}

\bibliographystyle{dcu}
\bibliography{\jobname}
\end{document}

The filecontents* environment is just for making the example selfcontained. Use your own database.

enter image description here

Related Question