背景
食谱书中的每个菜谱都有配料,这些配料可以是整本书中不同菜谱的共同配料。例如:
代码
我添加了逗号和颜色,如下所示:
\definealternativestyle[reg:bigbold][\sansserif\bold][]
\setupregister[index][
style=reg:bigbold,
alternative=A,
color=ColourPrimary,
pagecolor=ColourPrimary,
distance=0pt,
symbol=n,
pagecommand={\color[ColourBody]{,}\hskip1ex},
]
这会产生类似的结果:
问题
困难在于收集给定成分的所有部分名称并将它们与各自的页码进行整理。
问题
您将如何包含成分名称下缩进的章节标题列表?
例子
以下示例可以说明该问题:
\definealternativestyle[reg:bigbold][\sansserif\bold][]
\setupregister[index][
style=reg:bigbold,
alternative=A,
distance=0pt,
symbol=n,
pagecommand={\color[black]{,}\hskip1ex},
]
\starttext
\startfrontmatter
\completecontent
\stopfrontmatter
\startbodymatter
\startchapter[
title={Chapter 1},
reference=sec:chapter-1,
]
\startsection[
title={Section 1},
reference=sec:section-1,
]
\startsubsection[
title={Ingredients},
reference=sec:ingredients-1,]
\index{chocolate milk}{chocolate milk}
\index{milk}{milk}
\index{butter}{butter}
\stopsubsection
\stopsection
\stopchapter
\startchapter[
title={Chapter 2},
reference=sec:chapter-2,
]
\startsection[
title={Section 1},
reference=sec:section-1,]
\index{milk}{milk}
\index{egg}{egg}
\index{ham}{ham}
\stopsection
\stopchapter
\stopbodymatter
\startbackmatter
\chapter{Index}
\placeindex[compress=yes]
\stopbackmatter
\stoptext
答案1
我不确定这个问题,所以我不知道这个答案是不是你的问题。
\define[2]\Index
{\expanded{\index{#1+\currentstructuretitle}{#2}}}
\starttext
\startsection[title={Everything Buns}]
\Index{all-purpose flour}{all-purpose flour}
\Index{olive oil}{olive oil}
Instructions on how to make buns.
\stopsection
\startsection[title={Butternut Squash Soup}]
\Index{olive oil}{olive oil}
\Index{bacon}{bacon}
Instructions on how to make butternut squash soup.
\stopsection
\placeindex
\stoptext
这使