MakeIndex, Nomenclature, Glossaries and Acronyms ⇒ Forcing a blank index line alphabetically
Forcing a blank index line alphabetically
There are times when makeindex leaves some unfortunate page or column breaks. I know that it is possible to edit the .ind file and add a \indexspace entry.
However, I would like a solution that is handled at the source file level. Something like \indexspace{masquerades as} where "masquerades as" would indicate where, in alphabetical order, the blank space should reside.
For example, I have the index entries
cable
cat
coin
but want a space between cable and cat. I would like to add this to my source file:
\indexspace{cac}
(cac is not a valid word, but it lands where I want a blank line).
However, I would like a solution that is handled at the source file level. Something like \indexspace{masquerades as} where "masquerades as" would indicate where, in alphabetical order, the blank space should reside.
For example, I have the index entries
cable
cat
coin
but want a space between cable and cat. I would like to add this to my source file:
\indexspace{cac}
(cac is not a valid word, but it lands where I want a blank line).
NEW: TikZ book now 40% off at Amazon.com for a short time.
Forcing a blank index line alphabetically
I'm not sure what you may need this for, but here's an idea:
KR
Rainer
Code: Select all
Code, edit and compile here:
\documentclass{article}\usepackage{makeidx}% You could add this to your .ist file, if you're using one (makeindex -s .ist); .mst is loaded by makeindex automatically, if it has the same basename as the file to be processed (unless suppressed via -s argument):\begin{filecontents*}{\jobname.mst}delim_0 "\\idxcomma"delim_1 "\\idxcomma"delim_2 "\\idxcomma"\end{filecontents*}\makeindex\newif\ifidxskippage %flag for skipping over page entry ... and its delimeter\newcommand*\skipindex[1]{%\index{#1@\protect\idxskippagetrue~|skippageentry}%% this reads: create an index under #1 (`cac' in this example), set the skipping flag, use a non-breaking space as entry, and use \skippageentry for encapsuling the entry's page number.}\newcommand*\skippageentry[1]{\idxskippagefalse}% ignore the parameter (the page number) and reset the skipping flag\newcommand*\idxcomma{% now the reason for creating the skipping flag:\ifidxskippage% if skipping flag is active, do nothing\else % otherwise, output the usual comma, followed by space,\fi}\begin{document}foo\index{cat}\index{coin}\index{cable}\skipindex{cac}\printindex\end{document}
Rainer
Forcing a blank index line alphabetically
Thank you so much. This almost does what I need. If I run it on a typical latex file it works great. Unfortunately, I have the following .ist file:
IndexTest.ist:
When I run your code in conjunction with this, the commas are not suppressed on the blank index line.
Index
cable, 1
,
cat, 1
coin, 1
the revision replaces
(I am using the imakeindex package.)
IndexTest.ist:
Code: Select all
preamble"\\thispagestyle{empty}\n\\begin{theindex}\n"postamble"\\end{theindex}\n"
When I run your code in conjunction with this, the commas are not suppressed on the blank index line.
Index
cable, 1
,
cat, 1
coin, 1
the revision replaces
\makeindex
with\makeindex[options=-s IndexTest.ist]
(I am using the imakeindex package.)
Re: Forcing a blank index line alphabetically
I found a way to avoid using the .ist file. So your solution works just fine. Thanks again.
Forcing a blank index line alphabetically
so what? Can't you just add the three lines from my .mst file (delim...) to your .ist file?gossett wrote:Unfortunately, I have the following .ist file:
IndexTest.ist:Code: Select all
preamble"\\thispagestyle{empty}\n\\begin{theindex}\n"postamble"\\end{theindex}\n"
Or was your .ist file automagically created?
KR
Rainer
Re: Forcing a blank index line alphabetically
Adding your code into my .ist file did not eliminate the extra commas. I am not sure why the two don't play well together.
I will upload sample files.
I will upload sample files.
- Attachments
-
- IndexTest.tex
- The main file
- (1.3 KiB) Downloaded 593 times
Forcing a blank index line alphabetically
well, I still don't see the problem you're describing---after merging the three lines from my .mst into your .ist, that is.gossett wrote:Adding your code into my .ist file did not eliminate the extra commas.
Code: Select all
preamble"\\thispagestyle{empty}\n\\begin{theindex}\n"postamble"\\end{theindex}\n"delim_0 "\\idxcomma"delim_1 "\\idxcomma"delim_2 "\\idxcomma"
KR
Rainer
Re: Forcing a blank index line alphabetically
That did fix the test file. I think I was pasting too much into the .ist file. Thanks for the help.