3

I am trying to build my own beamer theme for which I personalized citations. Using the seq module of the package expl3, I have written a function that gathers all citations of a frame into a sequence which I use at the end of each frame to print all citations.

The issue is that I want to print all citations in a tcolorbox in a footnote, however using both the expl3 \seq_map_inline:Nn function and the footnote does not work with beamer, I get the error

Illegal parameter number in definition of \insertfootnotetext".

Everything works fine when using the article class.

Here is a MWE:

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\usepackage{xparse}
\usepackage{expl3}
\usepackage{biblatex}

% My citation
\newcommand{\mycite}[1]{ \cite{#1} ~ \citeauthor{#1} ~ \citetitle{#1} ~ (\citeyear{#1})}

% List of citations
\ExplSyntaxOn
\seq_new:N \l_frame_cite_list
\NewDocumentCommand{\myAddCitation}{m}{\seq_put_right:Nn \l_frame_cite_list {#1}}
\NewDocumentCommand{\generateCitationBox}{}{
    \seq_if_empty:NTF \l_frame_cite_list {} {
        \seq_remove_duplicates:N \l_frame_cite_list
        \footnote{
            \vspace{-1em}
            \begin{tcolorbox}
                \seq_map_inline:Nn \l_frame_cite_list {
                    \mycite{##1}\\
                }
                \vspace{-1em}
            \end{tcolorbox}
            \vspace{-1em}
        }
        \seq_clear:N \l_frame_cite_list
    }
}
\ExplSyntaxOff

\newenvironment{myframe}{\begin{frame}}{\generateCitationBox \end{frame}}

\begin{document}

    \begin{myframe}
        \myAddCitation{A}
        \myAddCitation{B}

        Hello World

    \end{myframe}
\end{document}

Thank you in advance for your answers,

Simon.

3
  • 2
    You need more hashes for \mycite{##1}. Try with \mycite{####1} or more. May 3, 2019 at 9:26
  • Thanks for the answer, I have used @egreg's answer that works fine, what is the signification of muliple # ? I though two were used to distinguish with the argument of the command, what about ####1 ?
    – Siolan
    May 3, 2019 at 11:56

1 Answer 1

3

This has to do with how beamer collects the text of a frame as the argument to a macro. You might use [fragile], but it's simpler using \seq_map_function:NN instead, so the parameter is not explicitly passed in the code.

\begin{filecontents*}{\jobname.bib}
@article{A,
  author={A. Uthor},
  title={A title},
  journal={A Journal},
  year=2018,
}
@article{B,
  author={W. Riter},
  title={B title},
  journal={B Journal},
  year=2019,
}
\end{filecontents*}

\documentclass{beamer}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tcolorbox}
\usepackage{xparse}
\usepackage{expl3}
\usepackage{biblatex}

\addbibresource{\jobname.bib}

% My citation
\newcommand{\mycite}[1]{\cite{#1} \citeauthor{#1} \citetitle{#1} (\citeyear{#1})}

\ExplSyntaxOn
% List of citations
\seq_new:N \l_frame_cite_list_seq
\NewDocumentCommand{\myAddCitation}{m}
 {
  \seq_put_right:Nn \l_frame_cite_list_seq {#1}
 }
\NewDocumentCommand{\generateCitationBox}{}
 {
  \seq_if_empty:NF \l_frame_cite_list_seq
   {
    \seq_remove_duplicates:N \l_frame_cite_list_seq
    \footnote
     {
%      \vspace{-1em}
      \begin{tcolorbox}
      \seq_map_function:NN \l_frame_cite_list_seq \__frame_mycite:n
      \vspace{-1em}
      \end{tcolorbox}
%      \vspace{-1em}
     }
    \seq_clear:N \l_frame_cite_list
   }
 }
\cs_new_protected:Nn \__frame_mycite:n { \mycite{#1}\\ }

\ExplSyntaxOff

\newenvironment{myframe}{\begin{frame}}{\generateCitationBox \end{frame}}

\begin{document}

    \begin{myframe}
        \myAddCitation{A}
        \myAddCitation{B}

        Hello World

    \end{myframe}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .