\newcommand\gobble[1]{}
and replace each occurrence of
gobbletwo
with gobble
.Regards
\newcommand\gobble[1]{}
gobbletwo
with gobble
.\gobbletwo
command to a command \gobbleone
that eats only the first argument but spits out the second.\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}
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\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 definition\newcommand\gobbleone[1]{}
\gobble
) or\newcommand\secondoftwo[2]{#2}
cgnieder wrote: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.
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.....
\seeonly
rather than |seeonly
inside the \index
parameter? \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}
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.\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)".
\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}
\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 translate
\index{additive identity@\adjtext{additive identity}%
|seeonly{zero elements}}
\seeonly
s in the index. Perhaps someone else can succeed with that.
\newcommand{\SeeOnly}[2]{\index{#1@\protect\adjtext{#1}|seeonly{#2}}}
\seeonly
and \adjtext
are as previously, does all that is aked of it.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.Return to “MakeIndex, Nomenclature, Glossaries and Acronyms”
Users browsing this forum: No registered users and 3 guests