Hi, I'm typesetting a recipes book (for hobby), in this book every recipe is a section, I have and index containing the ingredients of every recipe in this form:
water, 4-7
salt, 4, 6, 8
sugar, 5, ,8-10
I want the name of the recipe (section) near every appearance:
water,
home made pasta, 4
something else, 5
another recipe, 6
salt,
very ugly cake, 4
not edible yogurt, 6
and so on.
Page Layout ⇒ newb question
- Stefan Kottwitz
- Site Admin
- Posts: 10290
- Joined: Mon Mar 10, 2008 9:44 pm
newb question
Hi Genteel,
welcome to the forum!
Here is a quick example, using the imakeidx package and the nameref package for referencing the section names. I made a custom command to index with section names.
Stefan
welcome to the forum!
Here is a quick example, using the imakeidx package and the nameref package for referencing the section names. I made a custom command to index with section names.
Code: Select all
\documentclass{article}
\usepackage{imakeidx}
\usepackage{nameref}
\makeindex
\newcommand{\secindex}[1]{#1\index{#1!\nameref{sec:\thesection}}}
\begin{document}
\section{home made pasta}\label{sec:\thesection}
We need \secindex{salt} here.
\clearpage
\section{something else}\label{sec:\thesection}
Use \secindex{water} and more.
\clearpage
\section{another recipe}\label{sec:\thesection}
Use \secindex{water}.
\clearpage
\section{very ugly cake}\label{sec:\thesection}
Take \secindex{salt} and \secindex{water}.
\clearpage
\printindex
\end{document}
LaTeX.org admin