3

I would like to give some references using the bibentry package in a beamer presentation. But sometimes, e.g. if the list of authors spans over multiple lines, there is a wrong vertical space in the output (see Image below). Is there a way to adjust the wrong spacing? enter image description here

Here the corresponding MWE:

\documentclass{beamer}

\usepackage{filecontents}
    \begin{filecontents}{\jobname.bib} 
    @article{RefA, 
        author  = {AFirstName ALastName}, 
        title   = {Title A}, 
        journal = {Journal A}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{RefB, 
        author  = {BFirstName BLastName}, 
        title   = {Title B}, 
        journal = {Journal B}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{Problem, 
        author  = {ProblemFirstName ProblemLastName and NoSolutionFirstName NoSolutionLastName}, 
        title   = {Title Problem}, 
        journal = {Journal Problem}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    }  
\end{filecontents}

\usepackage{bibentry}
\nobibliography*

\begin{document}

\begin{frame}
    \frametitle{Bibentry -- Spacing Problem}
    \begin{itemize}
        \item \bibentry{RefA}
        \item \bibentry{RefB}
        \item \bibentry{Problem}
    \end{itemize}
\end{frame}

\begin{frame}
    \frametitle{Bibliography -- No Problem}
    \bibliographystyle{plain}
    \bibliography{\jobname.bib}
\end{frame}

\end{document}
crixstox
  • 1,784

1 Answers1

3

The problem is beamers definition of \newblock which is used between units of the citation. Its definition, in beamerbaselocalstructure.sty, ends with some code that is unnecessary for your inline use. The strange spacing occurs whenever the text before the first new block (the author part) spans more than one line.

Therefore you need to make a version of \newblock that does the font changing beamer provides, but without the final code. This is for use in the main text. When you get to the bibliography you should restore the original beamer definition which is in \beamer@newblock.

Sample output

\documentclass{beamer}

\usepackage{filecontents}
    \begin{filecontents}{\jobname.bib} 
    @article{RefA, 
        author  = {AFirstName ALastName}, 
        title   = {Title A}, 
        journal = {Journal A}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{RefB, 
        author  = {BFirstName BLastName}, 
        title   = {Title B}, 
        journal = {Journal B}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{Problem, 
        author  = {ProblemFirstName ProblemLastName and NoSolutionFirstName NoSolutionLastName}, 
        title   = {Title Problem}, 
        journal = {Journal Problem}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    }  
\end{filecontents}

\usepackage{bibentry}
\nobibliography*

\def\mybeamernewblock{%
  \usebeamercolor[fg]{bibliography entry author}%
  \usebeamerfont{bibliography entry author}%
  \usebeamertemplate{bibliography entry author}%
  \def\newblock{%
    \usebeamercolor[fg]{bibliography entry title}%
    \usebeamerfont{bibliography entry title}%
    \usebeamertemplate{bibliography entry title}%
    \def\newblock{%
      \usebeamercolor[fg]{bibliography entry location}%
      \usebeamerfont{bibliography entry location}%
      \usebeamertemplate{bibliography entry location}%
      \def\newblock{%
        \usebeamercolor[fg]{bibliography entry note}%
        \usebeamerfont{bibliography entry note}%
        \usebeamertemplate{bibliography entry note}}}}%
  \leavevmode
}

\begin{document}

\let\newblock\mybeamernewblock
\begin{frame}
    \frametitle{Bibentry -- Spacing Problem}
    \begin{itemize}
        \item \bibentry{RefA}
        \item \bibentry{RefB}
        \item \bibentry{Problem}
    \end{itemize}
\end{frame}

\makeatletter
\let\newblock\beamer@newblock
\makeatother
\begin{frame}
    \frametitle{Bibliography -- No Problem}
    \bibliographystyle{plain}
    \bibliography{\jobname.bib}
\end{frame}

\end{document}

Update This may be packaged as an environment for use in the body keeping the change local as follows:

\documentclass{beamer}

\usepackage{filecontents}
    \begin{filecontents}{\jobname.bib} 
    @article{RefA, 
        author  = {AFirstName ALastName}, 
        title   = {Title A}, 
        journal = {Journal A}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{RefB, 
        author  = {BFirstName BLastName}, 
        title   = {Title B}, 
        journal = {Journal B}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    } 
    @article{Problem, 
        author  = {ProblemFirstName ProblemLastName and NoSolutionFirstName NoSolutionLastName}, 
        title   = {Title Problem}, 
        journal = {Journal Problem}, 
        volume  = {1},
        pages   = {345--678},
        year    = {9999}, 
    }  
\end{filecontents}

\usepackage{bibentry}
\nobibliography*

\def\mybeamernewblock{%
  \usebeamercolor[fg]{bibliography entry author}%
  \usebeamerfont{bibliography entry author}%
  \usebeamertemplate{bibliography entry author}%
  \def\newblock{%
    \usebeamercolor[fg]{bibliography entry title}%
    \usebeamerfont{bibliography entry title}%
    \usebeamertemplate{bibliography entry title}%
    \def\newblock{%
      \usebeamercolor[fg]{bibliography entry location}%
      \usebeamerfont{bibliography entry location}%
      \usebeamertemplate{bibliography entry location}%
      \def\newblock{%
        \usebeamercolor[fg]{bibliography entry note}%
        \usebeamerfont{bibliography entry note}%
        \usebeamertemplate{bibliography entry note}}}}%
  \leavevmode
}

\newenvironment{references}{\begin{itemize}\let\newblock\mybeamernewblock}{\end{itemize}}

\begin{document}

\begin{frame}
    \frametitle{Bibentry -- Spacing Problem}
    \begin{references}
        \item \bibentry{RefA}
        \item \bibentry{RefB}
        \item \bibentry{Problem}
    \end{references}
\end{frame}

\begin{frame}
    \frametitle{Bibliography -- No Problem}
    \bibliographystyle{plain}
    \bibliography{\jobname.bib}
\end{frame}

\end{document}
Andrew Swann
  • 95,762