Home

The idxcmds package

When working on a larger document and designing and writing the macros for various bits and pieces I was going to use I found myself repeatedly writing the same kind of macros again and again that had some kind of semantic meaning, maybe some markup definitions that also created an index entry and had a star form for omitting the index entry. They all had more or less the following structure:

\makeatletter
\newcommand*\cmd{\@ifstar\cmd@star\cmd@nostar}
\newcommand*\cmd@star[1]{\cmd@base{#1}}
\newcommand*\cmd@nostar[1]{\cmd@base{#1}\cmd@idx{#1}}
\newcommand*\cmd@base[1]{\textit{#1}}
\newcommand*\cmd@idx[1]{\index{#1@\cmd@base{#1}}}
\makeatother

After having copied and pasted this code for the fourth time I thought: you should have a command that does this for you. That was when \newidxcmd was born. This command soon enough got some extensions, e.g., giving the commands thus defined an optional argument that allowed specifying the sorting. It wasn't long before I realized that I might want to use this \newidxcmd again in other documents which was when I wrote the first draft of this package.

I added other commands, \newsubmainidxcmd and \newsubidxcmd, which I didn't (and still don't) really use or need but of which I thought they could be useful for others, and here we are.

Updated

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.