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
\askforoverwritefalse
\askforoverwritefalse
\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: