\documentclass{jbook}
\author{
筆者
}
\title{索引を作ってみよう}
\usepackage{makeidx}
\makeindex
\begin{document}
\maketitle
わたしは、このページの北海道\index{ほっかいどう@北海道}を「あいうえお順」の索引に載せたいが、
次ページの北海道は索引に載せず、その次のページの北海道を「アルファベット順」の索引に載せたい。
このページの北海道は、あいうえお順の索引に載せるので、"北海道\index{ほっかいどう@北海道}"と書きます。
ホッカイド\index{ほっかいど@ホッカイド}は、北海道よりも前に索引化されるべきで、
偽北海道\index{ほっかいどうか@偽北海道}は、「にせほっかいどう」と読むべきだけれども、よみかたを「ほっかいどうか」と指定しているので、「ほ」「はひふへほ」の項目として索引化されている。
改ページします。
\newpage
このページの北海道は索引に載せないので、ただ北海道とスペルする。
ここでもう一度改ページします。
\newpage
このページの北海道\index{hokkaidou@北海道}はアルファベット順の索引に載せるので、"北海道\index{hokkaidou@北海道}"と書きます。
\printindex
\end{document}
> platex test.tex
...
Writing index file test.idx
(./test.aux) [1] [2] [3]
No file test.ind.
[4] (./test.aux) )
Output written on test.dvi (4 pa
Transcript written on test.log.
- というメッセージがスクロールされます。
- "test.idx"なるファイルを書き出していることがわかります。
- No. test.indというメッセージは、"test.idx"ファイルがまだないことを意味しています。また、それがあれば、その中味を参照して、索引を作るわけですが、それはしてませんよ、という意味です。
- "test.idx"なるファイルが出来ます。
- これは、どういう索引項目をどういう順序で、書き出し、それの参照ページがどこか、を指定するテキストファイルです。
- 中味はこんな感じ
\indexentry{ほっかいどう@北海道}{2}
\indexentry{ほっかいどう@北海道}{2}
\indexentry{ほっかいど@ホッカイド}{2}
\indexentry{ほっかいどうか@偽北海道}{2}
\indexentry{hokkaidou@北海道}{4}
\indexentry{hokkaidou@北海道}{4}
- 次に、"test.idx"を"mendex"コマンドで処理します
- line.istなるファイルで書き方を指定します。冒頭のサイトリンクから入手できます
> mendex -r -c -g -s line.ist -p any test.idx
-
- メッセージが出ます。
- 特に、今回は、「北海道」という文字列を「ほっかいどう」と「hokkaidou」と異なる順序指定にしているので、その警告も出ています。
This is mendex version 2.6d [5-Jan-2006] (sjis.euc).
Scanning input file test.idx.
Warning: Sort key "hokkaidou" is different from previous key "ほっかいどう" for
same index "北海道" in test.idx, line 5.
Warning: Sort key "hokkaidou" is different from previous key "ほっかいどう" for
same index "北海道" in test.idx, line 6....done (6 entries accepted, 0 rejected)
.
6 entries accepted, 0 rejected.
Sorting index....done(9 comparisons).
Sorting pages....done(0 comparisons).
Making index file....done.
2 warnings, written in test.ilg.
Output written in test.ind.
- "test.ind"というファイルができて、これは、"test.tex"の中から、"\printindex"にて呼ばれます。
\begin{theindex}
\setcounter{page}{7}
{\vbox{\hbox to \linewidth{\gtfamily\bfseries H\ \hskip\fill}\vskip1pt\hrule}}\nopagebreak
\item 北海道\hfill 4
\indexspace
{\vbox{\hbox to \linewidth{\gtfamily\bfseries は\ \hskip\fill}\vskip1pt\hrule}}\nopagebreak
\item ホッカイド\hfill 2
\item 北海道\hfill 2
\item 偽北海道\hfill 2
\end{theindex}
-
- また、"test.ind"を作るときの警告が、"test.ilg"ファイルに書き出されています。
This is mendex version 2.6d [5-Jan-2006] (sjis.euc).
Scanning input file test.idx.
Warning: Sort key "hokkaidou" is different from previous key "ほっかいどう" for same index "北海道" in test.idx, line 5.
Warning: Sort key "hokkaidou" is different from previous key "ほっかいどう" for same index "北海道" in test.idx, line 6....done (6 entries accepted, 0 rejected).
6 entries accepted, 0 rejected.
Sorting index....done(9 comparisons).
Sorting pages....done(0 comparisons).
Making index file....done.
2 warnings, written in test.ilg.
Output written in test.ind.
> platex test.tex
-
- とすると、索引が作られます。
- 掲載図のように以下の4項目が索引化されます
- Hのところに 「北海道 4(ページ)」
- はのところに 「ホッカイド 2」「北海道 2」「偽北海道 2」