[Tex/LaTex] How to remove the comma after journal name and before volume in the bst description

apa-stylebibliographiesbibtex

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

instead of

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},
  Author                   = {Adrian A. Author},
  Journal                  = {Journal of Bibtexing},
  Year                     = {2018},
  Note                     = {in press},
}

Best Answer

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.

enter image description here

\RequirePackage{filecontents}
\begin{filecontents}{mybib.bib}
@preamble { "\providecommand\noopsort[1]{}" }
@Article{Author:InPress,
  Title     = {Thoughts},
  Author    = {Adrian A. Author},
  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}