I think its a bit more complicated than a simple modification, the reason being that the bst
file is simply viewing it on an reference by reference basis and doesn't have the knowledge (as is) to insert the per year changes you want.
What you have is different functions (i.e. article
, book
...) that create a format string for each reference type. They know the year. The string they create is output by output.bibitem
. However, it doesn't know the year.
What you can possibly do is edit each reference type function to store/compare the year of that reference vs a previous reference. And if the year changes do an output (ala output.bibitem
) (something like
"\begin{thebibliography}{9}" write$ newline
(something I've used in my modified bst
files). That fits your formatting (as you seem to already know what it should be).
Annoying that you would have to do it every where.
Sorry I couldn't be more help.
The n.dashify
function is used for both page number ranges and other elements like ISBN numbers, so in order to get the style to work the way you want, we need to separate out those two uses in the style. The simplest way to do this is to create a version of the function for page ranges (which we will call n.dashify
) and create a new version (like the previous n.dashify
which we will call n.dashify.plain
. Additionally, we need to change the functions that process non-page number ranges to use the n.dashify.plain
function instead of our new function.
First, make a copy of natdin.bst
and put it in your local texmf
folder (on a TeX Live system this is usually ~/texmf/tex/bibtex/bst
(~/Library/texmf/tex/bibtex/bst
on a Mac)).
Then, make a copy of the original n.dashify
function in the file and give it a new name: n.dashify.plain
Next, replace the old n.dashify
function with the following one:
FUNCTION {n.dashify}
{ 't :=
""
{ t empty$ not }
{ t #1 #1 substring$ "-" =
{ t #1 #2 substring$ "--" = not
{ "\,--\," *
t #2 global.max$ substring$ 't :=
}
{ { t #1 #1 substring$ "-" = }
{ "" *
t #2 global.max$ substring$ 't :=
}
while$
"\,--\," * }
if$
}
{ t #1 #1 substring$ *
t #2 global.max$ substring$ 't :=
}
if$
}
while$
}
You should now have two n.dashify
type functions in the .bst
file: n.dashify
and n.dashify.plain
.
Finally, change the following two functions (which format URLs and ISSN/ISBNs) to use the n.dashify.plain
function:
FUNCTION { format.doi.urn }
{ urn empty$
{ doi empty$
{ "" }
{ "DOI" doi n.dashify.plain tie.or.space.connect }
if$
}
{ "URN" urn n.dashify.plain tie.or.space.connect }
if$
}
FUNCTION { format.isbn.issn }
{ isbn empty$
{ issn empty$
{ "" }
{ "ISSN" issn n.dashify.plain tie.or.space.connect }
if$
}
{ "ISBN" isbn n.dashify.plain tie.or.space.connect }
if$
}
Here's a sample document. I've duplicated the bib entries to show the behaviour with pages entries of the form n--m
and n-m
in the .bib
file (see discussion in the comments above) and added some ISBN numbers to check that things work as expected.
\begin{filecontents}{\jobname.bib}
@article{Nescio.2000,
author = {Nescio, Nomen and Public, John Q. and Else, Somebody},
year = {2000},
title = {What Miscellaneous Anomaly is This? A Field Guide for the Utterly Confused},
pages = {95--105},
volume = {08/15},
journal = {Internationale Zeitschrift für Tetrapilotomie und Potiosektion},
isbn = {1-84356-028-3}
}
@article{Nescio.2000b,
author = {Nescio, Nomen and Public, John Q. and Else, Somebody},
year = {2000},
title = {What Miscellaneous Anomaly is This? A Field Guide for the Utterly Confused},
pages = {95-105},
volume = {08/15},
journal = {Internationale Zeitschrift für Tetrapilotomie und Potiosektion},
issn = {1-84356-028-3}
}
\end{filecontents}
\documentclass[paper=a4]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english,ngerman]{babel}
\usepackage[square]{natbib}
\usepackage{lipsum}
\begin{document}
\section{Lorem Ispum}
According to \citet{Nescio.2000b,Nescio.2000} we find that
\lipsum[1]
\bibliography{\jobname}
\bibliographystyle{natdin-copy}
\end{document}
Best Answer
Try placing the following in the .bst file. (The upper function may already be present).