# newcommand and index

I want to have an index entry referencing to another entry withought adding a comma. I currently do this with:

\newcommand{\gobblecomma}[1]{}


And then in the text itself when an entry occurs:

\index{<Entry>!{}\gobblecomma@|seealso{<AlsoEntry>}}


This above part produces exactly the index format I am looking for. However, since this is a rather long bit for the second line to type each time in my text where I have such an entry I want to shorten this. I tried to use:

\newcommand{\gobblecomma}[1]{}
\newcommand{\alsoindex}[2]{\index{#1!{}\gobblecomma@|seealso{#2}}}


and then in the text itself:

\alsoindex{<Entry>}{<AlsoEntry>}


However, this completely ignores the "\gobblecomma@" part. How can I solve this? Compilable it looks like this:

\documentclass[10pt, twoside, a4paper, twocolumn, openany, makeidx]{book}

\usepackage[totoc, initsep=0pt, columns=4]{idxlayout}
\usepackage{makeidx}

\newcommand{\gobblecomma}[1]{}
\newcommand{\alsoindex}[2]{\index{#1!{}\gobblecomma@|seealso{#2}}}
\makeatother
\makeindex

\begin{document}

random text entry

\index{Entry}
\alsoindex{Entry}{Alsoentry}

random other entry text

\index{Otherentry}
\index{Otherentry!{}\gobblecomma@|seealso{Alsoentry}}

more random text

\clearpage
\printindex

\end{document}


The difference is just in the presence of the comma before the "see also" in the end result.

• Welcome to TeX.SE! Can you please make your code snippets compilable ... – Mensch Aug 14 '17 at 18:55
• \string\gobblecomma@ – David Carlisle Aug 14 '17 at 19:14