1

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.

1
  • 2
    Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – albert
    Aug 21, 2018 at 10:08

1 Answer 1

2

You have to use a suitable index style, where the standard delimiter, a comma followed by a space, is changed into a macro that adds the comma only if no punctuation comes along.

\begin{filecontents*}{athel.ist}
delim_0 "\\possiblecomma "
delim_1 "\\possiblecomma "
delim_2 "\\possiblecomma "
\end{filecontents*}

\documentclass{book}
\usepackage{imakeidx}
\usepackage{amsthm} % for \@addpunct

\makeindex[options=-s athel]

\makeatletter
\newcommand{\possiblecomma}{\@addpunct{,} }
\makeatother

\begin{document}

Here we index that title\index{whatislife@\textit{What is life?}}

We also index another entry\index{normal}

\printindex

\end{document}

enter image description here

2
  • Thanks. That worked fine (once I figured out how to incorporate it into my file). I thought there was a button to say"Yes. That answered my question", but I don't find it.
    – Athel
    Aug 21, 2018 at 11:44
  • @Athel You should see a dimmed checkmark next to the arrows for voting
    – egreg
    Aug 21, 2018 at 13:18

You must log in to answer this question.

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