[Tex/LaTex] Multiple \footcite of same literature on same page: How to merge footnotes

biblatexfootnotesmultiple-citations

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},
}

Best Answer

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}
Related Question