Have a default pre value in a multicite
The \AtNextCite
hook allows you to easily define variants of existing citation commands.
\newrobustcmd*{\mycite}{\AtNextCite{<code>}\cite}
In <code>
you can modify biblatex counters, generic commands, bibliography macros or formatting directives. These changes are applied only to the following \cite
. Citation argument parsing can be left to biblatex. A mulitcite variant of \mycite
can be defined similarly:
\newrobustcmd*{\mycites}{\AtNextCite{<code>}\cites}
Here's an example addressing your question. In the new citation commands you can override the default prenote \bibstring{confer}
by providing a non-empty prenote argument.
\documentclass{article}
\usepackage[style=verbose,maxnames=1]{biblatex}
\newrobustcmd*{\cfautocite}{\cfcitehook\autocite}
\newrobustcmd*{\Cftextcite}{\cfcitehook\Textcite}
\newrobustcmd*{\cfautocites}{\cfcitehook\autocites}
\newrobustcmd*{\Cftextcites}{\cfcitehook\Textcites}
\newrobustcmd*{\cfcitehook}{%
\AtNextCite{\renewbibmacro*{prenote}{\usebibmacro{prenote:confer}}}}
\newbibmacro*{prenote:confer}{%
\iffieldundef{prenote}
{\bibstring{confer}}
{\printfield{prenote}}%
\setunit{\prenotedelim}}
\newcommand{\cmd}[1]{\texttt{\textbackslash #1}}
\addbibresource{biblatex-examples.bib}
\begin{document}
\null\vfill\noindent
\cmd{Textcite}: \Textcite[e.g.][10]{companion} showed that... \\
\cmd{autocite}: Filler text \autocite[10]{companion,knuth:ct:a}. \\
\cmd{Textcites}: \Textcites[10]{companion}[e.g.][]{knuth:ct:a}{glashow} showed that... \\
\cmd{autocites}: Filler text \autocites[10]{companion}[e.g.][]{knuth:ct:a}{glashow}. \\\\
\cmd{Cfextcite}: \Cftextcite[e.g.][10]{companion} showed that... \\
\cmd{cfautocite}: Filler text \cfautocite[10]{companion,knuth:ct:a}. \\
\cmd{Cftextcites}: \Cftextcites[10]{companion}[e.g.][]{knuth:ct:a}{glashow} showed that...\\
\cmd{cfautocites}: Filler text \cfautocites[10]{companion}[e.g.][]{knuth:ct:a}{glashow}.
\end{document}
The same approach works for multiprenote
- a field that can't be accessed via \DeclareCiteCommand
or \DeclareMultiCiteCommand
.
\newrobustcmd*{\cfmulticitehook}{%
\AtNextCite{\renewbibmacro*{multiprenote}{\usebibmacro{multiprenote:confer}}}}
\renewbibmacro*{multiprenote:confer}{%
\iffieldundef{multiprenote}
{\bibstring{confer}}
{\printfield{multiprenote}}%
\setunit{\prenotedelim}}
I am only starting to learn how to beat on biblatex
. In general, you are trying to declare a new multicite command. For the numeric
style the \cites
is defined by
\DeclareMultiCiteCommand{\cites}[\mkbibbrackets]{\cite}{\multicitedelim}
so we want
\DeclareMultiCiteCommand{\mycites}[\mkbibbrackets]{\mycite}{\multicitedelim}
We now need to define \mycite
to do what we want. Again starting from teh original numeric
style
\DeclareCiteCommand{\cite}[\mkbibbrackets]
{\usebibmacro{prenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{postnote}}
we can go to
\DeclareCiteCommand{\mycite}[\mkbibbrackets]
{\usebibmacro{myprenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{mypostnote}}
leaving us to define \myprenote
and \mypostnote
. The originals are defined in biblatex.def
as
\newbibmacro*{prenote}{%
\iffieldundef{prenote}
{}
{\printfield{prenote}%
\setunit{\prenotedelim}}}
\newbibmacro*{postnote}{%
\iffieldundef{postnote}
{}
{\setunit{\postnotedelim}%
\printfield{postnote}}}
This is where I am not exactly sure what is best. One solution is
\newbibmacro*{myprenote}{x\space}
\newbibmacro*{mypostnote}{, y}
where x
and y
are whatever you want them to be. I don't think this is really the bibltex
way and I think slightly better is
\newbibmacro*{myprenote}{\printtext{x}\setunit{\prenotedelim}}
\newbibmacro*{mypostnote}{\printtext{\addcomma\space y}\setunit{\postnotedelim}}
but I don't really understand what this is doing and I think we should be using field formatting. Putting it all together
\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\newbibmacro*{myprenote}{\printtext[prenote]{x}\setunit{\prenotedelim}}
\newbibmacro*{mypostnote}{\printtext[postnote]{\addcomma\space y}\setunit{\postnotedelim}}
\DeclareCiteCommand{\mycite}[\mkbibbrackets]
{\usebibmacro{myprenote}}
{\usebibmacro{citeindex}%
\usebibmacro{cite}}
{\multicitedelim}
{\usebibmacro{mypostnote}}
\DeclareMultiCiteCommand{\mycites}[\mkbibbrackets]{\mycite}{\multicitedelim}
\begin{document}
\cites(a)(b)[x][y]{angenendt}[x][y]{bertram}
\mycites(a)(b){angenendt}{bertram}
\end{document}