为 Beamer 构建“智能” \footcite

为 Beamer 构建“智能” \footcite

我想构建一个类似于的命令footcite以在 中使用Beamer。它应按以下方式工作:

  • 如果在当前框架中未使用该引用,则打印带有 的脚注fullcite并将字母打印为footmark
  • 如果它已经在当前框架中使用,那么就将字母作为footmark
  • 如果在另一个框架中再次使用该参考,则打印带有的脚注fullcite并将字母为footmark

下面的 MWE 几乎完成了。但是,问题是在第一帧中,第一次使用 之后\myfootcite{3GPP:36.104},它应该显示为a而不是;因此避免出现警告。bfootmark

警告(ext4):具有相同标识符(名称{3GPP:36.104})的目标已被使用,重复项被忽略

\documentclass{beamer}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@techreport{3GPP:36.104,
    author={3GPP},
    institution={3rd Generation Partnership Project (3GPP)},
    title={Evolved Universal Terrestrial Radio Access {(E-UTRA)}; Base Station {(BS)} radio transmission and reception},
    type={TS},
    number={36.104},
    year=2012,
    month=sep,
    url={http://www.3gpp.org/ftp/Specs/html-info/36104.htm},
    urldate={2014-04},
}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\newcounter{tmpfootnote}
\newcounter{symfootnote}
\setcounter{symfootnote}{0}

\makeatletter
\newcommand\myfootcite[1]{%
    \unskip%
    \ifcsname fnct#1@\theframenumber\endcsname%
        \textsuperscript{\ref*{\csname fnct#1@\theframenumber\endcsname}}%
    \else%
        \expandafter\def\csname fnct#1@\theframenumber\endcsname{#1}%
        \setcounter{tmpfootnote}{\thefootnote}%
        \renewcommand*{\thefootnote}{\fnsymbol{footnote}}%
        \renewcommand*{\thefootnote}{\alph{footnote}}%
        \setcounter{footnote}{\thesymfootnote}%
        \footnote{\label{\csname fnct#1@\theframenumber\endcsname}\fullcite{\csname fnct#1@\theframenumber\endcsname}.}%
        \renewcommand*{\thefootnote}{\arabic{footnote}}%
        \setcounter{symfootnote}{\thefootnote}%
        \setcounter{footnote}{\thetmpfootnote}%
    \fi
}
\makeatother


\begin{document}

\begin{frame}{Frame 1}
    bla\footnote{Test 1}

    bla\myfootcite{3GPP:36.104}

    bla\myfootcite{3GPP:36.104}

    bla\footnote{Test 2}

    bla\myfootcite{3GPP:36.104}
\end{frame}

\begin{frame}{Frame 2}
    bla\footnote{Test 3}

    bla\myfootcite{3GPP:36.104}

    bla\footnote{Test 4}

    bla\myfootcite{3GPP:36.104}

    bla\myfootcite{3GPP:36.104}
\end{frame}

\end{document}

答案1

这似乎有效。

\newcounter{tmpfootnote}
\newcounter{symfootnote}
\setcounter{symfootnote}{0}
\makeatletter
\newcommand\myfootcite[1]{%
    \unskip%
    \ifcsname fnct#1@\theframenumber\endcsname%
        \textsuperscript{\ref*{\csname fnct#1@\theframenumber\endcsname}}%
    \else%
        \expandafter\def\csname fnct#1@\theframenumber\endcsname{fnct#1@\theframenumber}%
        \setcounter{tmpfootnote}{\thefootnote}%
        \renewcommand*{\thefootnote}{\fnsymbol{footnote}}%
        \renewcommand*{\thefootnote}{\alph{footnote}}%
        \setcounter{footnote}{\thesymfootnote}%
        \footnote{\label{\csname fnct#1@\theframenumber\endcsname}\fullcite{#1}.}%
        \renewcommand*{\thefootnote}{\arabic{footnote}}%
        \setcounter{symfootnote}{\thefootnote}%
        \setcounter{footnote}{\thetmpfootnote}%
    \fi
}
\makeatother

完整示例。

\documentclass{beamer}

\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@techreport{3GPP:36.104,
    author={3GPP},
    institution={3rd Generation Partnership Project (3GPP)},
    title={Evolved Universal Terrestrial Radio Access {(E-UTRA)}; Base Station {(BS)} radio transmission and reception},
    type={TS},
    number={36.104},
    year=2012,
    month=sep,
    url={http://www.3gpp.org/ftp/Specs/html-info/36104.htm},
    urldate={2014-04},
}
\end{filecontents}

\usepackage{biblatex}
\addbibresource{\jobname.bib}

\newcounter{tmpfootnote}
\newcounter{symfootnote}
\setcounter{symfootnote}{0}
\makeatletter
\newcommand\myfootcite[1]{%
    \unskip%
    \ifcsname fnct#1@\theframenumber\endcsname%
        \textsuperscript{\ref*{\csname fnct#1@\theframenumber\endcsname}}%
    \else%
        \expandafter\def\csname fnct#1@\theframenumber\endcsname{fnct#1@\theframenumber}%
        \setcounter{tmpfootnote}{\thefootnote}%
        \renewcommand*{\thefootnote}{\fnsymbol{footnote}}%
        \renewcommand*{\thefootnote}{\alph{footnote}}%
        \setcounter{footnote}{\thesymfootnote}%
        \footnote{\label{\csname fnct#1@\theframenumber\endcsname}\fullcite{#1}.}%
        \renewcommand*{\thefootnote}{\arabic{footnote}}%
        \setcounter{symfootnote}{\thefootnote}%
        \setcounter{footnote}{\thetmpfootnote}%
    \fi%
}
\makeatother


\begin{document}

\begin{frame}{Frame 1}
    bla\footnote{Test 1}

    bla\myfootcite{3GPP:36.104}

    bla\myfootcite{3GPP:36.104}

    bla\footnote{Test 2}

    bla\myfootcite{3GPP:36.104}
\end{frame}

\begin{frame}{Frame 2}
    bla\footnote{Test 3}

    bla\myfootcite{3GPP:36.104}

    bla\footnote{Test 4}

    bla\myfootcite{3GPP:36.104}

    bla\myfootcite{3GPP:36.104}
\end{frame}

\end{document}

相关内容