3

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}
4
  • 3
    Are you using two different citation schemes? Otherwise, this is what you'd get with style=authortitle for biblatex, and then just \footcite[Cf.][8]{iustunus1997}. (Biblatex will add "S." for you.)
    – pst
    Mar 28, 2014 at 8:16
  • No I am not using two schemes, I forgot to remove the other one from the MWE sorry!
    – stx932
    Mar 28, 2014 at 8:52
  • In that case, if what you want is an author/title scheme, use an author/title scheme! Besides the standard ones, you might look at dw-biblatex, which may be suitable for your use. Much better to use something fully worked out than "roll your own". Mar 28, 2014 at 9:04
  • So if you are not using "authoryear", why do you say style=authoryear instead of some style that does what you want without customization? (I noticed you just asked a followup to this question, so it's seems relevant.)
    – pst
    Mar 28, 2014 at 10:13

1 Answer 1

5

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.

11
  • Is there any benefit in declaring a new driver for the citation command instead of just defining a bibmacro?
    – moewe
    Mar 28, 2014 at 9:12
  • Not necessarily, it's a matter of taste. My own practice is generally to define drivers whenever the main "job" is to produce a fully formatted citation; but it's largely a matter of style. The code will be essentially the same in either case. Mar 28, 2014 at 9:16
  • Ahh, I see. I was concerned one might lose some of the type specific field formats by using a generic driver, but that might not be the case (I haven't investigated).
    – moewe
    Mar 28, 2014 at 9:20
  • I don't think so. All the fields are accessible once you are in the loop stage of the code. They are inaccessible at the prenote and postnote stage, IIRC, which can be a problem, but not in this case. Calling \usedriver{...} in the loop is idiomatic. Mar 28, 2014 at 9:21
  • Thank you Paul! This is genius solution and it works fine except that I get this error: Package biblatex Error: Bibliography macro 'begentry' undefined.
    – stx932
    Mar 28, 2014 at 9:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .