(第二篇帖子)以下是更新后的代码,它显示,在注释索引包时,我在索引中为术语 alldifferent 获得了两个单独的条目(一个用于定义,一个用于出现)。但是,如果我放入索引包,我只会获得 alldifferent 的一个条目(应该如此),但我再也得不到解释性文本了。
\documentclass[]{book}
\usepackage{etex}
\usepackage{makeidx}
\usepackage[totoc,columns=1]{idxlayout}
%\usepackage{index}
\usepackage[plainpages=false,pdfpagelabels,colorlinks,linkcolor=cyan,citecolor=cyan,urlcolor=cyan,bookmarks,hyperindex=false,pagebackref=true]{hyperref}
\sloppy
\makeindex
\newcommand*{\indexuse}[1]{\hyperpage{#1}}
\newcommand*{\indexdef}[1]{\textbf{\hyperpage{#1}}}
\newcommand*{\indexsyn}[1]{\textbf{\textit{\hyperpage{#1}}}}
\def\constraint#1{\textsc{#1}}
\def\ctrref#1{$\constraint{#1}$\index{#1@$\constraint{#1}$|indexuse}}
\pagestyle{headings}
\begin{document}
\pagenumbering{Alph}% to avoid spurious warnings
\title{\Huge Title}
\author{toto}
\maketitle
\thispagestyle{empty}
\frontmatter
\tableofcontents
\chapter{Preface}
abc abc
toto \index{toto|indexuse}
def
\index{alldifferent@$\constraint{alldifferent}$|indexdef}
\mainmatter
\chapter{First chapter}
tutu \index{tutu|indexuse}
titi \index{titi|indexuse}
aaa aaa \index{toto|indexdef} bbb
tutu \index{tutu|indexdef}
titi \index{titi|indexdef}
\index{toto|indexsyn}
\ctrref{alldifferent}
\setindexprenote{%
Page numbers in bold face (as in \textbf{160}) point to a definition
of a constraint, keyword, restriction or system. Page numbers in
bold-italic face (as in \textbf{\textit{160}}) notify an abbreviation
of a constraint name. Finally, page numbers in serif face (as in 160)
indicate an occurrence of constraint name, keyword, system or author name.%
}
\printindex
\end{document}
(初始帖子)当将 makeidx 与 book 类一起使用时,有没有办法在索引页中添加一段解释性小文本(请注意,由于我使用的是 .ist 样式文件,因此我更喜欢使用 makeidx 而不是使用某些帖子中建议的 splitidx 或 imakeidx 包;因为我还使用 book 类,所以我不想按照其他帖子中的建议切换到 memoir 类)。
由于我不完全确定应该在哪里添加您建议的代码,因此我添加了一个可以编译的文档小示例:
\documentclass[]{book}
\usepackage{makeidx}
\usepackage{index}
\usepackage[plainpages=false,pdfpagelabels,colorlinks,linkcolor=cyan,
citecolor=cyan,urlcolor=cyan,bookmarks,
hyperindex=false,pagebackref=true]{hyperref}
\sloppy
\makeindex
\newcommand*{\indexuse}[1]{\hyperpage{#1}}
\begin{document}
\pagestyle{headings}
\title{\Huge Title}
\author{toto}
\maketitle
\thispagestyle{empty}
\frontmatter
\chapter{Preface}
abc abc
toto \index{toto|indexuse}
def
\mainmatter
\chapter{First chapter}
tutu \index{tutu|indexuse}
titi \index{titi|indexuse}
\cleardoublepage
\markboth{INDEX}{INDEX}
\phantomsection
\addcontentsline{toc}{chapter}{Index}
% Page numbers in bold face (as in \textbf{160}) point to a definition
% of a constraint, keyword, restriction or system. Page numbers in
% bold-italic face (as in \textbf{\textit{160}}) notify an abbreviation
% of a constraint name. Finally, page numbers in serif face (as in 160)
% indicate an occurrence of constraint name, keyword, system or author name.
\printindex
\end{document}
最后,catalog.ist 文件包含以下几行:
preamble "\\begin{theindex} {\\small\\onecolumn\\newcounter{idxl}\n"
postamble "\n\n} \\end{theindex} \n"
group_skip "\n\n \\vspace*{12mm}\n"
heading_prefix "{
\\bfseries\\Large\\hfill "
heading_suffix "\\hfill}\\nopagebreak\\vspace*{4mm}\\stepcounter{idxl}\n"
symhead_positive "1..."
headings_flag 1
答案1
您可以使用idxlayout
,这样也可以避免发出\onecolumn
。这是修复后的.ist
文件:
preamble "\\begin{theindex} \\small\\newcounter{idxl}\n"
postamble "\n\n \\end{theindex} \n"
group_skip "\n\n \\vspace*{12mm}\n"
heading_prefix "{\\bfseries\\Large\\hfill "
heading_suffix "\\hfill}\\nopagebreak\\vspace*{4mm}\\stepcounter{idxl}\n"
symhead_positive "1..."
headings_flag 1
这是示例,其中我填充了索引来显示标题和目录中的条目如何符合需要。
\documentclass[]{book}
\usepackage{makeidx}
%\usepackage{index} % do you need it?
\usepackage[totoc,columns=1]{idxlayout}
\usepackage[
plainpages=false,
pdfpagelabels,
colorlinks,
linkcolor=cyan,
citecolor=cyan,
urlcolor=cyan,
bookmarks,
hyperindex=false,
pagebackref=true,
]{hyperref}
\sloppy
\makeindex
\newcommand*{\indexuse}[1]{\hyperpage{#1}}
\pagestyle{headings}
\begin{document}
\pagenumbering{Alph}% to avoid spurious warnings
\title{\Huge Title}
\author{toto}
\maketitle
\thispagestyle{empty}
\frontmatter
\tableofcontents
\chapter{Preface}
abc abc
toto \index{toto|indexuse}
def
\mainmatter
\chapter{First chapter}
tutu \index{tutu|indexuse}
titi \index{titi|indexuse}
% populate the index
\count255=0
\loop\ifnum\count255<200
\advance\count255 1
\expandafter\index\expandafter{\romannumeral\count255|indexuse}
\repeat
\setindexprenote{%
Page numbers in bold face (as in \textbf{160}) point to a definition
of a constraint, keyword, restriction or system. Page numbers in
bold-italic face (as in \textbf{\textit{160}}) notify an abbreviation
of a constraint name. Finally, page numbers in serif face (as in 160)
indicate an occurrence of constraint name, keyword, system or author name.%
}
\printindex
\end{document}
答案2
您不需要任何特殊的包。makeindex
只需将\begin{theindex}
...写入文件\end{theindex}
中.ind
,这样您只需定义该环境即可执行任何您想要的操作这是 article.cls 中的定义,其中添加了一段文本
\renewenvironment{theindex}
{\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\twocolumn[\section*{\indexname}
this is a paragraph spanning a 2-column index
a second paragraph
]%
\@mkboth{\MakeUppercase\indexname}%
{\MakeUppercase\indexname}%
this is a paragraph in the first column of the index
\thispagestyle{plain}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\columnseprule \z@
\columnsep 35\p@
\let\item\@idxitem}
{\if@restonecol\onecolumn\else\clearpage\fi}
在您稍后添加的示例上下文中看到这一点,请注意我group and
从 ist 文件中删除了错误的 \clearpage`。
文档
\documentclass[]{book}
\usepackage{makeidx}
\usepackage{index}
\usepackage[plainpages=false,pdfpagelabels,colorlinks,linkcolor=cyan,
citecolor=cyan,urlcolor=cyan,bookmarks,
hyperindex=false,pagebackref=true]{hyperref}
\sloppy
\makeindex
\makeatletter
\newcounter{idxl}
\renewenvironment{theindex}
{\if@twocolumn
\@restonecolfalse
\else
\@restonecoltrue
\fi
\twocolumn[\section*{\indexname}
this is a paragraph spanning a 2-column index
a second paragraph
]%
\@mkboth{\MakeUppercase\indexname}%
{\MakeUppercase\indexname}%
this is a paragraph in the first column of the index
\thispagestyle{plain}\parindent\z@
\parskip\z@ \@plus .3\p@\relax
\columnseprule \z@
\columnsep 35\p@
\let\item\@idxitem}
{\if@restonecol\onecolumn\else\clearpage\fi}
\makeatother
\newcommand*{\indexuse}[1]{\hyperpage{#1}}
\begin{document}
\pagestyle{headings}
\title{\Huge Title}
\author{toto}
\maketitle
\thispagestyle{empty}
\frontmatter
\chapter{Preface}
abc abc
toto \index{toto|indexuse}
def
\mainmatter
\chapter{First chapter}
tutu \index{tutu|indexuse}
titi \index{titi|indexuse}
\cleardoublepage
\markboth{INDEX}{INDEX}
\phantomsection
\addcontentsline{toc}{chapter}{Index}
% Page numbers in bold face (as in \textbf{160}) point to a definition
% of a constraint, keyword, restriction or system. Page numbers in
% bold-italic face (as in \textbf{\textit{160}}) notify an abbreviation
% of a constraint name. Finally, page numbers in serif face (as in 160)
% indicate an occurrence of constraint name, keyword, system or author name.
\printindex
\end{document}
是
preamble "\\begin{theindex}
postamble "\n\n} \\end{theindex} \n"
group_skip "\n\n \\vspace*{12mm}\n"
heading_prefix "{
\\bfseries\\Large\\hfill "
heading_suffix "\\hfill}\\nopagebreak\\vspace*{4mm}\\stepcounter{idxl}\n"
symhead_positive "1..."
headings_flag 1