This question is closely related to Biblatex: Autocite dependent on shorthand but since that question asks about autocite
, I decided to open a new question.
I am trying to to declare a citation command \mycite
, which behaves like \footcite
for bib-entries without a shorthand
field and for bib-entries with shorthand
field when they are cited for the first time. If a bib-entry with shorthand
field is cited for the second time \mycite
should behave like \parencite
Here is a MWE:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@book{Book1, author={Author 1}, title={Title 1}, shorthand={Shorthand1}}
@book{Book2, author={Author 2}, title={Title 2}}
\end{filecontents}
\usepackage[style=verbose,backend=biber]{biblatex}
\addbibresource{\jobname.bib}
\DeclareCiteCommand{\mycite}[\mkbibfootnote]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{cite:postnote}}
\begin{document}
Citing an entry with defined shorthand field for the first time \mycite{Book1}.
Citing an entry with undefined shorthand field \mycite{Book2}.
Citing an entry with defined shorthand field for the second time \mycite{Book1}.
\end{document}
This gives the following output:
I would like \mycite
to output instead:
Sadly the following declaration of \mycite
does not work:
\DeclareCiteCommand{\mycite}[\iffieldundef{shorthand}\mkbibfootnote\mkbibparens]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{cite:postnote}}
So what I tried instead, was to repurpose the <precode>
and <postcode>
fields by copy pasting the definitions of \mkbibparens
and others, which seems to work for simple tasks like using square or rounded brackets depending on the shorthand field:
\makeatletter
\DeclareCiteCommand{\mycite}[]
{\iffieldundef{shorthand}{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\bibopenparen
\usebibmacro{prenote}}{%
\begingroup
\blx@blxinit
\blx@setsfcodes
\bibopenbracket
\usebibmacro{prenote}}%
}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\iffieldundef{shorthand}{%
\usebibmacro{cite:postnote}%
\bibcloseparen%
\endgroup}{%
\usebibmacro{cite:postnote}%
\bibclosebracket%
\endgroup}
}
\makeatother
This might well be a very bad and ugly hack. And I have no idea how to do this with the \mkbibfootnote
wrapper, which is more complex then the ones for \mkbibparens
or \mkbibbrackets
.
I would like to note, that the most important thing for me here is, to have a cite command which behaves like \footcite
for entries without shorthand
field and which behaves like \parencite
for entries with shorthand
field.
\cite{foo,bar}
wherefoo
does have a shorthand andbar
does not? If you only ever cite one work at a time a workaround is very easy (just move\ifciteseen
and\mkbibfootnote
into the loopcode), if not one would probably have to resort to more trickery.\mycite
. Give me a shout if you would like to see that. Incidentally, the answer has pretty much the form of Guido's answer in the linked question.\footcite
in these cases, I guess. Also your point about readability is sound. As I briefly mentioned, having the first citation of a bib-entry with shorthand field in a footnote is not all that important to me, but it would still be nice to know, how to do that. If you could show me your solution for citing one work at a time, that would really help me.