3

I am using imakeidx to create an index for my recipe book.

I would like to have the index show the following level-wise:

Appetizers

Recipe 1, pagenumber

Recipe 2, pagenumber

What I want, is the index to show the main category without pagenumber, but the actual recipes with pagenumbers. This is a test code I have so far:

\documentclass[12pt, letterpaper]{book}
\usepackage{imakeidx}

\makeindex[name=cat, title=Category, columns=1]
\makeindex[name=type, title=Type of Dish]

\begin{document}
    \index[type]{Casual}    %Want this in bold and no page number
    \index[type]{Quick}     %Want this in bold and no page number
    \index[type]{Formal}    %Want this in bold and no page number
    Appetizers \index[cat]{Appetizers}  %Want this in bold and no page number

    \newpage
    Cauliflower soup \index[cat]{Appetizers!Cauliflower Soup}   \index[type]{Casual!Cauliflower Soup}   %Want this to show as usual with page number

    \newpage
    Drinks  \index[cat]{Drinks} %Want this in bold and no page number

    \newpage
    Lemon Drop \index[cat]{Drinks!Lemon Drop}   %Want this to show as usual with page number


    \printindex[cat]

    \printindex[type]
\end{document}

1 Answer 1

3

enter image description here

\documentclass[12pt, letterpaper]{book}
\usepackage{imakeidx}

\makeindex[name=cat, title=Category, columns=1]
\makeindex[name=type, title=Type of Dish]

\newcommand\foo[1]{}
\newcommand\textbfz[2]{\textbf{#1}}
\begin{document}
    \index[type]{Casual@\textbfz{Casual}|foo}    %Want this in bold and no page number
    \index[type]{Quick@\textbfz{Quick}|foo}     %Want this in bold and no page number
    \index[type]{Formal@\textbfz{Formal}|foo}    %Want this in bold and no page number
    Appetizers \index[cat]{Apetizers@\textbfz{Appetizers}|foo}  %Want this in bold and no page number

    \newpage
    Cauliflower soup \index[cat]{Apetizers@\textbfz{Appetizers}!Cauliflower Soup} 
   \index[type]{Casual@\textbfz{Casual}|!Cauliflower Soup}   %Want this to show as usual with page number

    \newpage
    Drinks  \index[cat]{Drinks@\textbfz{Drinks}|foo} %Want this in bold and no page number

    \newpage
    Lemon Drop \index[cat]{Drinks@\textbfz{Drinks}!Lemon Drop}   %Want this to show as usual with page number


    \printindex[cat]

    \printindex[type]
\end{document}
10
  • your spelling of "appetizers" is somewhat peculiar, not to say inconsistent. more to the point, what is the point of the period at the end of the category entries? (not needed, i think.) Oct 23, 2014 at 20:49
  • @barbarabeeton spellink? oh never looked at that, was just looking at the fonts:-) the comma yes not really needed could replace @\textbf by @\zz defined by \newcommand\zz[2]{\textbf{#1}} then #2 would gobble the comma. Oct 23, 2014 at 20:53
  • @barbarabeeton better? Oct 23, 2014 at 21:07
  • Just one question, why is column=1 needed?
    – Ahana
    Oct 23, 2014 at 22:09
  • @Ahana I didn't even see it, it was just in the original file. Oct 23, 2014 at 22:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.