summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/gindex
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-10-08 03:00:28 +0000
committerNorbert Preining <norbert@preining.info>2019-10-08 03:00:28 +0000
commite5ffc42ed260285f76383ae18dd0f4a603c07fa8 (patch)
tree7d901aebae17ed14f1c9812c9339a88d68dc74e4 /macros/latex/contrib/gindex
parentba86549c94b1e8b6b19bc82b01e85a7e513e7586 (diff)
CTAN sync 201910080300
Diffstat (limited to 'macros/latex/contrib/gindex')
-rw-r--r--macros/latex/contrib/gindex/README.md8
-rw-r--r--macros/latex/contrib/gindex/gindex.ist14
-rw-r--r--macros/latex/contrib/gindex/gindex.pdfbin26534 -> 30705 bytes
-rw-r--r--macros/latex/contrib/gindex/gindex.sty62
-rw-r--r--macros/latex/contrib/gindex/gindex.tex82
-rw-r--r--macros/latex/contrib/gindex/gindexh.ist42
6 files changed, 159 insertions, 49 deletions
diff --git a/macros/latex/contrib/gindex/README.md b/macros/latex/contrib/gindex/README.md
index ab045e6f42..6677a53fec 100644
--- a/macros/latex/contrib/gindex/README.md
+++ b/macros/latex/contrib/gindex/README.md
@@ -16,6 +16,14 @@ Then you can define `\indexitem` and the like to whatever you want.
### Recent changes
```
+0.2 2019-10-07
+ - Fix - Misplaced R in page_precedence.
+ - Fix - The last item was discarded.
+ - \indexspecial, for literal unformatted entries.
+ - delim_n now set with a macro (\indexpagessep).
+ - gindex.ist does not add headings anymore. A new style
+ gindexh.ist does.
+
0.1 2019-10-01
- First released version, with the most basic tools.
```
diff --git a/macros/latex/contrib/gindex/gindex.ist b/macros/latex/contrib/gindex/gindex.ist
index 9200efe193..c5992630bf 100644
--- a/macros/latex/contrib/gindex/gindex.ist
+++ b/macros/latex/contrib/gindex/gindex.ist
@@ -1,7 +1,7 @@
%
% Copyright (C) 2019 Javier Bezos http://www.texnia.com
%
-% 2019/10/01 v0.1
+% 2019/10/07 v0.2
%
% This file may be distributed and/or modified under the conditions of
% the MIT License. A version can be found at the end of this file.
@@ -25,18 +25,18 @@ group_skip "}\n%\n\\addindexskip{"
heading_prefix "}\n%\n\\addindexheading{"
heading_suffix "}\n%\n{"
preamble "\\begin{theindex}\\indexpreamble\n\n{"
-postamble "}\n\\indexpostamble\\end{theindex}"
+postamble "}\n\\indexflushitem\\indexpostamble\\end{theindex}"
indent_space ""
indent_length 0
-delim_r "{\\indexrangesep}"
+delim_n "\\indexpagessep "
+delim_r "\\indexrangesep "
% Modify to fit your own requirements
% -----------------------------------
-headings_flag -1 % Usually redefining \indexheading is better
+headings_flag 0
actual '@'
quote '"'
level '!'
-page_precedence "rnaRA"
-keyword "\\indexentry"
-delim_n ", " \ No newline at end of file
+page_precedence "rRnaA"
+keyword "\\indexentry" \ No newline at end of file
diff --git a/macros/latex/contrib/gindex/gindex.pdf b/macros/latex/contrib/gindex/gindex.pdf
index f2c092f75d..c51d724fdb 100644
--- a/macros/latex/contrib/gindex/gindex.pdf
+++ b/macros/latex/contrib/gindex/gindex.pdf
Binary files differ
diff --git a/macros/latex/contrib/gindex/gindex.sty b/macros/latex/contrib/gindex/gindex.sty
index 36311da7f9..5d86fe60a6 100644
--- a/macros/latex/contrib/gindex/gindex.sty
+++ b/macros/latex/contrib/gindex/gindex.sty
@@ -7,45 +7,50 @@
% Repository: https://github.com/jbezos/gindex
%
-\ProvidesPackage{gindex}[2019/10/01 v0.1 Formatting indexes]
+\ProvidesPackage{gindex}[2019/10/07 v0.2 Formatting indexes]
\newcounter{indexsubitems}
-\let\esx@save\@empty
+\let\gix@save\@empty
\let\indexnoitem\@gobbletwo
-\def\addindexitem#1#2{%
- \esx@save
- \indexnoitem{}{}%
- \setcounter{indexsubitems}{0}%
- \let\esx@save\@empty
- \g@addto@macro\esx@save{\indexitem{#1}{#2}}}
+%------------------------
-\def\addindexskip#1{%
- \esx@save
- \indexnoitem{}{}%
- \setcounter{indexsubitems}{0}%
- \let\esx@save\@empty
- \indexskip{#1}}
+\let\indexspecial\relax
-\def\addindexheading#1{%
- \esx@save
- \indexnoitem{}{}%
- \setcounter{indexsubitems}{0}%
- \let\esx@save\@empty
- \indexheading{#1}}
+% #4 current macro, #5 locator
+\def\gix@getspecial#1\indexspecial#2\indexspecial#3\@@#4#5{%
+ \ifx\indexspecial#3\@empty
+ \g@addto@macro\gix@save{#2}%
+ \else
+ \g@addto@macro\gix@save{#4{#1}{#5}}%
+ \fi}
+
+%------------------------
+
+\def\addindexitem#1#2{%
+ \indexflushitem
+ \gix@getspecial#1\indexspecial\indexspecial\@@\indexitem{#2}}
\def\addindexsubitem#1#2{%
\stepcounter{indexsubitems}%
- \g@addto@macro\esx@save{\indexsubitem{#1}{#2}}}
+ \gix@getspecial#1\indexspecial\indexspecial\@@\indexsubitem{#2}}
\def\addindexsubsubitem#1#2{%
- \g@addto@macro\esx@save{\indexsubsubitem{#1}{#2}}}
+ \gix@getspecial#1\indexspecial\indexspecial\@@\indexsubsubitem{#2}}
\newcommand\indexitem[2]{\item #1\ifx\\#2\\\else, #2\fi}
\newcommand\indexsubitem[2]{\subitem #1\ifx\\#2\\\else, #2\fi}
\newcommand\indexsubsubitem[2]{\subsubitem #1\ifx\\#2\\\else, #2\fi}
+\def\indexflushitem{%
+ \gix@save
+ \indexnoitem{}{}%
+ \setcounter{indexsubitems}{0}%
+ \let\gix@save\@empty}
+
+% ----------------------
+
\newcommand\indexitemhang[6]{%
\par\hangindent#2\relax
\ifdim#1=0pt\relax\else
@@ -58,6 +63,16 @@
#4#6%
\fi}
+%----------------------
+
+\def\addindexskip#1{%
+ \indexflushitem
+ \indexskip{#1}}
+
+\def\addindexheading#1{%
+ \indexflushitem
+ \indexheading{#1}}
+
\ifx\indexspace\@undefined
\newcommand\indexskip[1]{\par\vskip10\p@\@plus5\p@\@minus3\p@\relax}
\else
@@ -69,10 +84,13 @@
\hfil}%
\nopagebreak}
+%---------------------
+
\let\indexpreamble\relax
\let\indexpostamble\relax
\def\indexrangesep{-}
+\def\indexpagessep{, }
\endinput
diff --git a/macros/latex/contrib/gindex/gindex.tex b/macros/latex/contrib/gindex/gindex.tex
index c240281dfd..42670dfc31 100644
--- a/macros/latex/contrib/gindex/gindex.tex
+++ b/macros/latex/contrib/gindex/gindex.tex
@@ -4,16 +4,16 @@
% This file may be distributed and/or modified under the conditions of
% the MIT License. A version can be found at the end of this file.
%
-% Repository: https://github.com/jbezos/esindex
+% Repository: https://github.com/jbezos/gindex
%
\documentclass[a4paper]{ltxguide}
-\title{\textsf{gindex}\\\large Version 0.1}
+\title{\textsf{gindex}\\\large Version 0.2}
\author{Javier Bezos\\\texttt{http://www.texnia.com}}
-\date{2019-10-01}
+\date{2019-10-07}
\raggedright
\parskip=.8ex
@@ -42,8 +42,9 @@
{\fontsize{48}{48}\selectfont \color{notes}{gindex}\par}
{\LARGE Formatting indexes with \LaTeX\par}
\vspace*{1ex}
-Version 0.1 (2019-10-01)\par
-Javier Bezos (\texttt{http://www.texnia.com})
+Version 0.2 (2019-10-07)\par
+\texttt{https://github.com/jbezos/gindex}\par
+Javier Bezos (\texttt{http://www.texnia.com})\par
\vspace*{6ex}
@@ -53,7 +54,7 @@ the format of index entries from within \LaTeX. With standard classes,
it works out of the box with some predefined values, which you can (and
in fact should) redefine with |\renewcommand|.
-Note it is version 0.1. Changes of the existing features are unlikely
+Note it is version 0.2. Changes of the existing features are unlikely
to happen (but who knows), but new features, on the other hand, will be
added in the near future.
@@ -67,7 +68,8 @@ What it does is to generate blocks like this for each first-level entry:
\end{verbatim}
As you can see, when |\indexitem| is executed, you know the number of
-subitems, which is necessary for some styles.
+subitems, which is necessary for some styles. Subsubitems are allowed,
+but not counted. Only subitems are counted.
The default values are:
\begin{verbatim}
@@ -93,12 +95,9 @@ example will be:
This explains the line |\indexnoitem{}{}| above, which by default does
nothing. By inspecting the third parameter you decide how to format the
current parameter (of course, in most cases you must emit it again at
-the end of your definition of |\indexitem|).
+the end of your definition of |\indexitem|). See the example below.
-Subsubitems are allowed, but not counted. Only subitems are counted.
-
-
-There is a tool to define the most usual entry format, which is used in
+There is a tool to define the most usual entry format, which is uesd in
the following way:
\begin{verbatim}
\renewcommand\indexitem[2]{%
@@ -118,7 +117,8 @@ Other macros are:
\verb|\end{theindex}| (\verb|\relax| by default).
\item \verb|\indexskip|, which is \verb|\indexspace| by default,
with similar purpose.
-\item \verb|\indexheading|, is defined as follows:
+\item \verb|\indexheading|, which is added by |gindexh.ist| but no by
+|gindex.ist|, is defined as follows:
\begin{verbatim}
\newcommand\indexheading[1]{%
{\bfseries\hfil
@@ -127,15 +127,58 @@ with similar purpose.
\nopagebreak}
\end{verbatim}
\item \verb|\indexrangesep|, which by default is |-|.
+\item \verb|\indexpagessep|, which by default is |, |.
\end{itemize}
Remember to set the style to |gindex| when running \textsf{makeindex}:
\begin{verbatim}
makeindex -s gindex yourfile
\end{verbatim}
+Or if you want |\indexheading|'s to be included:
+\begin{verbatim}
+ makeindex -s gindexh yourfile
+\end{verbatim}
+
+Note also there is usually no need to run \textsf{makeindex} to fine
+tune the format.
+
+\begin{example}
+ With the following definitions, items and subitems are typeset, as
+ usual, as separate paragraphs. However, if the item has no locator,
+ and there is exactly one subitem, they are joined with a comma as
+ separator (the code is somewhat low-level):
+\begin{verbatim}
+\renewcommand\indexitem[5]{%
+ \def\next{%
+ \indexitemhang{0pt}{20pt}{:}{, }{#1}{#2}%
+ #3{#4}{#5}}%
+ \ifnum\value{indexsubitems}=1\relax
+ \ifx\\#2\\%
+ \def\next{%
+ \indexitemhang{0pt}{20pt}{:}{, }{#1, #4}{#5}}%
+ \fi
+ \fi
+ \next}
+
+\renewcommand\indexsubitem[2]{%
+ \indexitemhang{0pt}{40pt}{}{, }{--- #1}{#2}}
+\end{verbatim}
+\end{example}
+
+If an item starts with |\indexspecial|, what follows replaces the
+current item.
+\begin{example}
+With |gindex.ist|, you can generate your own headings. If you are sure
+there is nothing before |a '''| and |l '''| (actually, it can be
+anything provided it is sorted at the right place), the following two
+entries will ``group'' the items under two headings.
+\begin{verbatim}
+\index{a '''@\indexspecial\indexheading{a-k}}
+\index{l '''@\indexspecial\indexheading{l-z}}
+\end{verbatim}
+\end{example}
+
-Note also there is no need to run \textsf{makeindex} to fine tune the
-format.
\section{Internals}
@@ -148,16 +191,15 @@ The |ind| files is generated by |gindex.ist| with generic macros like:
What \textsf{gindex} does is to convert them to the above format. Some
parameters should be cuntomized in the |ist| file, however. These are:
\begin{verbatim}
-headings_flag -1
+headings_flag 0
actual '@'
quote '"'
level '!'
-page_precedence "rnaRA"
+page_precedence "rRnaA"
keyword "\\indexentry"
-delim_n ", "
\end{verbatim}
-As to |headings_flag|, the recommended way to deal with case is with
-|\indexheading|.
+As to |headings_flag|, its value is |-1| with |gindexh| and the
+recommended way to deal with case is with |\indexheading|
\end{document}
diff --git a/macros/latex/contrib/gindex/gindexh.ist b/macros/latex/contrib/gindex/gindexh.ist
new file mode 100644
index 0000000000..4c1e0d07cb
--- /dev/null
+++ b/macros/latex/contrib/gindex/gindexh.ist
@@ -0,0 +1,42 @@
+%
+% Copyright (C) 2019 Javier Bezos http://www.texnia.com
+%
+% 2019/10/07 v0.2
+%
+% This file may be distributed and/or modified under the conditions of
+% the MIT License. A version can be found at the end of this file.
+%
+% Repository: https://github.com/jbezos/gindex
+%
+% Required by gindex
+% ------------------
+
+item_0 "}\n\\addindexitem{"
+item_1 "}\n \\addindexsubitem{"
+item_01 "}\n \\addindexsubitem{"
+item_x1 "}{}\n \\addindexsubitem{"
+item_2 "}\n \\addindexsubsubitem{"
+item_12 "}\n \\addindexsubsubitem{"
+item_x2 "}{}\n \\addindexsubsubitem{"
+delim_0 "}{"
+delim_1 "}{"
+delim_2 "}{"
+group_skip "}\n%\n\\addindexskip{"
+heading_prefix "}\n%\n\\addindexheading{"
+heading_suffix "}\n%\n{"
+preamble "\\begin{theindex}\\indexpreamble\n\n{"
+postamble "}\n\\indexflushitem\\indexpostamble\\end{theindex}"
+indent_space ""
+indent_length 0
+delim_n "\\indexpagessep "
+delim_r "\\indexrangesep "
+
+% Modify to fit your own requirements
+% -----------------------------------
+
+headings_flag -1 % Usually redefining \indexheading is better
+actual '@'
+quote '"'
+level '!'
+page_precedence "rRnaA"
+keyword "\\indexentry" \ No newline at end of file