Text Formattingmakeidx

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

makeidx

Post by Laurentius »

I'm considering trying makeidx, but from a quick look at the documentation, it doesn't seem to allow for specification of the beginning and end of the indexed material. For instance, if it begins on p. 6 and ends of p. 7, the index should read 6 sq. or 6 f. Is this possible?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Re: makeidx

Post by Johannes_B »

Yes, i think it is the standard.

Never had to work with indexes myself, so cannot be more specific without an example.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

makeidx

Post by cgnieder »

This is possible but not the default:

Code: Select all

\documentclass{article}
\usepackage{imakeidx}% takes care of the call to the makeindex program; also
                     % provides a number of useful options for customization
\makeindex
\begin{document}

foo\index{foo}\newpage
foo\index{foo}

\printindex

\end{document}
without option
without option
index.png (2.81 KiB) Viewed 4648 times
However, the makeindex program knows options for customization. The ones you're looking for here are suffix_2p and suffix_3p. Those need to be set in an index style file (ending ist) and makeindex needs to be called

Code: Select all

makeindex -s name-of-style-file.ist
Here is an example:

Code: Select all

\documentclass{article}
\usepackage{imakeidx}% takes care of the call to the makeindex program; also
                     % provides a number of useful options for customization

\usepackage{filecontents}
\begin{filecontents}{\jobname.ist}
suffix_2p "\\,f."
suffix_3p "\\,ff."
\end{filecontents}

\makeindex[options={-s \jobname.ist}]


\begin{document}

foo\index{foo}\newpage
foo\index{foo}

\printindex

\end{document}
with option
with option
index.png (2.65 KiB) Viewed 4648 times
I suggest you try to read the manual of the makeindex program for more information on customization.

Regards
site moderator & package author
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Re: makeidx

Post by Laurentius »

Thank you. As I suspected this requires one to know beforehand where the pagebreaks are going to be. Besides, there is a difference between 7, 8 and 7 sq.; the former indicates two separate metions, the latter one continuous. Similarly with larger ranges, e.g. 7--9 ≠ 7, 8, 9.
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

makeidx

Post by cgnieder »

Laurentius wrote:Thank you. As I suspected this requires one to know beforehand where the pagebreaks are going to be.
Why would that be? All pages where an item is indexed is recorded and makeindex formats the pagelist afterwards according to the specifications in the style file.
Laurentius wrote:Besides, there is a difference between 7, 8 and 7 sq.; the former indicates two separate metions, the latter one continuous. Similarly with larger ranges, e.g. 7--9 ≠ 7, 8, 9.
I don't think so but anyway… However, a page number is not mentioned more than once. So as how do you actually (from a reader's perspective as well as from makeindex's perspective) distinguish between the two cases?

If an item occurs on page seven and eight and you haven't used suffix_2p then both pages are mentioned separately and if you have set it then this value is used. The same goes for suffix_3p.

If you actually want to indicate a range you usually input

Code: Select all

\index{foo|(}
...
\index{foo|)}
but if you have set suffix_3p then that value is used.

Maybe xindy can distinguish between those two cases (I don't know as I've never used it) but makeindex can't.

Regards
site moderator & package author
Laurentius
Posts: 132
Joined: Wed Feb 11, 2009 11:38 pm

Re: makeidx

Post by Laurentius »

Thanks again. I don't know what the traditional practice is, but the distinction is made in The Oxford Guide to Style.
Post Reply