如何為索引頁新增說明文字?

如何為索引頁新增說明文字?

注意:有關任何索引生成包的答案都是有益的,例如splitidx或預設值makeidx

我看過一些書的索引頁上有解釋文字指數標題但在實際索引列表之前。如何在不手動修改.idx.ind文件的情況下完成此操作?不幸的是,該命令printindex似乎無法執行。

這是一個足夠但令人遺憾的小例子:

在此輸入影像描述

這是使用該套件的 MWE makeidx

\documentclass[12pt]{book}
\usepackage{makeidx}\makeindex
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\index{1@One makeidx entry!With a subentry}

%How to put text on the following index page?
\printindex
%Be sure to run: makeindex <filename>


\end{document}

這是一個使用該套件splitidx並建立兩個索引的 MWE:

\documentclass[12pt]{book}
\usepackage[split]{splitidx}\makeindex
    \newindex{firstindex}
    \newindex{secondindex}
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\sindex[firstindex]{1@One splitindex entry!Using firstindex}
\sindex[secondindex]{Another splitindex entry!Using secondindex}

%How to put text on the following index pages?
\printindex[firstindex][A splitindex: firstindex]
\printindex[secondindex][A splitindex: secondindex]
%Be sure to run: makeindex <filename>-firstindex; makeindex <filename>-secondindex

\end{document}

答案1

使用包imakeidx代替makeidx。該軟體包更加強大並且允許:

  • 多列索引\makeindex[columns=n]

  • 之前的文字指數以及之後的標題\indexprologue{Text ...}。該指令必須正好放在 之前\printindex

  • 自動運行makeindex

  • 支持splitindexMarkus Kohm 的腳本。

  • 其描述的其他選項文件

範例 MWE

\documentclass[12pt]{book}
\usepackage{imakeidx}\makeindex
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\index{1@One entry!With a subentry}~\index{a@Other entry}
\indexprologue{\noindent How to put text on the following index page?}
\printindex


\end{document}

也可以使用此套件產生多個索引。在這種情況下,您必須使用選項載入套件並在和上splitindex運行(如果和是索引的名稱)。或使用或選項自動運行此操作。makeindex<filename>-firstindex<filename>-secondindexfirstindexsecondindexpdflatex--enable-write18-shell-escape

筆記:沒有必要為所有索引命名(如splitidx)。只需保留“主”索引不命名並命名其他索引即可。並使用\makeindex(不含參數的主要的索引)和\makeindex[name=...,title=...]其他索引。觀察範例

\documentclass[12pt]{book}
\usepackage[splitindex]{imakeidx}
    \makeindex
    \makeindex[name=secondindex,title=Second Index]
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\index{1@One splitindex entry!Using firstindex}
\index[secondindex]{Another splitindex entry!Using secondindex}

\indexprologue{\noindent How to put text on the following index pages?}
\printindex

\indexprologue{\noindent How to put text on the following index pages in the second index?}
\printindex[secondindex]
%Be sure to run: makeindex <filename>-splitindex; makeindex <filename>-secondindex
%Only if you didn't run pdflatex with the `--enable-write18` option.

\end{document}

因此創建了一個<filename>-splitindex.idx文件主要的索引和<filename>-secondindex.idx第二個。這主要的index 用於\indexname索引的標題。

跑步

pdflatex --enable-write18 <filename>

將由您自動執行此操作。

\documentclass[12pt]{book}
\usepackage[splitindex]{imakeidx}
    \makeindex[name=firstindex,title=First Index]
    \makeindex[name=secondindex,title=Second Index]
\usepackage{lipsum}

\begin{document}

\lipsum[1]
\index[firstindex]{1@One splitindex entry!Using firstindex}
\index[secondindex]{Another splitindex entry!Using secondindex}

\indexprologue{\noindent How to put text on the following index pages?}
\printindex[firstindex]

\indexprologue{\noindent How to put text on the following index pages in the second index?}
\printindex[secondindex]
%Be sure to run: makeindex <filename>-firstindex; makeindex <filename>-secondindex

\end{document}

相關內容