0

The \indextriple in the code below works for most operands, but it fails when one of the operands expands to contain the symbol \epi or \mon.

Error message

! Use of \@index doesn't match its definition.
\ifnextchar ...t \reserved@d =#1\def \reserved@a {
                                                  #2}\def \reserved@b {#3}\f...
l.106       {into2@{$\into$}}

from the code

\documentclass[draft]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{bm}
\usepackage{enumitem}
\usepackage{ifthen}
\usepackage{longtable}
\usepackage{indextools}
\usepackage{mathtools}
\usepackage{multicol}
\usepackage{needspace}
\usepackage{scalerel}
\usepackage{supertabular}
\usepackage{thmtools}
\usepackage{tikz-cd}
\usepackage{varioref}
\usepackage{xparse} % loads expl3
%See interface3.pdf
\usepackage{xstring}
\usepackage[cmtip,all,barr]{xy}

%Remove when xybarr.tex bug fixed
\newdir_{ (}{{ }*!/-.5em/@_{(}}

% Select font for functions and sequences of functions
\newcommand \funcname [1] {\mathit{#1}}
\newcommand \funcseqname [1] {\bm{#1}}

\DeclareMathOperator \Functor {\mathop{\mathcal{F}}}

\DeclareMathOperator \head {\mathrm{head}}

\DeclareMathOperator \Hom {\mathrm{Hom}}

\DeclareMathOperator \Id {\mathrm{Id}}

\DeclareMathOperator \ID {\mathbf{Id}}

% suppress verbatim for \index
\newcommand \indexfold [1] {\index{#1}}

% Generate paired subindex entries
\newcommand \indexpair [2] {\index{#1!#2}\index{#2!#1}}

% Generate paired subsubindex entries 2!3, 3!2, 1!2!3, 1!3!2
\newcommand \indextriple [3]%
  {%
    \index{#2!#3}%
    \index{#3!#2}%
    \index{#1!#2!#3}%
    \index{#1!#3!#2}%
  }

\newcommand \into {\!\mon}

\usepackage[colorlinks,hidelinks,draft=false]{hyperref}

\usepackage{cleveref}
\hypersetup {
   colorlinks,
   pdfinfo={
      Author={Shmuel (Seymour J.) Metz},
      Keywords={fiber bundles,manifolds},
      Subject={Topology},
      Title={A guide to my private preamble macros}
   }
}
\usepackage[final]{showlabels}
\showlabels{cite}
\showlabels{cref}
\showlabels{crefrange}

\makeindex

\begin{document}

\section {Symbols}

\begin{longtable}[t]{| l | l | p{2.9in} |}
  \hline
  \multicolumn{3}{|c|}{\small\sl continued from previous page} \\
  \hline
  Macro & Rendering & Meaning \\
  \hline
\endhead
  \hline
  Macro & Rendering & Meaning \\
  \hline
\endfirsthead
  \hline
  \multicolumn{3}{|c|}{Symbols} \\
  \multicolumn{3}{|c|}{\small\sl continued on next page} \\
  \hline
\endfoot
  \hline
  \caption{Symbols}
\endlastfoot
  {\textbackslash}into
& $\into$
& Separate domain from range for monomorphism:
  $\backslash\mathrm{funcname}\{\mathrm{f}\}\  \backslash\mathrm{maps}\ \mathrm{A}\ \backslash\mathrm{into}\ \mathrm{B}$
\indextriple%
  {Symbols}%
  {into1@{\textbackslash}into}%
  {into2@{$\into$}}
\\
\hline
\end{longtable}

\printindex

\end{document}
2
  • do you really use all those packages in a single document? Apr 11, 2018 at 20:03
  • Yes, but that document is over 100 pages long.
    – shmuel
    Apr 11, 2018 at 20:20

2 Answers 2

2

that was far from a minimal example:-) but anyway the problem is the expansion of \into so you can make it a robust command by using

\DeclareRobustCommand\into {\!\mon}

instead of \newcommand

2

\into is not robust and needs protection, since the index macros are using non-verbatim mode.

\indextriple%
  {Symbols}%
  {into1@\textbackslash into}%
  {into2@$\protect\into$}

The .idx file contains:

\indexentry{into1@\textbackslash into!into2@$\into $|hyperpage}{1}
\indexentry{into2@$\into $!into1@\textbackslash into|hyperpage}{1}
\indexentry{Symbols!into1@\textbackslash into!into2@$\into $|hyperpage}{1}
\indexentry{Symbols!into2@$\into $!into1@\textbackslash into|hyperpage}{1}

Also a typewriter font is possible for the command \into:

\indextriple%
  {Symbols}%
  {into1@{\textbackslash into}}%
  {into2@$\protect\into$}

Result with

\usepackage[T1]{fontenc}% text font for \textbackslash
\usepackage[variablett]{lmodern}% variable width typewriter font

Index

2
  • \into and \onto are intended for use in math mode; I would rarely, if ever, want a typewriter font.
    – shmuel
    Apr 11, 2018 at 20:24
  • @shmuel The typewriter font was not referring to math mode, but to the macro text representation (\into) and not the math symbol generated by the macro. But font choices are a matter of taste. Apr 11, 2018 at 20:45

You must log in to answer this question.

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