Search code examples
latexbibliography

Showing the number in front of an inline citation with \bibentry


I would like to show the number in front of the full inline citation generated by \bibentry from the bibentry package, matching the one that appears in the bibliography.

In the following MWE, this would correspond to a [2] in front of the indented \bibentry. How would I do that?

\documentclass[11pt]{article}
\usepackage{bibentry}
\begin{filecontents}{test.bib}
@misc{Emma,
author = "Emma",
title = "Emma's publication",
year = "2001" }
@misc{Martha,
author = "Martha",
title = "Interesting thoughts",
year = "2003" }
@misc{Paul,
author = "Paul",
title = "Paul's essay",
year = "2000" }
\end{filecontents}
\begin{document}
\nobibliography*
\noindent
This is a usual reference~\cite{Emma}.
Now I'm referring to\\[5pt]
\indent \bibentry{Martha}.\\[5pt]
The following is again a normal reference~\cite{Paul}.
\bibliography{test}
\bibliographystyle{plain}
\end{document}

This image shows the output of the above MWE


Solution

  • I guess bibentry doesn't allow that, one possible solution is to define a new command (or redefine \bibentry) as a \cite and \bibentry.

    Some thing like that:

    \let\oldbibentry\bibentry
    \renewcommand{\bibentry}[1]{\cite{#1} \oldbibentry{#1}}
    

    So if we try this code:

    \documentclass[11pt]{article}
    \usepackage{bibentry}
    
    % redefine the bibentry command as cite then bibentry
    \let\oldbibentry\bibentry
    \renewcommand{\bibentry}[1]{\cite{#1} \oldbibentry{#1}}
    
    \begin{filecontents}{test.bib}
    @misc{Emma,
    author = "Emma",
    title = "Emma's publication",
    year = "2001" }
    @misc{Martha,
    author = "Martha",
    title = "Interesting thoughts",
    year = "2003" }
    @misc{Paul,
    author = "Paul",
    title = "Paul's essay",
    year = "2000" }
    \end{filecontents}
    \nobibliography*
    \begin{document}
    \noindent
    This is a usual reference~\cite{Emma}.
    Now I'm referring to\\[5pt]
    \indent \bibentry{Martha}.\\[5pt]
    The following is again a normal reference~\cite{Paul}.
    \bibliography{test}
    \bibliographystyle{plain}
    \end{document}
    

    it should produce: enter image description here