0

Following up on this, I encounter a problem when using the algorithm environment. See the minimal working example below (mostly copied from an answer): Here, the algorithm environment simply treats the citation as if it was not printed earlier.

\documentclass{beamer}
\usepackage[style=numeric,citecounter=true,citetracker=true]{biblatex} 
\usepackage{filecontents}
\begin{filecontents*}{myreferences.bib}
    @online{bad,
        author = {{Bad Man}},
        year = {1313},
        title = {Bad Title},
        url = {http://badurl.com/},
    }
\end{filecontents*}
\addbibresource{myreferences.bib}

%https://tex.stackexchange.com/a/165016/38244
\hypersetup{
    colorlinks,
    citecolor=red,
    linkcolor=blue,
%   backref=true
}



\usepackage{algorithm}
\PassOptionsToPackage{noend}{algpseudocode}% comment out if want end's to show
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{algorithmicx}


\let\svthefootnote\thefootnote

\makeatletter
% https://tex.stackexchange.com/a/29931/38244
\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}%
{%  
    \ifciteseen{}{%
        \usebibmacro{citeindex}%
        \let\thefootnote\relax%
        \footnotetext{%
            \blx@anchor
            \mkbibbrackets{\usebibmacro{cite}}%
            \setunit{\addnbspace}
            \printnames{labelname}%
            \setunit{\labelnamepunct}
            \printfield[citetitle]{title}%
            \newunit%
            \printfield[]{year}%
        }%
        \let\thefootnote\svthefootnote%
    }%
    \autocite{\thefield{entrykey}}%
  }
{\addsemicolon\space}
{\usebibmacro{postnote}}
\makeatother



\begin{document}


\begin{frame}{What I found}
    test\footnote{test}

    First time, \cite{bad}   

    test\footnote{test}
\end{frame}

\begin{frame}{Again}
    Next time, \cite{bad} only
\end{frame}


\begin{frame}{Again 1}
    \begin{algorithm}[H]
        \begin{algorithmic}[1]
            \State \cite{bad}
        \end{algorithmic}
    \end{algorithm}
\end{frame}


\begin{frame}{Again 2}

    \begin{table}[htb]
        \begin{tabular}{cc}
            ee & \cite{bad}\\
        \end{tabular}
    \end{table}
\end{frame}

\end{document}

Just to be clear on what I need:

  • Each bibliography entry will appear only once at the footnote of the page on which it is cited for the first time
  • The later instances of the same citekey will hyperlink back to the footnote where the bibliography is printed
hola
  • 4,026
  • 3
  • 35
  • 72

1 Answers1

1

Here's an answer from the user samcarter (who is apparently suspended from this site):

\documentclass{beamer}
\usepackage[style=numeric,citecounter=true,citetracker=true]{biblatex} 
\usepackage{filecontents}
\begin{filecontents*}{myreferences.bib}
    @online{bad,
        author = {{Bad Man}},
        year = {1313},
        title = {Bad Title},
        url = {http://badurl.com/},
    }
\end{filecontents*}
\addbibresource{myreferences.bib}

%https://tex.stackexchange.com/a/165016/38244
\hypersetup{
    colorlinks,
    citecolor=red,
    linkcolor=blue,
%   backref=true
}



\usepackage{algorithm}
\PassOptionsToPackage{noend}{algpseudocode}% comment out if want end's to show
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
\usepackage{algorithmicx}


\let\svthefootnote\thefootnote

\makeatletter
% https://tex.stackexchange.com/a/29931/38244
\DeclareCiteCommand{\cite}
{\usebibmacro{prenote}}%
{%  
    \ifciteseen{}{%
        \usebibmacro{citeindex}%
        \let\thefootnote\relax%
        \footnotetext{%
            \blx@anchor
            \mkbibbrackets{\usebibmacro{cite}}%
            \setunit{\addnbspace}
            \printnames{labelname}%
            \setunit{\labelnamepunct}
            \printfield[citetitle]{title}%
            \newunit%
            \printfield[]{year}%
        }%
        \let\thefootnote\svthefootnote%
    }%
    \autocite{\thefield{entrykey}}%
  }
{\addsemicolon\space}
{\usebibmacro{postnote}}
\makeatother



\begin{document}


\begin{frame}{What I found}
    test\footnote{test}

    First time, \cite{bad}   

    test\footnote{test}
\end{frame}

\begin{frame}{Again}
    Next time, \cite{bad} only
\end{frame}


\begin{frame}{Again 1}
%    \begin{algorithm}[H]
\rule{\textwidth}{1pt}
        \begin{algorithmic}[1]
            \State \cite{bad}
        \end{algorithmic}
%    \end{algorithm}
\raisebox{.4\baselineskip}{\rule{\textwidth}{1pt}}
\end{frame}


\begin{frame}{Again 2}

    \begin{table}[htb]
        \begin{tabular}{cc}
            ee & \cite{bad}\\
        \end{tabular}
    \end{table}
\end{frame}

\end{document}

What I understand, this solution replaces the algorithm environment by horizontal rules.

hola
  • 4,026
  • 3
  • 35
  • 72