Dissertation: How to customize *.bst?

I am almost finished with my PhD thesis (of course in TeX) :) I was looking for hours for a nice bib style which fits the requirements of the Prof, then I looked into the *.bst which rather confused me. Unfortunately, I was not able to generate a bibliography, got me alot of errors. Anyway, the closest *.bst is cj.bst, but the YEAR should be in between the VOLUME and PAGES. Here is an example how it should look like:

Wester, H.J.; Herz, M.; Weber, W.; Heiss, P. Synthesis and radiopharmacology of O-(2- [18F]fluoroethyl)-L-tyrosine for tumor imaging. J Nucl Med 40 (1999) 205–212.

I really hope you can help me!

-
Welcome to TeX.sx! It's not necessary to sign your questions (as there is already a box with your username below it) or to begin them with a greeting. –  Torbjørn T. Dec 12 '11 at 10:29

If you like bst hacking more than using a package like biblatex you may edit cj.bst. First add the date to FUNCTION {format.vol.num.pages}:

FUNCTION {format.vol.num.pages}
{ volume field.or.null
duplicate$empty$ 'skip${ "volume" bibinfo.check } if$
bolden
swap$date.block format.date "year" output.check format.journal.pages }  then remove the date from FUNCTION {article}: FUNCTION {article} { output.bibitem format.authors "author" output.check format.title "title" output.check new.sentence crossref missing$
{
journal
"journal" bibinfo.check
emphasize
"journal" output.check
format.vol.num.pages output
}
{ format.article.crossref output.nonnull
format.pages output
}
if\$
format.note output
fin.entry
}


Additional changes to other entry types may be needed, depending on what you want. But if you really need several changes, I would recommend using biblatex.

-
This is good. Even using custom-bib I did a bit of bst hackery to get DOIs and arXiv IDs to link nicely. It was also enough to instil a desire to use biblatex as soon as I can. –  qubyte Dec 12 '11 at 15:34
@Schweinebacke: you made my day! I changed it and it works perfectly. I stick to that! Now I try to understand how this *.bst is programmed :) –  Dee Dec 12 '11 at 22:31
@Dee: bst is stack oriented. Arguments are put on the stack and functions operate on the topmost stack argument(s). See BibTeX documentation (btxdoc.pdf and btxhak.pdf) for more information. –  Schweinebacke Dec 13 '11 at 6:32
@Schweinebacke I managed to change the year even in the format:book. But I got now another problem, and was so overwhelmed with the initial result that I did not see that there are kommas. The output is as follows: Wester, H. J., Herz, M., Weber, W., Heiss, P., Senekowitsch-Schmidtke, R., Schwaiger, M., and Stöcklin, G., Synthesis and radiopharmacology of O-(2-[18F]fluoroethyl)-L- tyrosine for tumor imaging. J Nucl Med 40, (1999), 205–212. –  Dee Dec 15 '11 at 11:05
@Dee: I've already told you: If you want to do a lot of changes at a bst file, you should learn is works (see the link at may previous comment). Or you may use biblatex where you may do all those changes without learning bst-programming but simply from within LaTeX. The comma at the output is from output.nonnull. This function is often used, so you may need to copy and change several functions to remove it at this position only. I'd really recommend to see my biblatex answer and to try to modify this one with help of biblatex manual. –  Schweinebacke Dec 15 '11 at 11:50

I would recommend usage of biblatex, because you may configure it, without bst-hacking. You may start with, e.g.,

\RequirePackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{
anykeyyoulike,
author = {Wester},
title = {P. Synthesis and radiopharmacology of O-(2-
[18F]fluoroethyl)-L-tyrosine for tumor imaging},
journaltitle={J Nucl Med},
volume=40,
year={1999},
pages={205-212}
}
\end{filecontents*}
\documentclass{article}
\usepackage[citestyle=authoryear,bibstyle=authortitle]{biblatex}
\bibliography{\jobname}

\begin{document}
\nocite{*}
\printbibliography
\end{document}

-
What backend are you using? I'm with biber and I had to add backend=biber option when calling biblatex package. –  Crowley Dec 12 '11 at 11:17
@Crowley: bibtex is the default biblatex backend. So my examples works with bibtex. If you like to switch to another supported backend, you have to set option backend. See biblatex manual for more information. –  Schweinebacke Dec 12 '11 at 11:31
@Schweinebacke: You suggest to hard-write the bibliography in your suggested style? I use BibDesk (Mac) for keeping my Bibliography (around 200 citations!) –  Dee Dec 12 '11 at 22:20
@Dee: You may use every bibliography application, that provides proper bibtex export. The one hand made entry at my example was made to have a MWE. –  Schweinebacke Dec 13 '11 at 6:24

Take a look the following, condensed listing of different styles. It helped me finding a proper (already predefined style) for all of my written work.

-
Thank you. I had this list before and got the cj.bst from there. –  Dee Dec 12 '11 at 22:33

Do not hassle with hacking the .bst files. Most of them are very incomprehensible and it is hard to see what side effects small changes can cause.

While I would also recommend using biblatex instead of the older methods there is another alternative: custom-bib.

This script basically asks you 100 questions and produces a .bst file exactly as you want it.

-
I don't know why this wasn't the first suggestion. It's probably the simplest too, considering that the only effort needed is to answer the equations and substitute the bibliography style. –  qubyte Dec 12 '11 at 15:32

Although you're a bit late in the game: If you don't absolutely have to use traditional bibtex, have a good look at biblatex. It gets rid of the .bst files, all the formatting is done in LaTeX. Besides that biblatex is much more powerful and has a much more complete data model. If you're not desperately running out of time, it's definitely worth to spend some time to get familiar with biblatex.

Personal anecdote: I myself switched to biblatex quite late during my PhD and I haven't regretted it for one moment.

-
A general comment: Whenever an OP asks a BibTeX-related question on the TeX.SE group, I've noticed a fair amount of advice-giving of the type "switch from bibtex to biblatex". No matter how superior one may honestly believe that biblatex/biber is to (say) natbib/bibtex, such pieces of "advice" are rarely helpful and, because they are really of form of opinion-giving and proselytizing, may actually be quite off-putting. At the very least, if you want to bring up biblatex as the better method, do provide a concrete MWE that shows how the OP might solved his/her problem. Thanks. –  Mico Dec 12 '11 at 11:05
@Mico: If I understand Dee's question correctly, he is still searching for a proper bibtex style. So I cannot see any problem in suggesting to use biblatex. But if you'd recommend another solution: Do it. –  Schweinebacke Dec 12 '11 at 11:09
@Mico: I strongly disagree: If the OP can achieve something with biblatex he can't achieve with bibtex, the advice is definitely helpful. And it's also not a matter of opinion that biblatex allows you to do many things which can't be done with bibtex. –  Simifilm Dec 12 '11 at 11:13
@Schweinebacke: In your answer, you do suggest an actual solution rather than just a hand out generic advice. That's fabulous -- and answers like your's are not what I'm reacting to. By the way, I hope "Simifilm" doesn't feel singled out by my comment. He/she is certainly not the only person on this list who commits an act that goes against the group's professed goal of giving concrete solutions rather than just general pieces of advice. –  Mico Dec 12 '11 at 11:14
@Simifilm: Opinions may be correct or incorrect; notice, though, that I didn't dispute the view that biblatex is (vastly) superior to bibtex. A personal aside: Because biblatex is about 20 years more recent than bibtex, I wouldn't believe anyone who claims that bibtex is actually better than biblatex. My point is different: just pointing out biblatex's superiority without actually providing a suggested solution that employs biblatex is unlikely to be helpful, and it may end up being off-putting. –  Mico Dec 12 '11 at 11:18

Whereas you say that the cj.bst style file is "close" to what you need, you don't provide enough information to give you a full answer. You mention that you're writing your dissertation: does your academic department, or your university, provide a detailed set of formatting requirements? If so, is there a .bst file that someone has already created to meet these requirements? If that's the case, use that file and you're done (at least until after the dissertation's been accepted).

I'm pretty sure nobody will ever seriously recommend that you do any direct hacking of an existing .bst file in order to achieve your formatting objectives. But hacking an existing .bst file isn't the only way to go. As long as your prof's/department's/school's formatting requirements are spelled out reasonably clearly, you should consider running the program makebst to create a .bst file from scratch. (The file is part of the custombib package already mentioned in another answer.) The file makebst.tex can be run either from the command window or by loading it into an editor and then passing it through tex or latex. It'll ask you a lot of questions related to formatting of citations and bib entries; sometimes you'll be asked a yes/no question, more often you'll get quite a few options to choose from. (Don't be shy to use the verbose option; you'll get plenty of explanations.) The program's output is a customized .bst file which should meet all of your school's formatting requirements.

-
Thanks for the help and input! To your question about a template from university... I am sorry, they are poor Word users, so, there is no *.bst.// You are absolutly right about the makebst. I will look into that. But for now, with Schweinebackes code I changed the cj.bst and I got the References out as it I wanted it. Thank you! –  Dee Dec 12 '11 at 22:41
Glad you found my comments useful -- and even happier that you've been able to solve your BibTeX needs. –  Mico Dec 12 '11 at 23:08