# Remove comma after title ending with questionmark

I am using a bit modified bibtex style but with quite common base. It is based on utphys 2.7 which is based on "IEEE Transactions bibliography style (29-Jan-88 version)"

I'd like to remove comma after titles ending with question marks. Some automated hack will do. (Not changing the bbl)

Bibtex entery is as follows:

@article{EPR35,
author = {Einstein, A. and Podolsky, B. and Rosen, N.},
title = {Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?}
}


And corresponding output is like:

A. Einstein, B. Podolsky ja N. Rosen, “Can quantum-mechanical description of physical reality be considered complete?,” Phys. Rev. 47 (May, 1935) 777–780. 5, 8

Bibtex style is at http://pastebin.com/h8in9BZU

-

The makebst package has a nice function to test whether the last character of a string is one of ! ? .":

FUNCTION {non.stop}
{ duplicate$"}" * add.period$
#-1 #1 substring$"." = }  Then you can write an add.comma function that tests that: FUNCTION {add.comma} { non.stop { "," * } 'skip$
if$}  Use this add.comma function in places where you want the conditional comma. - +1 Nice. I was playing with using add.period$ as a base for my function, but couldn't get it working in all cases. It's obvious now that I see how to do it! –  Simon Jan 16 '13 at 22:20

I think on solution could be to redefine the question marks local by setting:

\catcode?=\active


To provide a mwe I saved your linked bst-file with the name utphys.bst. You should avoid spaces or other special characters inside your filename. (I think a dot is also wrong)

In the example below I defined a new if-function to which will be true after a question mark. If this function is true no comma will be printed.

The result without the redefinition:

The result with the modification:

\documentclass{article}
\usepackage{filecontents}
\begin{filecontents*}{references.bib}
@article{EPR35,
author = {Einstein, A. and Podolsky, B. and Rosen, N.},
title = {Can Quantum-Mechanical Description of Physical Reality Be Considered Complete?}
}

\end{filecontents*}

\begin{document}
\cite{EPR35}

\begingroup
\newif\ifgobblecomma
\gobblecommafalse %default
\edef\FZ{?}
\edef\KM{,}
\catcode?=\active
\catcode,=\active
\def?{\FZ\gobblecommatrue}
\def,{\ifgobblecomma\gobblecommafalse\else\KM\fi}
\bibliographystyle{utphys}
\bibliography{references}
\endgroup
\end{document}

-

I'm also using a modified utphys.sty style. A quick hack that I use to remove the extra commas in the titles is to define the following function in the style file:

INTEGERS{steps}
FUNCTION {add.comma$} { #-1 'steps := {duplicate$ steps #1 substring$"}" =} {steps #1 - 'steps := } while$
duplicate$steps #1 substring$ "?" =
{"" *}  % string ended in ? so don't do anything skip${"," *} % string didn't end in ? so add a comma if$
}


Then, the only change to the format.title function is to insert a call to add.comma$ FUNCTION {format.title} { title empty$
{ "" }
{"" title "t" change.case$* add.comma$ "''" * }
if$}  This is good enough for my bibliography, however the add.comma$ function only does the bare minimum it that it needs in order to work in my case. It should probably be made more robust so that it works with whitespace and punctuation other than "?".

-