4

I followed the solution of Undesired Placement of Footnotes in Blocks to do citations in my Beamer so that they are indeed footnotes and not foot-of-the-block notes. It works wonders however, when I do \sfcite{some_ref} inside a tabularx, it displays it as 0[1] Author's name, etc instead of simply [1] Author's name, etc. Any clue where this would come from?

% !TEX TS–program = pdflatexmk

\documentclass[mathserif,english]{beamer}
\usepackage[english]{babel}
\usepackage[backend=biber,style=numeric-comp,sorting=none]{biblatex}

\AtEveryCitekey{%
    \renewbibmacro*{in:}{}%
    \clearfield{pages}%
    \clearfield{volume}%
    \clearname{journal}%
    \clearfield{journal}%
    \clearlist{journal}%
    \clearfield{eprint}%
    \clearfield{archivePrefix}%
    \clearfield{primaryClass}%
    \clearfield{url}%
    \clearlist{address}%
    \clearfield{date}%
    \clearfield{eprint}%
    \clearfield{isbn}%
    \clearfield{issn}%
    \clearlist{location}%
    \clearfield{month}%
    \clearfield{series}%
    \clearfield{booktitle}%
    \clearname{booktitle}%
}

\setbeamertemplate{bibliography entry title}{}
\setbeamertemplate{bibliography entry location}{}
\setbeamertemplate{bibliography entry note}{}

\DeclareCiteCommand{\footfullcitetext}
  [\let\thefootnote\relax\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\mkbibbrackets{\thefield{labelnumber}}%
   \addnbspace%
   \usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter
\let\cbx@citehook=\empty
\newtoggle{cbx@blockcite}

\renewcommand{\@makefntext}[1]{%
  \noindent\normalfont\@thefnmark#1}

\DeclareCiteCommand{\sfcite}[\cbx@superscript]%
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \ifciteseen
     {\ifnumequal{\value{page}}{\csuse{cbx@page@\thefield{entrykey}}}
       {}
       {\ifnumequal{\value{framenumber}}{\csuse{cbx@frame@\thefield{entrykey}}}
          {\usebibmacro{sfcite}}
          {}}}
     {\usebibmacro{sfcite}}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\newbibmacro*{sfcite}{%
  \csnumgdef{cbx@page@\thefield{entrykey}}{\value{page}}%
  \csnumgdef{cbx@frame@\thefield{entrykey}}{\value{framenumber}}%
  \xappto\cbx@citehook{%
    \noexpand\footfullcitetext{\thefield{entrykey}}}}

\newrobustcmd*{\cbx@superscript}[1]{%
  \mkbibsuperscript{\mkbibbrackets{#1}}%
  \iftoggle{cbx@blockcite}
    {}
    {\cbx@citehook%
     \global\let\cbx@citehook=\empty}}

\BeforeBeginEnvironment{block}{\global\toggletrue{cbx@blockcite}}

\def\metabox#1{\edef\theprevdepth{\the\prevdepth}\nointerlineskip
  \vbox to0pt{#1\vss}\prevdepth=\theprevdepth}

\AfterEndEnvironment{block}
  {\metabox{%
     \global\togglefalse{cbx@blockcite}%
     \cbx@citehook%
     \global\let\cbx@citehook=\empty}}

\makeatother

\usepackage{filecontents}
\begin{filecontents*}{bib2.bib}
@article{some_ref,
  title={Reference title},
  author={Author's name},
  year={2018}
}
}
\end{filecontents*}

\addbibresource{bib2.bib}

\usepackage{tabularx}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}


\begin{document}

\begin{frame}
\frametitle{MWE frame}

The tabular here:

\begin{table}[h]
\begin{tabularx}{\textwidth}{P{0.45\linewidth}P{0.45\linewidth}}
Sample text & Other sample text\sfcite{some_ref}
\end{tabularx}
\end{table}

The same ref.\sfcite{some_ref}

\end{frame}
\begin{frame}[allowframebreaks]
        \frametitle{References}
    \printbibliography
\end{frame}


\end{document}

enter image description here

Cryme
  • 761
  • 1
    Can you please provide us with a minimal working example, i.e. a small document that starts with \documentclass, ends with \end{document} and illustrates the issue? –  Dec 12 '18 at 18:33
  • Hello, I just did, with a picture as well! – Cryme Dec 12 '18 at 19:04
  • 1
    Thanks. Unfortunately you seem to have inserted your code as a picture, so every [ became a \[ and every ] a \]. Could you please fix that? –  Dec 12 '18 at 19:06
  • 1
    It's fixed, that was a clumsy blunder, sorry. – Cryme Dec 12 '18 at 19:09
  • 3
    Why do you use tabularx? It doesn't make sense in your example. – Ulrike Fischer Dec 12 '18 at 20:20
  • 1
    That is very true, because it is a MWE. I use the tabularx to hold images and an itemize. I could not get the itemize to work in a table else than using tabularx. – Cryme Dec 12 '18 at 20:25
  • I'm not able to find a proper fix for that, but the problem is indeed tabularx. It internally uses a two-stage pass to set the tabular contents and redefines \@footnotetext to prevent extra output on one pass. That somehow messes with the definition biblatex expects, which is why the extra 0 occurs in the output. I guess the easier solution is to drop tabularx here and find a fix for your itemize problem – siracusa Dec 13 '18 at 08:01
  • I would use the \footfullcitetext approach, as shown e.g. in this question: https://tex.stackexchange.com/questions/234306/footfullcitetext-and-beamer-incremental-numbering – samcarter_is_at_topanswers.xyz Dec 13 '18 at 12:29
  • 1
    Off-topic: floating specifier like [h] don't make sense in a document class without floating mechanism – samcarter_is_at_topanswers.xyz Dec 13 '18 at 16:49

1 Answers1

4

Using smacarter's answer to Unnumbered footnote in Beamer we can get unnumbered footnotes in beamer by redefining the beamer template.

\documentclass[mathserif,english]{beamer}
\usepackage[english]{babel}
\usepackage[backend=biber,style=numeric-comp,sorting=none]{biblatex}


\DeclareCiteCommand{\footfullcitetext}
  [\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\mkbibbrackets{\thefield{labelnumber}}%
   \addnbspace%
   \usedriver
     {\DeclareNameAlias{sortname}{default}}
     {\thefield{entrytype}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\makeatletter
\let\cbx@citehook=\empty
\newtoggle{cbx@blockcite}

\DeclareCiteCommand{\sfcite}[\cbx@superscript]%
  {\usebibmacro{cite:init}%
   \let\multicitedelim=\supercitedelim
   \iffieldundef{prenote}{}{\BibliographyWarning{Ignoring prenote argument}}%
   \iffieldundef{postnote}{}{\BibliographyWarning{Ignoring postnote argument}}}
  {\usebibmacro{citeindex}%
   \ifciteseen
     {\ifnumequal{\value{page}}{\csuse{cbx@page@\thefield{entrykey}}}
       {}
       {\ifnumequal{\value{framenumber}}{\csuse{cbx@frame@\thefield{entrykey}}}
          {\usebibmacro{sfcite}}
          {}}}
     {\usebibmacro{sfcite}}%
   \usebibmacro{cite:comp}}
  {}
  {\usebibmacro{cite:dump}}

\newbibmacro*{sfcite}{%
  \csnumgdef{cbx@page@\thefield{entrykey}}{\value{page}}%
  \csnumgdef{cbx@frame@\thefield{entrykey}}{\value{framenumber}}%
  \xappto\cbx@citehook{%
    \noexpand\footfullcitetext{\thefield{entrykey}}}}

\newrobustcmd*{\cbx@superscript}[1]{%
  \mkbibsuperscript{\mkbibbrackets{#1}}%
  \iftoggle{cbx@blockcite}
    {}
    {\cbx@citehook%
     \global\let\cbx@citehook=\empty}}
\makeatother

\setbeamertemplate{footnote}{%
  \parindent 1em\noindent%
  \raggedright
  \insertfootnotetext\par}

\addbibresource{biblatex-examples.bib}

\usepackage{tabularx}
\newcolumntype{P}[1]{>{\centering\arraybackslash}p{#1}}


\begin{document}
\begin{frame}
\begin{table}[h]
\begin{tabularx}{\textwidth}{P{0.45\linewidth}P{0.45\linewidth}}
Sample text & Other sample text\sfcite{sigfridsson}\footnotetext{lorem}
\end{tabularx}
\end{table}

The same ref.\sfcite{sigfridsson}
\end{frame}
\end{document}

Footnotes without superfluous "0"s

moewe
  • 175,683
  • +1 Nice answer! I knew adding the biblatex tag to the question would result in an answer by you :) – samcarter_is_at_topanswers.xyz Dec 13 '18 at 16:34
  • @samcarter Well, you did all the work ;-) It took way too long because I have never really understood how footnotes work and throwing beamer into the equation definitely did not make things easier for me. – moewe Dec 13 '18 at 16:37
  • Na, the really difficult parts were to combine that with biblatex :) (understanding footnotes is probably irrelevant for beamer, as beamer is reinventing them anyway :) – samcarter_is_at_topanswers.xyz Dec 13 '18 at 16:50