Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question

3 Answers 3

up vote 5 down vote accepted

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.

share|improve this answer
    
+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:

enter image description here

The result with the modification:

enter image description here

\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}
share|improve this answer

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 "?".

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.