10

I have a line that says \index{flamingo's ``knee''}. As one would expect, it produces an entry

flamingo’s “knee”, 3

in the index. Unfortunately the publisher wants it to be

flamingo’s “knee,” 3

and I haven’t succeeded in getting that. If I change \index{flamingo's ``knee''} to \index{flamingo's ``knee,''} I get two commas:

flamingo’s “knee,”, 3

How can I get rid of the second comma in this entry only, while not affecting any entries that don’t contain quotation marks?

1 Answer 1

11

Interesting question!

\documentclass{book}
\usepackage{imakeidx}

\makeindex

\newrobustcmd{\invertcomma}[2]{#2#1}

\begin{document}

Flamingo's ``knee''\index{flamingosknee@flamingo's ``knee\invertcomma{''}}

\printindex

\end{document}

enter image description here

4
  • 6
    but misguided publisher. Mar 16, 2016 at 14:14
  • 2
    @barbarabeeton Certainly so!
    – egreg
    Mar 16, 2016 at 14:20
  • I have a question that is similar, but different. I want to index the name of a book that ends in a question mark. What I get is \textit{What is Life?}, 27, but what I'd like is \textit{What is Life?} 27. In other words I want to suppress the comma. Only when I've succeeded in doing it will I know if it looks better like that.
    – Athel
    Aug 21, 2018 at 7:41
  • @Athel This should be a new question.
    – egreg
    Aug 21, 2018 at 8:33

You must log in to answer this question.

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