# Year in bibliography with brackets

i want in my bibliography the year within brackets. How can I customize my style?

I think I have to change the FUNCTION {format.date}, but how?

regards

\documentclass[pdftex,a4paper,12pt,german]{book}
\usepackage[german,ngerman]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[authoryear]{natbib}
\begin{document}
\bibliographystyle{myplainnat}
\cite{Alonso.2004}
\bibliography{Literatur}
\end{document}

@book{Alonso.2004,
author = {Alonso, Gustavo and Casati, Fabio and Kuno, Harumi and Machiraju, Vijay},
year = {2004},
title = {Web services: Concepts, architectures and applications},
url = {http://www.loc.gov/catdir/enhancements/fy0817/2004298168-d.html},
publisher = {Springer},
isbn = {3540440089},
series = {Data-centric systems and applications}
}


Now my bibliography looks like this:

G. Alonso, F. Casati, H. Kuno, and V. Machiraju. 2004, Web services: Concepts, architectures and applications. Data-centric systems and applications. Springer, Berlin, 2004.

But I want it looks like this:

G. Alonso, F. Casati, H. Kuno, and V. Machiraju. (2004), Web services: Concepts, architectures and applications. Data-centric systems and applications. Springer, Berlin, 2004.

The First Year within brackets

-
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  mafp Feb 19 '13 at 9:31

You did not provide your bibliography style, but it should work like this: add the two lines to format.date as

FUNCTION {format.date}
{ year duplicate$empty$
{ "empty year in " cite$* warning$
pop$"" } 'skip$
if$month empty$
'skip${ month " " * swap$ *
}
if$duplicate$ empty$'skip$ %% added
{ "(" swap$* ")" *} %% added if$
extra.label *
}


To have a period in front of the year instead of the comma, issue a new.block command before the output of the year, like I did here for the article type

FUNCTION {article}
{ output.bibitem
format.authors "author" output.check
author format.key output
new.block
format.title "title" output.check
new.block
crossref missing${ journal emphasize "journal" output.check eid empty$
{ format.vol.num.pages output }
{ format.vol.num.eid output }
if$new.block %% added format.date "year" output.check } { format.article.crossref output.nonnull eid empty$
{ format.pages output }
{ format.eid output }
if$} if$
format.issn output
format.doi output
format.url output
new.block
note output
fin.entry
}

-
I do not provide my bibliography style because it was standard style. It works, Thank you a Lot. But there is still a Problem. The second Year shall not within brackets, but with your solution it is :( This second year should belongs to the address field. Maybe I have to change another Function for this? –  Igor Feb 19 '13 at 11:09
@Igor Your style myplainnat is not standard, plainnat is. I used plainnat as a start, and added the two lines to format.date. If you need two different forms of format.date, you have to define two, and then use them in the right place. The first would be the unaltered form, the second the new form. But ultimately, you should provide your myplainnat.bst, so maybe a better solution can be found. –  mafp Feb 19 '13 at 11:27
Oh thats a good suggestion. I will try this. unfortunately i can not provide my style, because it have to much characters :( –  Igor Feb 19 '13 at 11:30
Now I have a separate Function for years with brackets. The Function for formate.date is standard. So it works as expected –  Igor Feb 19 '13 at 11:40
Maybe you can give me a hint to merge the adress with the year like "Berlin 2004" and not "Berlin, 2004"? I added just an additional "year"-line after the address at the Function{book}... –  Igor Feb 19 '13 at 11:45

Fix the address year problem with another customized formate.date Function

  FUNCTION {format.dateWithSpace}
{ year duplicate$empty$
{ "empty year in " cite$* warning$
pop$"" } 'skip$
if$month empty$
'skip${ month " " * swap$ *
}
if$duplicate$ empty$'skip$              %% added
{ " " swap$* "" *} %% added if$
extra.label *
}

-