# Remove extra space in abbreviated journal title with jabbrv?

I would like to abbreviate journal titles in my bibliography. One method employs the jabbrv package (https://tex.stackexchange.com/a/66821/293248), in particular with files from this Overleaf template (https://www.overleaf.com/latex/templates/automatic-journal-abbreviations/mxfsdscmvxcr). Even in the template as is, there are extra blank spaces sometimes at the beginning of the abbreviated title, and always when certain characters are removed (those defined by \DefineSpuriousJournalWord{} in jabbrv.sty). I have read through the jabbrv package documentation as well as relevant posts about the package , and did not see the problem being mentioned anywhere.

For example, in the screenshot above, notice the extra space before

[11] ... Two MyAbbrv., ...

and

[13] ... Tes. J. Ref. Inf., ...

Also, in entry [13], whereas the full journal title should be "Test Journal of Reference Information", after "of" is removed, the space following it remains, resulting in what looks like a double-spaces.

In jabbrv.sty from the Overleaf template, starting from line 290, the space after a SpuriousJournalWord is not identified along with the word itself, which makes sense because a space is used as a delimiting character.

% Define Suprious Word Removal:
\providecommand{\DefineSpuriousJournalWord}[1]{%
\expandafter\def\csname journal@abbrv@#1\endcsname{%
\@gobble@space@true%
\journal@output@space%
}%
}
\DefineSpuriousJournalWord{of}
\DefineSpuriousJournalWord{in}
\DefineSpuriousJournalWord{and}
\DefineSpuriousJournalWord{the}


I suppose if one could solve the problem by making a "special case" for the space after such a word (though it does not help with or explain why there is also an extra space at the beginning of the journal title), my limited LaTex coding skill did not allow me quite come up with a solution.

• Welcome to tex.sx. I'm far from expert regarding .bst files, but it seems to me that \@gobble@space@true operates in the "forward" direction, whereas it's the preceding space that is relevant. That would call for something more like \unskip. Also, but irrelevant. the % on that line and the next shouldn't be necessary. (Others are.) Mar 18 at 18:20

Following @barbara beeton's comment, I messed around with the code and came up with the following partial solution, despite still not understanding it.

It seems the problem is with an extra space being generated before each journal word, so using \unskip to delete that space works around the problem. However, if there is a special character (e.g. an underscore _ or a SpuriousJournalWord such as "of") before the last word of the journal title, there is not an extra space, and deleting one would leave no space behind. I do yet not know how to deal with the problem.

Here are lines 411-450 from jabbrv.sty, with modification on line 422 (% <- Originally...):

% Output the correct abbreviation for a title word
\def\journal@output@abbrv{%
\if@special@period@%
\journal@abbrv@period%
\else%
\if@no@space@%
.% There was a user-entered period with no space after it
\else%
\unskip\journal@output@space% <- Originally \journal@output@space
\fi%
\@jabbrv@match@found@false%
\expandafter\ifx\csname journal@abbrv@\the\temp@journal@text\endcsname\relax%
\expandafter\ifcsname journal@word@exception@\the\temp@journal@text\endcsname%
\expandafter\csname journal@word@exception@\the\temp@journal@text\endcsname%
\@jabbrv@match@found@true%
\else%
\journal@output@abbrv@partial%
\fi%
\else%
% Replace with abbreviation
\expandafter\csname journal@abbrv@\the\temp@journal@text\endcsname%
\@jabbrv@match@found@true%
\fi%
\if@jabbrv@match@found@%
% A match was output, do nothing.
\else%
% No known abbreviation
\if@warn@noabbrv@%
\@latex@warning{No abbreviation defined for \the\temp@journal@text'}%
\fi%
\begingroup%
\jabbrv@normal@diacritic%
\the\temp@journal@text%
\endgroup%
\global\@end@period@false % reset the "need a period at the end" indicator
\@gobble@space@false%
\fi%
\fi%
\@special@period@false%
}
`