以下代码中的 \indextriple 对大多数操作数都有效,但当其中一个操作数扩展为包含符号 \epi 或 \mon 时,它会失败。
错误信息
! 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$}}
从代码中
\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}
答案1
那是远的从一个最小的例子:-)但无论如何问题是扩展,\into
因此您可以使用它成为一个强大的命令
\DeclareRobustCommand\into {\!\mon}
代替\newcommand
答案2
\into
不够强大并且需要保护,因为索引宏使用非逐字模式。
\indextriple%
{Symbols}%
{into1@\textbackslash into}%
{into2@$\protect\into$}
该.idx
文件包含:
\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}
该命令也可以使用打字机字体\into
:
\indextriple%
{Symbols}%
{into1@{\textbackslash into}}%
{into2@$\protect\into$}
结果
\usepackage[T1]{fontenc}% text font for \textbackslash
\usepackage[variablett]{lmodern}% variable width typewriter font