Code: Select all
\newcommand\gobble[1]{}
gobbletwo
with gobble
.Regards
Code: Select all
\newcommand\gobble[1]{}
gobbletwo
with gobble
.\gobbletwo
command to a command \gobbleone
that eats only the first argument but spits out the second.Code: Select all
\documentclass{article}
\usepackage{makeidx}
\makeindex
\newcommand\gobbleone[2]{#2}
\newcommand*{\seeonly}[2]{(\emph{see} #1)}
\newcommand*{\also}[2]{(\emph{see also} #1)}
\newcommand{\Also}[2]{\emph{See also} #1}
\begin{document}
This is a short book. It's about zero.
\index{zero elements}
\index{zero \seeonly{zero elements}|gobbleone}
\index{additive identity \seeonly{zero elements}|gobbleone}
\index{additive subtraction}
Therefore, it's also about nothing.
\index{nothing}
\index{nothing!zz@\Also{zero elements}|gobbleone}
Which means null.
\index{null}
\index{nothing!nil}
\index{nothing!null}
\index{nothing!nil!zz@\also{null elements}|gobbleone}
\index{nil elements}
\index{null elements}
That's the same as zilch.
\index{zilch}
\index{zilch!zero}
\index{zilch!zz@\Also{nothing}|gobbleone}
\newpage
Another name for zilch is nil.\index{zilch}Good grief!\index{zounds}
\printindex
\end{document}
This is essentially the same as my suggestion. I'd favor mine as it doesn't read in the next token first just to reuse it. One remark regarding semantics:murraye wrote:I think I finally figured out, but would welcome suggestions for improvement or additional test cases. I changed the\gobbletwo
command to a command\gobbleone
that eats only the first argument but spits out the second.
\gobble
and \gobbletwo
are the the same as the LaTeX kernel commands \@gobble
and \@gobbletwo
. That's why I chose the names. \gobbleone
reflects its purpose even more, I think. I could have used
Code: Select all
\makeatletter
\let\gobble\@gobble% or
\let\gobbletwo\@gobbletwo% respectively
\makeatother
\gobbleone
, however, is exactly the same as the LaTeX kernel command \@secondoftwo
. In order to use a semantically meaningful command you should use the definitionCode: Select all
\newcommand\gobbleone[1]{}
\gobble
) orCode: Select all
\newcommand\secondoftwo[2]{#2}
Yes, your solution is better. Again, since your post was so short and to-the-point compared with mine, I had just missed it when posting that longer solution of mine. Thanks for the follow-up!cgnieder wrote:This is essentially the same as my suggestion. I'd favor mine as it doesn't read in the next token first just to reuse it.....murraye wrote:I think I finally figured out, but would welcome suggestions for improvement or additional test cases. I changed the\gobbletwo
command to a command\gobbleone
that eats only the first argument but spits out the second.
\seeonly
rather than |seeonly
inside the \index
parameter? Code: Select all
\documentclass{article}
\newcommand{\seeonly}[2]{(\emph{see} #1)}
\usepackage{makeidx}\makeindex
\begin{document}
This is a very short book. It's about zero.\index{zero elements}
\index{zero|see{zero elements}}
\index{additive identity|seeonly{zero elements}}
\printindex
\end{document}
No, your code produces an unwanted comma in the index entry for "additive identity", between "additive identity" and the parenthesized reference "(see zero elements)".extal wrote:I have just seen your query today while investigating MakeIndex myself.
Is not your error to use \seeonly rather than |seeonly inside the \index parameter?
The following works well for me.Code: Select all
\documentclass{article} \newcommand{\seeonly}[2]{(\emph{see} #1)} \usepackage{makeidx}\makeindex \begin{document} This is a very short book. It's about zero.\index{zero elements} \index{zero|see{zero elements}} \index{additive identity|seeonly{zero elements}} \printindex \end{document}
Murraye you are quite correct. The original post did not mention an unwanted comma (,) after the index entry merely an unwanted page number. I should have read the thread further and more carefully to see that you had made my suggestion already and that that had been rejected on the grounds of the superfluous comma.No, your code produces an unwanted comma in the index entry for "additive identity", between "additive identity" and the parenthesized reference "(see zero elements)".
Code: Select all
\documentclass{article}
\usepackage{makeidx}
\newcommand{\seeonly}[2]{(\emph{see} #1)}
\newcommand{\adjtext}[2]{#1}
\makeindex
\begin{document}
This is a very short book. It's about zero.\index{zero elements}
\index{zero|see{zero elements}}
\index{additive identity@\adjtext{additive identity}|seeonly{zero elements}}
\pagebreak\\
zero\index{zero elements}
\printindex
\end{document}
Code: Select all
\begin{theindex}
\item \adjtext{additive identity}, \seeonly{zero elements}{1}
\indexspace
\item zero, \see{zero elements}{1}
\item zero elements, 1, 2
\end{theindex}
\adjtext
seems to kill. I have not been able to translateCode: Select all
\index{additive identity@\adjtext{additive identity}%
|seeonly{zero elements}}
\seeonly
s in the index. Perhaps someone else can succeed with that.Code: Select all
\newcommand{\SeeOnly}[2]{\index{#1@\protect\adjtext{#1}|seeonly{#2}}}
\seeonly
and \adjtext
are as previously, does all that is aked of it.Code: Select all
delim_0 ""
delim_1 ""
delim_2 ""
\makeindex
as explained in the usual LaTeX documentation. This, however, will get rid of text-following commas for all index entries at all levels.