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)"
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
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
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.
.
myapalike.bst
to " (" year * extra.label * ")\removeperiod" *
, i.e., don't insert a space between )
and \removeperiod
that then has to be \unskip
-ped.
@article
,@book
, etc) or only to certain entry types?