1

I'm trying to change the order of \footcite using biblatex only for a specific entrytype. For example if I'd try to do that for the \ifentrytype{commentary}, how can I achieve that. I want the following order:

shorthand, prenote, postnote enter image description here

My idea so war was to change the position of \usebibmacro{prenote} in \DeclareCiteCommand{\footcite}

See attached Example:

\documentclass[12pt,ngerman]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%
\usepackage[%
citestyle=authoryear,%
bibstyle=authortitle,%
backend=biber%
]{biblatex}
%
\usepackage{lipsum}
\usepackage{fontspec}
\setmainfont{Times New Roman}
%
\usepackage{verbatim}
% =======================================================
% =======================================================
\DeclareBibliographyDriver{commentary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{maintitle+title}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{edition}
  \newunit
  \usebibmacro{location+date}%
  \newunit\newblock
  \usebibmacro{finentry}}
% =======================================================
\AtEveryCite{
\ifentrytype{commentary}{%
\DeclareCiteCommand{\footcite}%
  %{\usebibmacro{prenote}}% OLD
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}}
   {\usebibmacro{prenote}}% NEW moved the prenote
  {\multicitedelim}
  {\usebibmacro{postnote}}
}{}%
}
% =======================================================
% =======================================================
% =======================================================

\addbibresource{\jobname.bib}
%
\begin{filecontents}{\jobname.bib}
    @commentary{citekey,
    maintitle={M{\"u}nchener Kommentar zum B{\"u}rgerlichen Gesetzbuch},
    editor={S{\"a}cker, Franz},
    volume={1},
    title={Allgemeiner Teil},
    edition={7},
    address={M{\"u}nchen},
    year={2015},
    shorthand={M{\"u}nchKomm},
}
\end{filecontents}

\begin{document}
% =======================================================

% =======================================================
The idea was to just change the position of \verb|\usebibmacro{prenote}|
\footcite[Armbrüster][§ 138 Rn. 11]{citekey}\\
But sadly it doesn't change anything.


\printbibliography[title=Bibliography]
\end{document}

Any idea how to achieve an order like shown on the picture?

texnewbie
  • 241
  • Why not insert the information directly in the postnote? – gusbrs May 08 '18 at 21:15
  • I already thought about that. The idea is to print the 'commentator' in the prenote for a specific entrytype. I also want the prenote to be formatted in textit for the entrytype. So I just have to insert the name and not always \textit{name}. The rest of the citation is not supposed to be in textit, like shown in the picture. That's why I thought it would be a solution to change the order for a specific entry type. – texnewbie May 08 '18 at 21:19
  • I must say I don't think it is a good idea. As the name says it is a "pre"note, so all the structure of the citation command assumes that. You would probably be better off choosing some other structure than the prenote to do what you want to do. Probably, working with the cite bibmacro. But I'm not sure I understand exactly what you want to achieve, so that's a guess. – gusbrs May 08 '18 at 21:52
  • I can't think of another way. I have no idea how to achieve that with the bibmacro. I need an empty field that I can fill with text that is formatted in a specific way (textit) right after the citation of footcite. Since I'm not after a one time solution, just using the postnote won't work for me. And I only want to change the order for one entrytype, so I can't see the harm in doing that. – texnewbie May 08 '18 at 22:18

1 Answers1

2

The \AtEveryCite doesn't really work because you can't redefine the citation command at a point where you are already executing it. So the redefinition has to happen outside of \AtEveryCite.

On the other hand, \ifentrytype must be executed at a point where the entry type of the processed entry is known. This is not the case if we just do \ifentrytype{commentary}{...redefine \footcite here...}{...keep the original definition...}, so that can't work either. A possible solution is

\DeclareCiteCommand{\footcite}%
  {\ifentrytype{commentary}{}{\usebibmacro{prenote}}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \ifentrytype{commentary}{\usebibmacro{prenote}}{}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

But then you can't add real pre-notes to @commentary types. So I think the idea of abusing the prenote argument in this way is conceptually flawed.

Instead you could think about a solution similar to Optional argument within another optional argument in biblatex \cite. The idea is not to abuse the prenote argument, instead another optional value can be passed to the command via the postnote in round brackets: \autocite[(Armbrüster)§ 138 Rn. 11]{citekey}.

\documentclass[12pt,ngerman]{scrartcl}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[
  citestyle=authoryear,
  bibstyle=authortitle,
  backend=biber,
  autocite=footnote,
]{biblatex}

\DeclareBibliographyDriver{commentary}{%
  \usebibmacro{bibindex}%
  \usebibmacro{begentry}%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{maintitle+title}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{byeditor+others}%
  \newunit\newblock
  \printfield{edition}
  \newunit
  \usebibmacro{location+date}%
  \newunit\newblock
  \usebibmacro{finentry}}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

%\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@commentary{citekey,
  maintitle  = {Münchener Kommentar zum Bürgerlichen Gesetzbuch},
  editor     = {Säcker, Franz},
  volume     = {1},
  title      = {Allgemeiner Teil},
  edition    = {7},
  address    = {München},
  year       = {2015},
  shorthand  = {MünchKomm},
}
\end{filecontents}

\let\oldpostnotedelim\postnotedelim
\renewcommand*{\postnotedelim}{\ifentrytype{commentary}{}{\oldpostnotedelim}}
\DeclareFieldFormat{postnote:stem}{\oldpostnotedelim\mkpageprefix[pagination][\mknormrange]{#1}}
\DeclareFieldFormat{postnote:prefix}{\addslash\mkbibemph{#1}}
\DeclareFieldFormat{postnote}{\mkpostnote{#1}}

\makeatletter
\newrobustcmd*{\mkpostnote}[1]{\mkpostnote@i#1&}

\def\mkpostnote@i{%
  \@ifnextchar(%)
    {\mkpostnote@ii}
    {\mkpostnote@ii()}}

\def\mkpostnote@ii(#1)#2&{%
  \ifblank{#1}{}{%
    \blx@getformat\cbx@postnote@prefix@fmt{ffd}{}{postnote:prefix}%
    \cbx@postnote@prefix@fmt{#1}}%
  \ifblank{#2}{}{%
    \blx@getformat\cbx@postnote@stem@fmt{ffd}{}{postnote:stem}%
    \cbx@postnote@stem@fmt{#2}}%
  }
\def\cbx@postnote@stem@fmt{}
\def\cbx@postnote@prefix@fmt{}
\makeatother

\begin{document}
Lorem\autocite[(Armbrüster)§ 138 Rn. 11]{citekey}
ipsum\autocite[cf.][380]{sigfridsson}
dolor\autocite[cf.][(Armbrüster)§ 138 Rn. 11]{citekey}
sit\autocite[cf.][§ 138 Rn. 11]{citekey}
sit\autocite[(Armbrüster)]{citekey}
\printbibliography[title=Bibliography]
\end{document}

enter image description here

moewe
  • 175,683
  • Maybe this can even be combined with https://tex.stackexchange.com/q/179836/35864 for full name handling in the parenthesised argument. – moewe May 09 '18 at 07:24
  • Thanks for taking your time to help. I really like your first solution DeclareCiteCommand{... it does exactly what I intended. Concerning the abuse of prenotes; there is no scenario where I'd need a prenote when using the entry type commentary. And even if there would be a single exception I'd prefer to simple use \footnote{exceptional prenote \cite{citekey} postnote} and keep everything else simple. This will be only used for german law documents and only for one specific entry type so I really don't understand how it would be bad. Am I breaking something with that? – texnewbie May 09 '18 at 08:55
  • 1
    @texnewbie I'm against it from a conceptual point of view. The only thing that you break is the standard behaviour of the pre-note. If that is no big deal for you, you might as well stick with that approach. But if you want to make your style available to other people, then you should not break established and documented behaviour, especially if an acceptable alternative exists. – moewe May 09 '18 at 09:19
  • I think I understand the concern. Otherwise I'll create a whole new entry type for which I'll want that behaviour. So I'll be able to stick with the \footcite[][]{}and \cite[][]}{} commands. I think it's cleaner. For me breaking established behaviour for one specific new entry type is ok, as long as I'm not breaking anything else. - – texnewbie May 14 '18 at 14:53
  • 1
    @texnewbie I'm not sure if I misunderstand what you say, but the second solution with \autocite[(Armbrüster)§ 138 Rn. 11]{citekey} also works for \cite and \footcite. I just used the high-level command \autocite because I prefer it over \footcite (you can switch from footnote citations to parencite in an instant). In fact the second solution, while longer, is completely agnostic with respect to the citation command that you want to use, whereas the \ifentrytype{commentary} thingy requires you to define every cite command you want to be able to use with a \DeclareCiteCommand. – moewe May 14 '18 at 16:12
  • I just tried to compile the sample. But I'm getting an error message Undefined control sequence. <argument> \mknormrange – texnewbie May 14 '18 at 18:23
  • 1
    @texnewbie Seems you are using an outdated version of biblatex. The command was introduced in the current biblatex 3.11. If you don't want to/can't update, add \providecommand*{\mknormrange}[1]{#1} to the code. – moewe May 14 '18 at 18:32