%---
\begin{filecontents*}[overwrite]{mal-style.xdy}
;;; Load a predefined style:
;(require "makeindex.xdy")
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(define-attributes ("squarebr"))
(markup-attribute-group-list :sep "; ")
(markup-locref
:attr "squarebr"
:open "[\colorbox{yellow!40}{\hyperpage{"
:close "}}]")
;(markup-locref :class "page-numbers" :attr "definition"
; :open "{\bf " :close "}")
;(markup-locref :class "page-numbers" :attr "definition"
; :open "\textbf{" :close "}")
;(define-letter-groups
; ("a" "b" "c" "d" "e" "f" "g" "h" "i" "j" "k" "l" "m"
; "n" "o" "p" "q" "r" "s" "t" "u" "v" "w" "x" "y" "z"))
;
;(markup-letter-group-list :sep "~n\indexspace")
;(define-letter-group "ly" :after "l" :before "m")
;(define-letter-group "ny" :after "n" :before "o")
;
;(markup-letter-group :open-head "~n {\bf " :close-head "}"
; :capitalize)
;(define-location-class "appendices"
; ("ALPHA" :sep "-" "arabic-numbers")
; :hierdepth 2)
;(markup-locref-list :sep "; " :depth 0 :class "appendices")
;(markup-locref-list :open "~~" :sep ", " :depth 1 :class "appendices")
;(define-alphabet "bible-chapters"
; ("Genesis" "Exodus" "Leviticus" "Numbers" "Deuteronomy"
; ... ))
;(define-location-class "bible-verses"
; ("bible-chapters" :sep " " "arabic-numbers" :sep "," "arabic-numbers"))
; (define-letter-groups (""))
;(define-letter-group "z")
(markup-locclass-list :open ": ")
(define-letter-group "Α" ; Greek alpha
:prefixes ("α");\x0391")
:after "Z"
)
;(define-letter-groups ("Num" "Dtn" "Ps"))
;(define-letter-group "Greek"
; :prefixes ("α" "ω")
; :after "Z")
;%(markup-letter-group [:open string] [:close string] [:group group-name]
;% [:open-head string] [:close-head string]
;% [:upcase | :downcase | :capitalize])
;%
; \begingroup
; \setlength{\fboxsep}{5pt}%
; \colorbox{blue}{%
; \color{white}\large\sffamily\bfseries
; \hbox to \dimexpr\linewidth-2\fboxsep{%
; \hfill
(markup-letter-group
:open-head "~n {\setlength{\fboxsep}{5pt}\sffamily\bfseries\large\colorbox{blue!30}{\textcolor{yellow!90!red!5}{\hbox to \dimexpr\linewidth-2\fboxsep{
\hfill " ; space is needed
:close-head "\hfill}}\nopagebreak\vspace{2mm}}}"
)
;(markup-letter-group
; :open-head "~n {\sffamily\bfseries\colorbox{blue};;;;{\textcolor{yellow}{"
; :close-head "}}}"
; )
(markup-locclass-list :open "\dotfill" :sep "")
(define-attributes (("texttt" "textsc" "myown")) )
(markup-locref :attr "textbf" :open "\textbf{\hyperpage{" :close "}}")
(markup-locref :attr "textit" :open "\textit{\hyperpage{" :close "}}")
(markup-locref :attr "texttt" :open "\texttt{\hyperpage{" :close "}}")
(markup-locref :attr "textsc" :open "\textsc{\hyperpage{" :close "}}")
(markup-locref :attr "myown" :open "\myown{\hyperpage{" :close "}}")
(markup-locref :attr "hyperpage" :open "\hyperpage{" :close "}")
(markup-locref :attr "default" :open "\hyperpage{" :close "}")
(merge-rule "n" "X" :again)
\end{filecontents*}
%---
\begin{filecontents*}[overwrite]{general-aindex.xdy}
(define-alphabet "secalpha" ("s" "p"))
(define-location-class "section-index" :var
("secalpha"
:sep ""
"arabic-numbers"
:sep "-"
"secalpha" :sep ""
"arabic-numbers" :sep ", "
))
(markup-locclass-list :open "\dotfill " :sep ", " :close "")
(define-attributes (("sectionmark" "sectionmarky")) )
(markup-locref
:attr "sectionmark"
:open "\textbf{\S}"
:close "")
(markup-locref
:attr "sectionmarky"
:open "\colorbox{yellow}{\textbf{\S}"
:close "}")
\end{filecontents*}
\documentclass{article}
\usepackage{xcolor}
\usepackage{fontspec}
\setmainfont{Noto Serif}
\usepackage[hyperindex=false,colorlinks]{hyperref}
%\usepackage{splitidx}
\usepackage{imakeidx}
\usepackage{xparse}
\ExplSyntaxOn
\makeatletter
\NewDocumentCommand { \generalindex } { o m m } {
\IfValueTF {#1}
{
{
% Local redefinition of indexentry to #3 instead of page%
\renewcommand{\imki@wrindexentrysplit}[3]{%
\expandafter\protected@write\csname##1@idxfile\endcsname{}%
{\string\indexentry{##2}{#3}}%
}%
\index[#1]{#2}
}
}
{ }
}
\makeatother
\NewDocumentCommand { \indexsec } { m } {
\generalindex[sec]{#1}{s\thesection-p\thepage}
}
\NewDocumentCommand { \indexsecb } { m } {
\generalindex[secb]{#1}{\thesection}
}
\NewDocumentCommand { \indexsecc } { m } {
\generalindex[secc]{#1|sectionmark}{\thesection}
}
\NewDocumentCommand { \genindex } { m m m } {
\generalindex[#1]{#2}{#3}
}
\ExplSyntaxOff
\makeindex[title=Xindy--demo,
program=texindy,
options=
-M mal-style.xdy
-C utf8
-t secondary.ilg
,
columnseprule,
]
\makeindex[name=s,title=Statutes,
program=texindy,
options=
-M mal-style.xdy
-C utf8
,
columnseprule,
]
\makeindex[name=sec,
title={IndexA Xindy {\small\ by section}},
program=texindy,
options=-M general-aindex.xdy
-C utf8
-t \jobname aidx.ilg
,
]
\makeindex[name=secb,
title={IndexB Xindy {\small\ by section only}},
program=texindy,
options=-M general-aindex.xdy
-C utf8
-t secb.ilg
,
]
\makeindex[name=secc,
title={IndexC Xindy {\small\ by section, with section-mark applied}},
program=texindy,
options=-M general-aindex.xdy
-C utf8
-t secc.ilg
,
]
\makeindex[name=secd,
title={IndexD Xindy {\small\ mixture of reference types}},
program=texindy,
options=-M general-aindex.xdy
-C utf8
-t secd.ilg
,
columns=1,
]
%=====
\newcommand{\secindex}[1]{\textbf{#1}\indexsec{#1}}
\newcommand{\secbindex}[1]{\indexsecb{#1}}
\newcommand{\seccindex}[1]{\indexsecc{#1}}
\newcommand\yellowcommand[1]{{\sffamily\textbf{#1}}}
\begin{document}
% from tex.se:
\def\myshift#1{\makebox[0pt][r]{\texttt{--}}\texttt{#1}}
\def\myown#1{{\Huge#1}}
\def\mycommand#1{{\color{green}#1}}
\def\mydef#1{\texttt{\makebox[0pt][r]{\char"5C}#1}}
\def\mymath#1{{\color{blue}$#1$}}
\def\myfavorite#1{{\color{cyan}\makebox[0pt][r]{I $\heartsuit$\ }{\color{cyan}#1}}}
\section{My section}\label{mysection}
I refer to my section~\ref{mysection}.
Start. Nunc ligula faucibus\index{xindy|textbf}.
\newpage
\index{vector@Vector}
\index{runme@\mycommand{runme}}
\newpage
\index{asquared@\mymath{a^2}}
\index{bsquared@\mymath{b^2}}
\newpage
x
\newpage
\index{csquared@\mymath{c^2}}
\index{roof|myown}
\newpage
\index{mal@\myshift{mal}}
\index{nature@\textbf{Nature}}
\newpage
\index{home!my own 1}
\index{home!my own 2}
\newpage
\index{definition@\mydef{definition}}
\index{Velocity}
Nullarutrum porttitor...
\newpage
\index{alcohol}\index{beauty}\index{älf}\index{zero}
\newpage
x\index{vectors@\myfavorite{vectors}}
x\index{roof|myown}
\newpage
x\index{roof}
% additions:
x\index{αβγ}
\newpage
x\index{10.2.250.1}
x\index{10.12.250.12}
\newpage
x\index{60.12.250.12}
x\index{128.12.250.12}
\newpage
x\index{128.12.250.12}
x\index[s]{s 7}x\index[s]{s 7B}x\index[s]{s 50}x\index[s]{s 5}x\index[s]{s 3(2)(a)}
\newpage
x\index[s]{SOGA!s 7}x\index[s]{SOGA!s 7B}x\index[s]{SOGA!s 50}x\index[s]{SOGA!s 5}x\index[s]{SOGA!s 3(2)(a)}
x\index[s]{Vsort!V-sort!V128}
x\index[s]{Vsort!V-sort!V64}
x\index[s]{SOGA!s 3(12)(a)}
x\index{first level!second level!third level}
x\index{xfirst level!xsecond level!xthird level|textbf}
\newpage
x\index{xfirst level!xsecond level|textit}
\newpage
x\index{xfirst level|squarebr}
%---------------------------------------------------
\section{Model}
x\secindex{model}
x\secbindex{model}
x\seccindex{model}
y\genindex{secd}{model!amain section@\yellowcommand{main section}|sectionmarky}{\thesection}
y\genindex{secd}{model!details!intro}{p\thepage}
\section{Hypothesis}
x\secindex{hypothesis}
x\secbindex{hypothesis}
x\seccindex{hypothesis}
\section{Testing}
x\secindex{testing}
x\secbindex{testing}
\newpage
x\seccindex{testing}
\section{Methodology}
x\secindex{methodology}
\newpage
x\secbindex{methodology}
x\seccindex{methodology}
y\genindex{secd}{model!details!causative}{p\thepage}
\newpage
\section{Experiment}
x\secindex{experiment}
x\secbindex{experiment}
x\seccindex{experiment}
\newpage
y\genindex{secd}{model!details!error margin}{p\thepage}
\newpage
\section{Results}
x\secindex{results}
x\secbindex{results}
x\seccindex{results}
y\genindex{secd}{model!details!error margin}{p\thepage}
\newpage
y\genindex{secd}{model!details!error margin}{p\thepage}
\section{Conclusions}
x\secindex{conclusions}
x\secbindex{conclusions}
x\seccindex{conclusions}
\section{Acknowledgements}
x\secindex{acknowledgements}
x\secbindex{acknowledgements}
x\seccindex{acknowledgements}
%---------------------------------------------------
\printindex
\printindex[s]
\printindex[sec]
\printindex[secb]
\printindex[secc]
\printindex[secd]
\end{document}
\imki@wrindexentrysplit? Which part should I remove? The part that should be in the first index or the rest that should be in the second? I tried adding a\renewcommandbetween the\makeindexbut both index unsurprisingly used that. -- Is there a way to specify that\index{....}uses onewrindexentrysplitimplementation and\index[X]{...}another? Or maybe provide a mapping function to\printindex[]? Is that something that can be done as "formatting" -- Any advice on which of these I should start learning about first? – BCS Aug 10 '21 at 06:36pandsin the working example is because it inserts both (which is what I don't want) and it makes it clear which is which. – BCS Aug 10 '21 at 07:38indexandsecindex, to reduce users' cognitive load and help with proof-reading. – Cicada Sep 10 '22 at 16:25