1

By default, biblatex prints a new footnote for every use of \footcite{...} regardless of the content.

In case of multiple citations of the same literature on the same page, I'd like to automatically merge the identical \footcites (use the same footnote number for every occurence and print the footnote only once). How an I achieve this?

Explanation

MWE

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{Literature.bib}
\begin{document}
    Some text.\footcite{ExampleBook} Some more text.\footcite{ExampleBook}
\end{document}

Content of Literature.bib

@book{ExampleBook,
    title = {Some Title},
    author = {Some Author},
    year = {1492},
}
MaxD
  • 1,137
  • What if you decide to give page numbers as well? \footcite[2]{ExampleBook} and \footcite[3]{ExampleBook} should probably not be merged. It is very unusual to re-use footnotes - even though from time to time people request this. – moewe Dec 29 '17 at 16:16
  • @moewe I don' t understand what you mean. From the biblatex documentation, the input format is\footcite[prenote][postnote]{key}? How would it make sense to enter a page number into the pre- or postnote? – MaxD Dec 29 '17 at 16:20
  • 1
    You can manually repeat a footnote using \footnotemark[\thefootnote] or something to that effect. – John Kormylo Dec 29 '17 at 16:21
  • @JohnKormylo Thanks, I didn't know that command. It's not the automatic solution I'm still hoping for, but in case of emergency it'll do just fine. – MaxD Dec 29 '17 at 16:31
  • 2
    There are number of question about this already. Search a bit and see also https://tex.stackexchange.com/a/295413/2388 – Ulrike Fischer Dec 29 '17 at 16:35
  • @UlrikeFischer Did some more searching now and finally found https://tex.stackexchange.com/q/200286/. It's pretty much exactly what I want, but unfortunately it breaks when changing style option of biblatex and I have no idea how to fix this. – MaxD Dec 29 '17 at 17:14
  • The postnote is usually used to give a specific page number in the reference. Ideally you would not cite sigfridsson, but also the relevant page, that is done with \cite[3]{sigfridsson}. – moewe Dec 29 '17 at 18:10
  • https://tex.stackexchange.com/q/200286/35864 is not what you want, it does not give a new number on a new page. You probably want something like https://tex.stackexchange.com/q/35673/35864 – moewe Dec 29 '17 at 18:14

1 Answers1

2

The tricky bit is when the \footcite is in a paragraph which gets split across two pages. Both halves think they are on the first page. The ifoddpage package can be used to handle that, but it takes two runs.

\documentclass{article}
\usepackage[style=authoryear]{biblatex}
\addbibresource{Literature.bib}

\usepackage{xparse}% for multiple optional parameters
\usepackage{ifoddpage}% get correct page number

\makeatletter
\let\oldfootcite=\footcite
\RenewDocumentCommand{\footcite}{O{}O{}m}{\checkoddpage
  \@ifundefined{citepage@#3}{}%
  {\ifnum\csname citepage@#3\endcsname<\oddpage@page\relax
      \global\expandafter\let\csname repeatcite@#3\endcsname=\relax
  \fi}%
  \@ifundefined{repeatcite@#3}%
  {\oldfootcite[#1][#2]{#3}%
    \expandafter\xdef\csname repeatcite@#3\endcsname{\thefootnote}%
    \expandafter\xdef\csname citepage@#3\endcsname{\arabic{page}}}%
  {\footnotemark[\csname repeatcite@#3\endcsname]}}
\makeatother

\begin{document}
    Some text.\footcite{ExampleBook} Some more text.\footcite{ExampleBook}
    \newpage
    Some more text.\footcite{ExampleBook}

\end{document}
John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • 2
    This breaks the optional arguments for pre- and postnote. – Ulrike Fischer Dec 29 '17 at 17:06
  • Thanks! As long as every literature is only cited on one page this works great. However when an already-cited literature is cited again on another page, it uses the previous number again and doesn't print a new footnote. So if this code could somehow be modified to reset its behaviour every time a new page starts (?) it would be perfect. – MaxD Dec 29 '17 at 17:10
  • Okay, I updated the code. – John Kormylo Dec 29 '17 at 22:22
  • I get "-NoValue-" fields when omitting the square brackets in the footcite command. Is there a way to not having to write them out when they are empty? – Daniel M Feb 02 '20 at 14:06
  • I must have been in a hurry when I did this. – John Kormylo Feb 02 '20 at 16:42
  • @JohnKormylo do you know of a way when you look at it now? It's not really crucial but I'd like to learn how this is done. – Daniel M Feb 03 '20 at 09:26
  • Oops, I fixed it in my version, but curiously not here.Anyway, it is documented in xparse. – John Kormylo Feb 03 '20 at 14:27
  • Thank you so much - this was very helpful. Can this solution also be made to consider the pre and postnotes? I have entries with the same page number in the postnote that I'd like to merge into a single footnote. – Daniel M Feb 29 '20 at 13:42
  • Sorry, I have no idea what a prenote or postnote is. – John Kormylo Feb 29 '20 at 14:26