3

How do you get bold index entries to appear first in your index please? My mwe is

\documentclass[a4paper,12pt]{report}
\usepackage{imakeidx}
\makeindex[options=-s columnseprule,intoc,columns=2]
\begin{document}

\subsubsection{The back of your bra rides up towards your shoulder}
If the back of the bra rides up towards your shoulder blades it usually
indicates the back of the bra is too big. For example – if you are wearing
a 36C, it may be worth trying a 34D or even a 32DD. (Take a look at our
bra sizing guide to help you with this.) 
\index{Bra@\textbf{Bra}|textbf} 

\subsubsection{The bra cup digs into your bust at the top creating a ‘double-bust’ effect}
If the bra cups digs into your bust at the top, it is a sure sign that
the bra cup is too small. Try the next cup size up! 
\index{Bra!classic}
\index{Bra!standard}

\printindex

\end{document}

Using the above example, they appear as "Bra, classic" and "Bra, standard" in the index, with the bold "Bra" and page number after them. How do I reverse that please so that bold "Bra" and page number comes first in the index?

3
  • you can "force" a sort by adding a sort argument "Bra1" to the two non-bold entries. or change the sort argument for the bold one to "Br0" if there is no other likely conflict. Commented Mar 12, 2015 at 15:13
  • @barbarabeeton can you give an example please? I've never used 'sort arguments' so I'm not sure how to place it
    – boudiccas
    Commented Mar 12, 2015 at 15:34
  • actually, you are using a sort argument. but i'll write an answer, using your example as the base. Commented Mar 12, 2015 at 16:25

1 Answer 1

5

Here is the original example with one change, that will cause the bold index entry to be sorted before the two others.

\documentclass[a4paper,12pt]{report}
\usepackage{imakeidx}
\makeindex[options=-s columnseprule,intoc,columns=2]
\begin{document}

\subsubsection{The back of your bra rides up towards your shoulder}
If the back of the bra rides up towards your shoulder blades it usually
indicates the back of the bra is too big. For example – if you are wearing
a 36C, it may be worth trying a 34D or even a 32DD. (Take a look at our
bra sizing guide to help you with this.) 
%\index{Bra@\textbf{Bra}|textbf}
\index{Br0@\textbf{Bra}|textbf} 

\subsubsection{The bra cup digs into your bust at the top creating a ‘double-bust’ effect}
If the bra cups digs into your bust at the top, it is a sure sign that
the bra cup is too small. Try the next cup size up! 
\index{Bra!classic}
\index{"`!standard}

\printindex

\end{document}

the first (bold) \index entered in the file has what is called a "sort argument", the string that appears before the @. the other two entries have an "implicit" sort argument that appears to be the same as that for the bold entry. however, the index processor actually sorts on the entire entry (up to the ! for a multi-level entry), so "Bra@\textbf{Bra}|textbf" is not the same as "Bra", and they will be treated as two separate entries in the index, and since the bolded entry is sorted on a longer string, it will be placed later in the index.

by modifying the existing sort argument (on the bold entry) from "Bra" to "Br0", it will be sorted before the "ordinary" entries. (digits sort before letters.)

when doing this, it needs to be considered whether there will other entries present in the index that could cause a conflicting sort order. in this example, that's not likely, but if the sort were intended to manage math notation, where symbols are involved, more care must be taken.

1
  • Thank you very much, that works beautifully, and I undestand what's happening too! :)
    – boudiccas
    Commented Mar 12, 2015 at 16:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .