Page Layoutnewb question

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Genteel
Posts: 1
Joined: Mon May 13, 2024 10:40 am

newb question

Post by Genteel »

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.
Cranked-up bro-level tube packed wall-to-wall with real nasty incest porn: mom sons riding raw, dads daughters take nut, sisters brothers sneaking late-night quickies – https://tabooporn.xxx/ , https://porntaboo.tv/ , https://familyporn.love/

Recommended reading 2024:

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

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Stefan Kottwitz
Site Admin
Posts: 10360
Joined: Mon Mar 10, 2008 9:44 pm

newb question

Post by Stefan Kottwitz »

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.

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}
index.png
index.png (13.25 KiB) Viewed 13775 times
Stefan
LaTeX.org admin
Post Reply