朋友们,作为后续重叠的 TikZ 节点看起来像胶带条,我使用该包将 TikZ 代码添加到索引条目中splitidx
。考虑以下代码:
\documentclass{article}
\usepackage[useindex]{splitidx}
\newindex[Index of Foo]{iof}
\makeindex
\usepackage{tikz}
\usetikzlibrary{chains,backgrounds}
\usepackage{xstring}
\tikzset{
tape node/.style={
on chain,
draw,
inner sep=1pt,
outer xsep=0pt,
minimum height=0.2cm,
minimum width=0.2cm
}
}
\newcommand*\myblackbox[1]{%
\node[
tape node
] {\tiny\tt\raisebox{0pt}[\height][0pt]{#1}};
}
\newcommand*\mygraybox[1]{%
\begin{pgfonlayer}{background}
\node[
tape node,
gray!60
] {\color{gray!60}\tiny\tt\raisebox{0pt}[\height][0pt]{#1}}; \end{pgfonlayer}
}
\DeclareRobustCommand*\drawboxes[1]{%
\begin{tikzpicture}[
start chain=going right,
node distance=0pt
]
\IfSubStr{#1}{A}{\myblackbox{A}}{\mygraybox{A}}%
\IfSubStr{#1}{N}{\myblackbox{N}}{\mygraybox{N}}%
\IfSubStr{#1}{C}{\myblackbox{C}}{\mygraybox{C}}%
\IfSubStr{#1}{Q}{\myblackbox{Q}}{\mygraybox{Q}}%
\IfSubStr{#1}{P}{\myblackbox{P}~}{\mygraybox{P}~}
\end{tikzpicture}
}
\begin{document}
\sindex[iof]{\drawboxes{AC} Oranges}
\sindex[iof]{\drawboxes{ANCQ} Grapes}
\sindex[iof]{\drawboxes{CP} Bananas}
\sindex[iof]{\drawboxes{Q} Avocado}
\sindex[iof]{\drawboxes{P} Strawberry}
\printindex*
\end{document}
它非常有效,但不幸的是,由于在条目开头添加了 TikZ 代码,字母顺序丢失了:
我有一个大胆的猜测:通过将一些正则表达式模式传递给splitindex
解析器工具,我可以以某种方式让生成的索引忽略条目开头的 TikZ 代码。
如果可能的话,我想继续使用该splitidx
软件包,因为它可以处理文档中的多个索引。任何帮助都值得感激。
答案1
这是标准的制作索引句法:
\sindex[iof]{Oranges@\drawboxes{AC} Oranges}
\sindex[iof]{Grapes@\drawboxes{ANCQ} Grapes}
\sindex[iof]{Bananas@\drawboxes{CP} Bananas}
\sindex[iof]{Avocado@\drawboxes{Q} Avocado}
\sindex[iof]{Strawberry@\drawboxes{P} Strawberry}