2

I want to do a basic command called \footcite to write a text, and any number of citations to write them in the footnote.
It's basically this command \newcommand{\footcite}[2]{\footnote{#1 \cite{#2}}} but with 2-n parameters. An use case of this would be \footcite{LLM like ChatGPT or BERT}{chatgpt}{bert},
resulting in a footnote like "LLM like ChatGPT or BERT [1] [2]"

I don't know anything about xparse or macros, etc...

1 Answer 1

6

A command \footcite is defined. It takes 2 arguments. The second argument is a list. A loop is performed on this list with \clist_map_inline:nn. Here each element in the list is given by ##1 on which \cite is applied with a space ~ before that.

enter image description here

\documentclass[a4paper]{article}
\ExplSyntaxOn
\NewDocumentCommand \footcite { m m }
  {
    \footnote
      {
        #1
        \clist_map_inline:nn {#2}
          { ~ \cite {##1} }
      }
  }
\ExplSyntaxOff
\begin{document}
Some text\footcite{LLM like ChatGPT or BERT}{chatgpt,bert}
\begin{thebibliography}{9}
\bibitem{chatgpt}
\emph{ChatGPT},
2024.
\bibitem{bert}
\emph{BERT},
2024.
\end{thebibliography}
\end{document}

You must log in to answer this question.

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