哈佛引文管理包:如何在引文标注中将作者姓名大写?

哈佛引文管理包:如何在引文标注中将作者姓名大写?

我一直在使用harvard具有以下配置的引文管理包:

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

数据库:

@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 =   {},
}

我一直尝试将文中引文标注中的作者姓名大写(我的意思是所有字母,而不仅仅是第一个字母),但没有成功。有没有自动的方法可以做到这一点?

今天,当我使用\citeasnoun{Campbell(1996)},我将得到Campbell et al. (1996)。另一方面,当我使用\cite{Hamilton(1994),我将得到(Hamilton, 1994)

我想要当我使用 时\citeasnoun{Campbell(1996)},我会得到CAMPBELL et al. (1996)。另一方面,当我使用 时\cite{Hamilton(1994),我会得到(HAMILTON, 1994)

答案1

只要作者姓名中没有特殊字符(如\ss或) ,就可以正常工作而不需要更改文件。\i.bst

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

filecontents*环境仅用于使示例独立。请使用您自己的数据库。

在此处输入图片描述

答案2

在此处输入图片描述

\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.bstdcu.bst

"u" change.case$

在一些可能的地方添加(我可能没有全部找到)

您可以使用以下命令找到原始副本

 kpsewhich dcu.bst

在我的系统上返回

/usr/local/texlive/2014/texmf-dist/bibtex/bst/harvard/dcu.bst

具体来说,我做了以下更改(diff格式如此,200c200表示第 200 行,<表示中的一行dcu.bst>表示中的一行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$

答案3

我的解决方案是在读取文件中使用的\uppercase第三个参数时使用的。然后我们需要将其替换为。为此,我使用了 OPmac 中的宏。\harvardcite.auxET~AL.et.~al.\replacestrings

\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!{%
   \ifx!##2!\addto\tmpb{##1}\else\addto\tmpb{##1#2}\replacestringsA##2!\fi}%
   \edef\tmpb{\expandafter}\expandafter\replacestringsA\tmpb?#1!%
   \long\def\replacestringsA##1?{\def\tmpb{##1}}\expandafter\replacestringsA\tmpb
}
\egroup
\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}

\citationmode{abbr}
\citationstyle{dcu}

\begin{document}

A \citeasnoun{Campbell(1996)}

B \cite{Hamilton(1994)}

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

相关内容