# How can I remove the comma after journal name and before volume in my bst description?

I am using an apparently heavily-edited apalike bst style, which I have to use for some reason.

This style unfortunately outputs a comma between the journal name and the volume number, which is something I need to avoid.

Here are the supposedly relevant code snippets:

FUNCTION {article}
{ output.bibitem
format.authors "author" output.check
author format.key output              % special for
output.year.check                 % apalike
new.block
format.title "title" output.check
new.block
crossref missing${ journal emphasize "journal" output.check format.vol.num.pages output } { format.article.crossref output.nonnull format.pages output } if$
new.block
note output
fin.entry
}

FUNCTION {format.vol.num.pages}
{ volume field.or.null
number empty$'skip$
{ " (" number * ")" * *
volume empty${ "there's a number but no volume in " cite$ *
warning$} 'skip$
if$} if$
pages empty$'skip$
{ duplicate$empty$
%   { pop$format.pages } { ": " * pages n.dashify * } % { ", " * pages n.dashify * } % changed from ":" for vol,pgs -- BJR 10/5/89 { ": " * pages n.dashify * } % changed from ":" for vol,pgs -- BJR 10/5/89 if$
}
if\$
}


How can I remove this comma with the least amount of changes to this code? To summarize again, I would like to have

Author names (year) Title of article. Journal Name Volume (Number): pages

Author names (year) Title of article. Journal Name, Volume (Number): pages

EDIT: The full file can be found here: https://pastebin.com/RZmmiqyh

EDIT2: I am particularly in search of a solution that can also handle entries that are "in press", i.e. neither volume, nor number, nor pages have been assigned yet. Instead, after the journal name a colon should appear, and after the colon a comment such as "in press" should be printed.

Example:

Author names (year) Title of article. Journal Name: in press

Exemplary Bibtex entry:

@Article{Author2018,
Title                    = {How to make Bibtex do what I want},
Journal                  = {Journal of Bibtexing},
Year                     = {2018},
Note                     = {in press},
}

• Can you upload the entire .bst file to a text-sharing website like pastebin (please don't use a file sharing website where one has to download a .zip or the like)? That would make it much easier to actually test a solution and it helps with the definitions of unseen macros like field.or.null. – moewe Sep 18 '18 at 8:05
• Sure, please find it here: pastebin.com/RZmmiqyh – Michael Sep 18 '18 at 8:07

I suggest you proceed as follows:

• Open your modified copy of apalike.bst in a text editor. (The program you use to edit your tex files will do fine.)

• Immediately after the function output.check, add the following 3 lines of code:

FUNCTION {add.blank}
{  " " * before.all 'output.state :=
}

• In the article function, locate the line that says

   { journal emphasize "journal" output.check

• Immediately after this line (and hence immediately before the line that says format.vol.num.pages output), insert a new line with following text:

     add.blank

• Save the bst file

• Rerun LaTeX, BibTeX, and LaTeX once more to recreate the formatted bibliography

Happy BibTeXing!

Addendum to address the OP's follow-up question, about how to handle an entry which is "In press", i.e., which hasn't been published yet and for which the volume, number, and pages fields are not yet available.

I believe you should put the "In Press" information in the year field, not the note field. If the article hasn't been published yet, it's better to write "In press" in the year field; before you know it, the publication year might slip from 2018 to 2019 or even 2020... Optional: Use a \noopsort directive to help BibTeX with figuring out how to sort the entry. And, place an \unskip directive in the entry's volume field to undo the output of the add.blank directive.

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@preamble { "\providecommand\noopsort[1]{}" }
@Article{Author:InPress,
Title     = {Thoughts},
Journal   = {Journal of Bib\TeX{}ing},
Year      = {\noopsort{2019}In Press},
volume    = {\unskip},
}
\end{filecontents}

\documentclass{article}
\usepackage[round]{natbib}
\bibliographystyle{apalike-nocomma} % modified form of 'apalike.bst'
\begin{document}
\nocite{*}
\bibliography{mybib}
\end{document}

• Thanks a lot, this worked - almost. Now, there is a space between the Journal name and the colon, which should not exist. – Michael Sep 18 '18 at 8:38
• @Michael - If there's a space between the journal name and the colon, it must be because the entry is missing the volume field. That's almost certainly an error. All academic journals I'm familiar with feature a volume number. Which journal you're citing from is missing the volume information? – Mico Sep 18 '18 at 8:43
• @Michael - So not only the volume field, but also the number and pages fields, are missing? You might have volunteered this rather crucial piece of information a bit earlier... – Mico Sep 18 '18 at 8:46
• @Michael - Please edit your posting to (a) mention that for entries the volume, number, and pages fields might be missing and (b) provide a representative example of such an entry. Clearly, this is a rather non-standard case which requires further investigation. – Mico Sep 18 '18 at 8:49
• @Michael - Please edit your query to provide a specific example of such a "non-standard" entry. – Mico Sep 18 '18 at 8:51