| This is thediscussion page for discussing improvements to theLaTeX/Indexing page. |
Textbook policies |
`makeidx` is woefully obsolete. It's one of the few pieces of software left that can't handle Unicode, and this has been unacceptable for ages now. It should not be recommended or even explained here. A modern alternative, like `texindy` should be provided and explained instead.
To allow texindy to process.idx files and to have hyperlinks in index you have to pre- and post-process files used by texindy.
First, the pre-processor,texindy-pre.pl:
#!/usr/bin/perlunless ($ARGV[0] =~ /\.idx$/){ print "\nUsage:\n"; print "texindy-post.pl file.idx\n\n"; print "This script will work only for unprocessed LaTeX .idx files.\n"; print "It is the first script in series, to pre process files so they can\n"; print "be processed by TeXindy.\n"; print "\nTogether with texindy-post.pl it works around the \"\\hyperindexformat{}\"\n"; print "deficiency in TeXindy, making it possible to use \"textbf\" and \"texit\"\n"; print "modifiers in \"\\index{}\" command together with \'hyperref\' package\n";}open(DATA, "< $ARGV[0]") or die "\nCan't open file for reading: $!\n";#All lines must be read by Perl so that no scratch files need to be used@lines = <DATA>;close(DATA);print "\nFile $ARGV[0] read\.\n\n";open(DATA, "> $ARGV[0]") or die "\nCan't open file $ARGV[0] for writing: $!\n";$f1=0;$f2=0;foreach $line (@lines) {# change "|)" to "|)hyperpage" if ($line =~ s/\|\)/|)hyperpage/){ $f1 += 1; }# remove hyperindexformat if ($line =~ s/hyperindexformat\{\\([^\}]*)\}/$1/){ $f2 += 1; }print DATA $line;}close(DATA);print "Fixed $f1 page ranges.\nFixed $f2 hyperindexformat occurences.\n\n";exit();Second, the post-processor,texindy-post.pl:
#!/usr/bin/perlunless ($ARGV[0] =~ /\.ind$/){ print "\nUsage:\n"; print "texindy-post.pl file.ind\n\n"; print "This script will work only for processed LaTeX .ind files.\n"; print "It is the second script in series, to post process files after they have\n"; print "been processed by TeXindy.\n"; print "\nTogether with texindy-pre.pl it works around the \"\\hyperindexformat{}\"\n"; print "deficiency in TeXindy, making it possible to use \"textbf\" and \"texit\"\n"; print "modifiers in \"\\index{}\" command together with \'hyperref\' package\n";}open(DATA, "< $ARGV[0]") or die "\nCan't open file for reading: $!\n";#All lines must be read by Perl so that no scratch files need to be used@lines = <DATA>;close(DATA);print "\nFile $ARGV[0] read\.\n\n";open(DATA, "> $ARGV[0]") or die "\nCan't open file $ARGV[0] for writing: $!\n";$f1=0;$f2=0;foreach $line (@lines) {#change textbf modifiers to hyperlinks if ($line =~ s/ \\textbf{([0-9ivxl]+)}/ \\hyperindexformat{\\textbf}{\1}/){ $f1 += 1; }#change textit modifiers to hyperlinks if ($line =~ s/ \\textit{([0-9ivxl]+)}/ \\hyperindexformat{\\textit}{\1}/){ $f2 += 1; }print DATA $line;}close(DATA);print "Changed $f1 textbf occurences.\nChanged $f2 textit occurences.\n\n";exit();If you have those two files in the same directory as your LaTeX project, your LaTeX file ismain.tex and the project is written in polish, use this commands to generate dvi file with correct index:
latex main./texindy-pre.pl main.idxtexindy -M lang/polish/utf8 -I latex 'main.idx'./texindy-post.pl main.indlatex main
---
It would be very helpful if the lines about multiple indices would add thatmakeindex filename has to be run twice (or even more often) as well.
I don't know why, but the sectionhttp://en.wikibooks.org/wiki/LaTeX/Indexing#Adding_index_to_table_of_contents is not necessary, at least I don't know when that lines are needed. I've tried 'standard' index as well as `multind' and I get indices in my TOC automatically. --79.154.142.115 (discuss)17:19, 8 January 2014 (UTC)
An alternative to multind is imakeidx. Seehttp://mirrors.ctan.org/macros/latex/contrib/imakeidx/imakeidx.pdf
imakeidx. See the "Latest Draft" tab. --Hops Splurt (discuss •contribs)05:11, 5 May 2019 (UTC)Note to self: Replace themultind stuff with a more recent package.--Johannes Bo (discuss •contribs)15:20, 27 September 2017 (UTC)
On this page (in the section "Using makeidx")makeidx is described as a package, and must be invoked with the\usepackage{makeidx} command.But the manual formakeindex, which describes the same commands as thepage text (\makeindex,\index,\printindex) states that to use ityou must addmakeidx to the list of options of the\documentstyle command.On the other hand, that manual is from 1987, and speaks of the "\documentstyle" command, which has presumablybeen superseeded by the\documentclass command.Thereis apackage calledmakeidx, but this is a LaTeX2epackage which only providesthe\see and\printindex commands.
Can anyone find out if the way to invokemakeindex is correctly described on the page?--Hops Splurt (discuss •contribs)06:48, 5 May 2019 (UTC)
\documentstyle is obsolete just as long. Usemakeidx by loading it withusepackage, it just provides few extra commands. The rest is provided by basic LaTeX. Be sure to run the proper external tool to get the index sorted out. --Johannes Bo (discuss •contribs)05:32, 12 May 2019 (UTC)