1

I am currently modifying a bst file. The problem I am facing now is how to change the separator of the style.

At the moment, I get the following output:

Badie, Dina (2010) ‘Groupthink, iraq, and the war on terror: Explaining us policy shifts toward iraq’ Foreign Policy Analysis 6(4):277–296.

However, I need the following output:

Badie, Dina (2010) ‘Groupthink, iraq, and the war on terror: Explaining us policy shifts toward iraq’, Foreign Policy Analysis 6(4):277–296.

With NO comma after the year, but WITH a comma after the title (and after the editor in a chapter of an edited volume).

Here is the code of the bst file:

FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block =
        %{ add.period$ write$
        { " " * write$
          newline$
          "\newblock " write$
        }
        { output.state before.all =
            'write$
            { add.period$ " " * write$ }
          if$
        }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  author format.key output
  format.date "year" output.check
  date.block
  format.title quote "title" output.check
  new.block
  crossref missing$
    {
      journal
      "journal" bibinfo.check

      "journal" output.check
      add.blank
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

FUNCTION {format.title}
{ title
  duplicate$ empty$ 'skip$
    { "t" change.case$ }
  if$
  "title" bibinfo.check
}
6
  • I'm not sure you've included enough information to address the problem. If the bibliographic entry is of type @ARTICLE, then you should start by showing us the FUNCTION {article} entry. More may still be needed, if the function shunts to a sub-function to handle the title and the date. Commented Oct 1, 2014 at 10:52
  • Looking at the article function you provide, it would seem that any punctuation following the year would be handled by the function format.date or maybe date.block. Likewise, punctuation following the title would likely be handled in format.date or new.block. In the four functions I just mentioned, you might look to see in which ones a comma appears, as that is probably the origin of the comma in your output. (Also note that in your example, there is no discrepancy after the year in how the "bad" and "good" references are shown) Commented Oct 1, 2014 at 12:38
  • I do not need a comma after the year, but after the title! that is my problem
    – feder80
    Commented Oct 1, 2014 at 12:40
  • One indispensible reference for working with BibTeX is tug.ctan.org/tex-archive/info/bibtex/tamethebeast/ttb_en.pdf Commented Oct 1, 2014 at 12:41
  • It is possible that, in the article function, changing the line format.title quote "title" output.check to something like format.title quote "," * "title" output.check might give you the needed comma. The insertion of "," * says to concatenate a comma to the prior string. But whether that will work depends on what format.title is really doing. Commented Oct 1, 2014 at 12:42

1 Answer 1

2

I tried to solve the problem on my own. So I modified the @article function by changing

format.title quote "title" output.check

to

format.title ", " * quote "title" output.check

Here is the complete function

FUNCTION {article}
{ output.bibitem
  format.authors "author" output.check
  author format.key output
  format.date "year" output.check
  date.block
  format.title ", " * quote "title" output.check
  new.block
  crossref missing$
    {
      journal
      "journal" bibinfo.check
      emphasize
      "journal" output.check
      add.blank
      format.vol.num.pages output
    }
    { format.article.crossref output.nonnull
      format.pages output
    }
  if$
  new.block
  format.note output
  fin.entry
}

The result looks like this:

Burke, John P. (2005a) ‘Condoleezza Rice as NSC Advisor: A Case of the Honest Broker Role, ’ Presidential Studies Quarterly 35(3): 554–575.

However, I want the comma to be outside the quote, as follows:

Burke, John P. (2005a) ‘Condoleezza Rice as NSC Advisor: A Case of the Honest Broker Role’, Presidential Studies Quarterly 35(3): 554–575.

How can I solve that Problem? Maybe by changing the quote function?

FUNCTION {quote}
{ duplicate$ empty$
    { pop$ "" }
    { "`" swap$ * "'" * }
  if$
}
2
  • What happens when you place the quote command before the ", ", rather than after the *? Commented Oct 1, 2014 at 14:39
  • Excellent. The switch allowed the quote to apply first, prior to the concatenation of the comma. Commented Oct 1, 2014 at 16:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .