0

I am using the authoryear-icomp biblatex style. For some publications by institutions with long names, I would like to use shortauthor. However, the style authoryear-icomp simply uses shortauthor from the first citation onwards, like so:

enter image description here

I would like it to work as it does in style=apa, which uses the full author name for the first citation and introduces the short name in square brackets, which it then uses for all further citations (even for other publications of the same author).

This is the output if I change the style to apa: enter image description here

Is there any way to achieve this behaviour with authoryear-icomp?

This is the MWE:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[style=authoryear-icomp, % alternatively: style=apa
  bibstyle=authoryear,
  autocite=inline,
  backend=biber
  ]
 {biblatex}

\usepackage{filecontents}

\begin{filecontents*}{testbib.bib}

@online{test1,
  author = {{Institution Long Name}},
  shortauthor = {ILN},
  title = {Test title},
  year = {2020}
}

@online{test2,
  author = {{Institution Long Name}},
  shortauthor = {ILN},
  title = {Another test title},
  year = {2020}
}

\end{filecontents*}

\addbibresource{testbib.bib}


\begin{document}

Citation number one \autocite{test1}.

Citation number two \autocite{test1}.

Third citation with a different publication by the same author \autocite{test2}.

\end{document}
anbeck
  • 337
  • 1
    Have a look at https://tex.stackexchange.com/q/449052/35864. – moewe Jan 08 '20 at 07:20
  • 1
    I made sure my answer to https://tex.stackexchange.com/q/449052/35864 works again and I checked that it also works with style=authoryear-icomp,. So I suggest you check out https://tex.stackexchange.com/a/449082/35864 because as I understand it your question is pretty much answered by the solution there. – moewe Jan 09 '20 at 20:14
  • Thanks. I haven't been able to try it yet, but from what I understand of the code, it uses the author field and divides it in long and short name parts. My whole bib file, however, uses the shortauthor field, so I imagine it would not work 'out of the box' without adapting my bib? – anbeck Jan 10 '20 at 08:44

1 Answers1

1

You can do something like this - I took some code from APA style. You may need to make this more in line with cite from the authoryear-icomp style for more general use but this gets you what you want as a start:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}

\usepackage[style=authoryear-icomp, % alternatively: style=apa
  bibstyle=authoryear,
  autocite=inline,
  backend=biber
  ]
 {biblatex}

\usepackage{filecontents}

\begin{filecontents*}{testbib.bib}

@online{test1,
  author = {{Institution Long Name}},
  shortauthor = {ILN},
  title = {Test title},
  year = {2020}
}

@online{test2,
  author = {{Institution Long Name}},
  shortauthor = {ILN},
  title = {Another test title},
  year = {2020}
}

\end{filecontents*}

\addbibresource{testbib.bib}

\makeatletter
\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{metacite}%
   \usebibmacro{cite:post}}
  {}
  {\usebibmacro{cite:postnote}}

\newbibmacro*{cite:post}{%
  \xifinlist{\thefield{fullhash}}{\cbx@names}
    {}
    {\listxadd{\cbx@names}{\thefield{fullhash}}}}

\global\let\cbx@names\@empty
\def\cbx@ifnamesaved{%
  \xifinlist{\thefield{fullhash}}{\cbx@names}
    {\@firstoftwo}
    {\@secondoftwo}}

\newbibmacro*{metacite}{%
  \ifnameundef{shortauthor}
    {\usebibmacro{cite}}
    {\usebibmacro{sacite}}}

\newbibmacro*{sacite}{%
  \cbx@ifnamesaved
    {\printnames{shortauthor}}
    {\printnames{author}%
     \addspace\mkbibbrackets{\printnames[sabrackets]{shortauthor}}}%
  \setunit{\printdelim{nameyeardelim}}%
  \usebibmacro{cite:labeldate+extradate}%
  \savefield{namehash}{\cbx@lasthash}%
  \savefield{labelyear}{\cbx@lastyear}%
  \setunit{\multicitedelim}}

\makeatother

\begin{document}

Citation number one \autocite{test1}.

Citation number two \autocite{test1}.

Third citation with a different publication by the same author \autocite{test2}.

\end{document}

PLK
  • 22,776
  • This works great for the initial citation! I just realized, however, that the subsequent citations only show shortauthor and not the year (e.g., "2020b") --- which is probably what you referred to when you said further adjustments might be necessary. I've taken a long look at the cbx file, but have to admit I'm rather overwhelmed. Could you point me to where to go from here? – anbeck Jan 18 '20 at 17:52
  • 1
    My mistake - I have corrected the sacite macro above. – PLK Jan 18 '20 at 18:26