2

which part of apalike.bst do I have to change to remove the period . after "author (year)" ?

Instead of "author (year)." I need "author (year)"

2
  • Welcome to TeX.SE. Should the change in format apply to all entry types (@article, @book, etc) or only to certain entry types?
    – Mico
    Commented Dec 29, 2016 at 1:27
  • Yes, the change in format should apply to all entry types (@article, @book, etc).
    – Qwerty
    Commented Dec 29, 2016 at 1:36

2 Answers 2

4

Here's a solution that avoids the problem identified in my comments on @Qwerty's own answer.

Begin by making a copy of the file apalike.bst; call the copy, say, myapalike.bst. In myapalike.bst, find the the function output.year.check. Replace the entire function with the following code:

FUNCTION {output.year.check}
{ year empty$
  { "empty year in " cite$ * warning$ }
  { write$
      " (" year * extra.label * ")\removeperiod" *    
  mid.sentence 'output.state :=
    }  
if$
}

Note that there's now no space between ") and \removeperiod".

Save the file myapalike.bst either in the directory where your main tex file is located or in a directory that's searched by BibTeX. If you choose the second option, you will likely also need to update the filename database of your TeX distribution. And, change the argument of the \bibliographystyle instruction from apalike to myapalike.

Separately, provide the following code in the preamble of your document:

\makeatletter
\newcommand{\removeperiod}{\@ifnextchar.{\@gobble}\relax}
\makeatother
1

Copy the apalike.bst file and paste it where the required .tex and .bib files are located. Rename it, (say) myapalike.bst. For editing, open the myapalike.bst using some text editor (I used notepad). Search for FUNCTION {output.year.check}. Now modify it as follows:

FUNCTION {output.year.check}
{ year empty$
  { "empty year in " cite$ * warning$ }
  { write$
      " (" year * extra.label * ") \removeperiod" *    
  mid.sentence 'output.state :=
    }  
if$
}

Also add the following code in your document preamble:

\makeatletter
\newcommand{\removeperiod}{\@ifnextchar.{\@gobble}\relax}
\makeatother
2
  • 1
    I'm afraid this solution isn't quite right. It indeed deletes the "." character, but in the process it inserts too much whitespace between the closing parenthesis of the year field and the first word of the title field. As a result, there's a noticeable difference between the whitespace between the year and title fields and the other interword whitespaces. In short, you also need to remove the space that LaTeX inserts immediately ahead of \removeperiod. Hint: Modify the definition of \removeperiod by inserting the instruction \unskip immediately before \@ifnextchar..
    – Mico
    Commented Dec 30, 2016 at 12:11
  • 2
    Or, maybe more simply, change one of the modified lines in myapalike.bst to " (" year * extra.label * ")\removeperiod" *, i.e., don't insert a space between ) and \removeperiod that then has to be \unskip-ped.
    – Mico
    Commented Dec 30, 2016 at 12:13

You must log in to answer this question.

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