4

How might the commas between "phrases" and "see words" be suppressed in the printed index produced from the source below?

\documentclass{book}
\usepackage{makeidx}
\makeindex

\begin{document}

Some words.
\index{words}
\index{phrases|see{words}}

\printindex

\end{document}

I'm aware from (http://latex-community.org/forum/viewtopic.php?f=51&t=21464) that one way to do that is:

\documentclass{book}
\usepackage{makeidx}
\makeindex

\newcommand{\seeonly}[2]{(\emph{see} #1)}
\newcommand\gobble[2]{}

\begin{document}

Some words.
\index{words}
\index{phrases \seeonly{words}|gobble}

\printindex

\end{document}

However, I'd like a method that does not require adding within each such "see" index entry any explicit code (such as |gobble) to suppress the comma. Rather, I seek some way to modify the definition of \seeonly itself.

The object is to simplify typing such cross-references in the source document.

(The question is related to: Change index "see also" and "see" format.)

4

1 Answer 1

2

Adapting the answer here:

We can define an index delimiter to be a macro which tests whether it is followed by the \see or the \seealso command. This eliminates the need for different indexing commands as in the answer here: Change index "see also" and "see" format

\documentclass{book}
\begin{filecontents}{\jobname.mst}
delim_0 "\\idxdelim"
delim_1 "\\idxdelim"
delim_2 "\\idxdelim"
\end{filecontents}
\usepackage{makeidx}
\makeindex
\makeatletter
\def\idxdelim{\@ifnextchar{\see}{\space}{\@ifnextchar{\seealso}{\space}{, \space}}}

\makeatother
\begin{document}

Some words. A test.
\index{words}
\index{phrases|see{words}}
\index{sentences|seealso{words}}

\printindex

\end{document}

output of index

You must log in to answer this question.

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