# \bibentry producing dashes for authors with custom bst

I made a custom .bst file using makebst and chose the option for producing a long dash for repeated author names in the bibliography (option nmdash,nmd-3). (I'm using bibtex with natbib and author-year citations.) This works as intended in the bibliography (produced with \bibliography{}). However, I need to include certain entries at various points in the text, and then primarily in isolation. When I use \bibentry{key} for a reference that appears in the bibliography with the authors replaced by a long dash, the long dash is used here too. When the reference is printed by itself like that, the dash is meaningless. Is this avoidable with my current setup or will I have to switch to biblatex or something else?

I'm not sure how to create an MWE for this without attaching the bst file (which I'd be happy to do if it'd be helpful, of course) --- sorry.

• – henrique Dec 18 '15 at 13:18
• @henrique Thanks, I was not able to find that. – tanh Dec 18 '15 at 21:44

First we need to recreate the bst file you created with makebst. The file above is only a stripped version (I removed everything commented with latexpand) of the dbj file created running tex makebst.tex with all the default options except for the ay (for author-year), nmdash and nmd-3:

%% Stripped version of driver file produced from merlin.mbs
\input docstrip
\preamble
----------------------------------------
***  ***
\endpreamble
\postamble
End of customized bst file
\endpostamble
\keepsilent
\def\MBopts{\from{merlin.mbs}{ay,ed-au,nmdash,nmd-3,num-xser,isbn,issn,doi,xedn,nfss,}}
% You can change the name of the bst file below:
\generate{\file{tanh.bst}{\MBopts}}
\endbatchfile


Save it as .dbj and run tex on it. You will get a tanh.bst or whatever name you write in the \generate line.

Then, accoding to Guido's answer to Prevent ibid tracking in natbib, we must edit the name.or.dash macro on the newly created bst file. Here's a patch:

--- tanh.bst    2015-12-18 13:11:40.004012993 -0200
+++ tanh_new.bst    2015-12-18 11:19:30.636130895 -0200
@@ -890,7 +890,7 @@
oldname empty${ s 'oldname := s } { s oldname = - { "---{}---{}---" } + { "\andash{" oldname * "}" * } { s 'oldname := s } if$
}


Apply it with patch < <patch-filename>. It only works if your bst file is named tanh.bst. But it's a single line diff, so you can just edit the line accordingly (in line 890, replace { "---{}---{}---" } for { "\andash{" oldname * "}" * }).

The MWE from Guido's answer must be enough. Just comment out \bibliography on your first run before running bibtex as suggested there.

\documentclass{article}
\usepackage{natbib}
\usepackage{bibentry}
\usepackage{filecontents}
\begin{filecontents}{\jobname.bib}
@Article{first,
author = "Last, First",
title = "First Title",
journal = "Journal Name",
year = 2012
}
@Article{second,
author = "Last, First",
title = "Second Title",
journal = "Journal Name",
year = 2011
}
@Article{third,
author = "More, First",
title = "Third Title",
journal = "Journal Name",
year = 2011
}
\end{filecontents}

\usepackage{etoolbox}
\newcommand{\andash}[1]{#1}
\AtBeginEnvironment{thebibliography}{\renewcommand{\andash}[1]{---{}---{}---}}
\AtEndEnvironment{thebibliography}{\renewcommand\andash[1]{#1}}

\begin{document}
Testing normal citations
\cite{first}
\cite{second}
\cite{third}

\bibliographystyle{tanh.bst}
\nobibliography{\jobname}

Testing \verb|\bibentry|

\bibentry{first}

\bibentry{second}

\bibliography{\jobname}

\section*{More Testing}
Testing \verb|\bibentry| again after the bibliography

\bibentry{second}

\bibentry{first}

\end{document}


Or move to biblatex. It's worth the effort. For guidance:

• Wow, thank you so much for the comprehensive answer. Works great, although commenting out \bibliography prior to every run of bibtex makes it a bit of a hassle (especially when using latexmk or something similar). I'll take your advice on moving to biblatex. – tanh Dec 18 '15 at 21:44