[Tex/LaTex] Biblatex Custom Cite Command with \citefield

biblatexciting

I need to make a custom cite command for my PhD.

I made this so far:

\newcommand{\sfootcite}[1]{\footnote{\emph{\citename[2]{#1}{shortauthor}}, \citefield{#1}{shorttitle}}}

which works great if my cite looks like this:

\sfootcite{iustinus1997}

The problem is I have two optional arguments before the entry name. My cites look like this:

\sfootcite[Cf.][P. 8]{iustinus1997}

How do I get new command to make the cite looking like this:

Cf. Autor, Title, P. 8

Basically my question is: How do you get things, which are in [][] before {iustinus1997} to be included in the new cite command?

Here is my MWE:

\documentclass[a4paper,11pt]{scrartcl}
\usepackage[latin1]{inputenc}
\usepackage{csquotes}
\usepackage{blindtext}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib} 
@book{iustinus1997,
    Address = {Berlin/New York},
    Author = {{Iustinus Martyr}},
    Call-Number = {EgI180},
    Date-Added = {2010-10-13 09:19:34 +0200},
    Date-Modified = {2010-10-13 09:21:42 +0200},
    Editor = {Miroslav Marcovich},
    Publisher = {Walter de Gruyter},
    Series = {Patristischen Texte und Studien},
    Shortauthor = {Iust.},
    Shorttitle = {De Tryph.},
    Title = {Iustini Martyris dialogus cum Tryphone},
    Volume = {47},
    Year = {1997}}
\end{filecontents} 
\newcommand{\sfootcite}[1]{\footnote{\emph{\citename[2]{#1}{shortauthor}}, \citefield{#1}{shorttitle}}}
\usepackage[ngerman]{babel}
\usepackage[style=authoryear, hyperref=true]{biblatex} 
\bibliography{\jobname} 
\begin{document}
\blindtext \sfootcite{iustinus1997}
\blindtext
\printbibliography

\end{document}

Best Answer

I must agree with pst's comment that it looks as if you are trying to use two inconsistent citation schemes; but I take it that you want to use an author/title scheme for some works (e.g. primary texts) and an author/year scheme for others. If that is not so, and what you want is an author/title scheme, then it is much better to use that from the get-go.

Anyway, here's (roughly) how I would do it, if you actually need this particular command.

First, we define a specific bibliography driver. There are some catches here, because what happens if (for instance) you don't have a shortauthor or a shorttitle? This is defined so that it would (in that case) fall back on the "standard" driver for the work. This might well not be what you want, but you need to decide what you do want in such circumstances. Programming custom styles is all about predicting the unpredictable.

\DeclareBibliographyDriver{myshort}{%
    \usebibmacro{begentry}%
    \ifboolexpr{ test{\ifnameundef{shortauthor}} 
                or test {\iffieldundef{shorttitle}}}
      {\usedriver{}{\thefield{entrytype}}}
      {\printnames{shortauthor}%
       \setunit{\addcomma\space}%
       \printfield{shorttitle}\isdot}%
       \usebibmacro{finentry}%
    }

Basically this looks to see if you have a shortauthor and shorttitle fields. If you don't it falls back on the standard driver. If you do it prints both, with a comma between, and "converts" the period you use at the end of your short titles into an "abbreviation point" which will allow a comma to be placed after it by the postnote.

That done, we define a "proper" citation command which will make use of that driver. This has four mandatory and one optional argument: the mandatory arguments specify (a) code to use before the citation (i.e. the prenote), (b) the "loop code" called for each citation; (c) the delimiting code called between each citation, and (d) code to be used at the end of the citation(s) (i.e. to handle postnotes). The optional argument is used to "wrap" the whole citation, if that is required (e.g. to place it in parentheses or, as in this case, a footnote.)

\DeclareCiteCommand{\mycite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usedriver{}{myshort}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

Now \mycite will act like an ordinary citation command, calling the myshort driver, and wrapping everything in a footnote. So

\mycite[See][11]{iustinus1997}

produces a footnote as appears in the image below.

Image shows footnote citation

If I was putting this to actual use, I'd want to spend some more time making sure there was no other "housekeeping" my citation command should be doing, which would mean working through authoryear.cbx to make sure this was more or less compatible with it.

Related Question