# harvard citation management package: How to uppercase the authors in the citation call-out?

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

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


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).

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},
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.

\documentclass{article}

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

\newcommand\HARVARDAND{\harvardand}

\begin{document}

A \citeasnoun{Campbell(1996)}

B  \cite{Hamilton(1994)}

\bibliography{tst}

\end{document}


xdcu.bst is a copy of dcu.bst with

"u" change.case$ added in some likely looking places (I may not have caught them all) You can find a copy of the original with a command such as  kpsewhich dcu.bst  which on my system returns /usr/local/texlive/2014/texmf-dist/bibtex/bst/harvard/dcu.bst  Specifically I made the following changes (diff format so 200c200 means line 200, < denotes a line in dcu.bst and > denotes a line in xdcu.bst. 200c200 < { "{vv~}{ll}{, jj}{, f.}" author format.names } --- > { "{vv~}{ll}{, jj}{, f.}" author format.names "u" change.case$}
540,544c540,544
<   { s #1 "{vv~}{ll}" format.name$" et~al." * } < { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
<             { s #1 "{vv~}{ll}" format.name$" et~al." * } < { s #1 "{vv~}{ll}" format.name$ " \harvardand\ " *
<               s #2 "{vv~}{ll}" format.name$* --- > { s #1 "{vv~}{ll}" format.name$ "u" change.case$" et~al." * } > { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "u" change.case$"others" = > { s #1 "{vv~}{ll}" format.name$ "u" change.case$" et~al." * } > { s #1 "{vv~}{ll}" format.name$ "u" change.case$" \harvardand\ " * > s #2 "{vv~}{ll}" format.name$ "u" change.case$* 550c550 < { s #1 "{vv~}{ll}" format.name$ }
---
>     { s #1 "{vv~}{ll}" format.name$"u" change.case$}
676c676
<   make.full.label write$--- > make.full.label "u" change.case$ write\$

• @DanielTheRocketMan No!!!!!!!!!!!!!!!!!!! not more points to egreg:-) – David Carlisle Dec 1 '14 at 23:54
• @DanielTheRocketMan This solution capitalizes the authors in the referenece (not only citations) too. Was it your intend? – wipet Dec 5 '14 at 6:00
• @wipet I wondered about that, I assumed it was the intention, seeing as the point of printing the string at the citation is so the reader can match the label in the reference list it seems more natural to print them in the same way. – David Carlisle Dec 5 '14 at 8:27
• @wipet, my original intention was to capitalize the authors in the reference, but based on the solution above, I discovered that if you choose correctly the places to change (as he showed), I can also find the needed solution. I believe that this citation style is based on a Brazilian norm (I have no justification to support as well) – DanielTheRocketMan Dec 6 '14 at 9:23

My solution uses \uppercase when reading the third parameter of \harvardcite which is used in .aux file. Then we need to replace ET~AL. to et.~al.. I used the macro \replacestrings from my OPmac for this purpose.

\documentclass{article}
\usepackage{harvard}

\let\harvardciteori=\harvardcite
\def\harvardcite#1#2#3#4{\uppercase{\def\tmpb{#3}}%
\replacestrings{ET~AL.}{et~al.}%
\def\tmpa{\harvardciteori{#1}{#2}}\expandafter\tmpa\expandafter{\tmpb}{#4}%
}
% replacestrings from OPmac:
\bgroup \catcode!=3 \catcode?=3
\gdef\replacestrings#1#2{\long\def\replacestringsA##1#1##2!{%
\edef\tmpb{\expandafter}\expandafter\replacestringsA\tmpb?#1!%
\long\def\replacestringsA##1?{\def\tmpb{##1}}\expandafter\replacestringsA\tmpb
}
\egroup

\citationmode{abbr}
\citationstyle{dcu}

\begin{document}

A \citeasnoun{Campbell(1996)}

B \cite{Hamilton(1994)}

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

• This appears to be applying \edef to the citation strings which isn't safe in general, \uppercase would be better \MakeUppercase for similar reasons. for example if \ss is in the name latex doesn't seem to ever converge, reports labels changed every time. – David Carlisle Dec 5 '14 at 8:58
• @DavidCarlisle There is no \edef here. – wipet Dec 5 '14 at 12:23
• so there isn't (or rather there isn't an edef applied to unknown tokens) I misread \edef\tmpb{\expandafter} sorry:-) but \ss still causes latex to not converge, presumably due to \uppercase, I didn't check. – David Carlisle Dec 5 '14 at 15:01