Skip to content

Commit

Permalink
Add hyperlinks to author year, parens -> brackets
Browse files Browse the repository at this point in the history
@Eprint entry type doesn't exist
  • Loading branch information
k4rtik committed Feb 22, 2022
1 parent 979a6cc commit d0ec555
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 29 deletions.
90 changes: 90 additions & 0 deletions acmauthoryear.cbx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,75 @@

\RequireCitationStyle{authoryear}

% From https://tex.stackexchange.com/a/537666/133551
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\iffieldundef{shorthand}
{\ifthenelse{\ifnameundef{labelname}\OR\iffieldundef{labelyear}}
{\usebibmacro{cite:label}%
\setunit{\printdelim{nonameyeardelim}}}
{\printnames{labelname}%
\setunit{\printdelim{nameyeardelim}}}%
\usebibmacro{cite:labeldate+extradate}}
{\usebibmacro{cite:shorthand}}}}

\renewbibmacro*{citeyear}{%
\printtext[bibhyperref]{%
\iffieldundef{shorthand}
{\iffieldundef{labelyear}
{\usebibmacro{cite:label}}
{\usebibmacro{cite:labeldate+extradate}}}
{\usebibmacro{cite:shorthand}}}}

\renewbibmacro*{textcite}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\printtext[bibhyperref]{%
\usebibmacro{cite:label}}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenbracket}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}}
{\printtext[bibhyperref]{\usebibmacro{cite:shorthand}}}}
{\printtext[bibhyperref]{\printnames{labelname}}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nameyeardelim}\bibopenbracket}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\usebibmacro{citeyear}}}

\renewbibmacro*{cite:shorthand}{%
\printfield{shorthand}}

\renewbibmacro*{cite:label}{%
\iffieldundef{label}
{\printfield[citetitle]{labeltitle}}
{\printfield{label}}}

\renewbibmacro*{cite:labeldate+extradate}{%
\printlabeldateextra}

% NEW
\newbibmacro*{citeauthor}{%
\ifnameundef{labelname}
{\iffieldundef{shorthand}
{\printtext[bibhyperref]{%
\usebibmacro{cite:label}}%
\setunit{%
\global\booltrue{cbx:parens}%
\printdelim{nonameyeardelim}\bibopenbracket}%
\ifnumequal{\value{citecount}}{1}
{\usebibmacro{prenote}}
{}%
\printtext[bibhyperref]{\usebibmacro{cite:labeldate+extradate}}}
{\printtext[bibhyperref]{\usebibmacro{cite:shorthand}}}}
\printtext[bibhyperref]{\printnames{labelname}}}

%
% Put brackets around citations
%
Expand Down Expand Up @@ -70,4 +139,25 @@

\DeclareMultiCiteCommand{\textcites}{\textcite}{}

\DeclareCiteCommand{\citeauthor}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeauthor}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear}
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyearpar}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{citeyear}}
{\multicitedelim}
{\usebibmacro{postnote}}

\endinput
2 changes: 2 additions & 0 deletions main-acmauthoryear.tex
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ \section{Introduction}

Test brackets:~\cite{gf-tag-sound-repo,ad-wood-2003}\\
Test repeated items:~\cite{897367,Buss:1987:VTB:897367}\\
Test brackets*:~\cite*{gf-tag-sound-repo,ad-wood-2003}\\
Test repeated items*:~\cite*{897367,Buss:1987:VTB:897367}\\
Test citep: ~\citep{ad-wood-2003}\\
Test citeauthor: ~\citeauthor{ad-wood-2003}\\
Test citeyear: ~\citeyear{ad-wood-2003}\\
Expand Down
2 changes: 2 additions & 0 deletions main-bibtex.tex
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ \section{Introduction}

Test brackets:~\cite{gf-tag-sound-repo,ad-wood-2003}\\
Test repeated items:~\cite{897367,Buss:1987:VTB:897367}\\
Test brackets*:~\cite*{gf-tag-sound-repo,ad-wood-2003}\\
Test repeated items*:~\cite*{897367,Buss:1987:VTB:897367}\\
Test citep: ~\citep{ad-wood-2003}\\
Test citeauthor: ~\citeauthor{ad-wood-2003}\\
Test citeyear: ~\citeyear{ad-wood-2003}\\
Expand Down
29 changes: 0 additions & 29 deletions sample-base.bib
Original file line number Diff line number Diff line change
Expand Up @@ -1586,35 +1586,6 @@ @ArtifactDataset{UMassCitations
lastaccessed = {May 27, 2019}
}

@Eprint{Bornmann2019,
author = {Bornmann, Lutz and Wray, K. Brad and Haunschild,
Robin},
title = {Citation concept analysis {(CCA)}---A new form of
citation analysis revealing the usefulness of
concepts for other researchers illustrated by two
exemplary case studies including classic books by
{Thomas S.~Kuhn} and {Karl R.~Popper}},
keywords = {Computer Science - Digital Libraries},
year = 2019,
month = "May",
eid = {arXiv:1905.12410},
archivePrefix = {arXiv},
eprint = {1905.12410},
primaryClass = {cs.DL},
}

@Eprint{AnzarootPBM14,
author = {Sam Anzaroot and
Alexandre Passos and
David Belanger and
Andrew McCallum},
title = {Learning Soft Linear Constraints with Application to
Citation Field Extraction},
year = {2014},
archivePrefix = {arXiv},
eprint = {1403.1349},
}

@inproceedings{Hagerup1993,
title = {Maintaining Discrete Probability Distributions Optimally},
author = {Hagerup, Torben and Mehlhorn, Kurt and Munro, J. Ian},
Expand Down

0 comments on commit d0ec555

Please sign in to comment.