3

Consider the following MWE (say test.tex), to be compiled with:

  1. pdflatex test
  2. texindy -M test.xdy test.idx
  3. pdflatex test

where the changes are listed thanks to a (slightly) customized index (I don't need the \RecordChanges, \PrintChanges, \changes machinery provided by the doc package).

\documentclass{article}
\usepackage[xindy,nonewpage]{imakeidx}
\usepackage{filecontents}

\begin{filecontents*}{\jobname.xdy}
(markup-index :open  "~n
\begin{theindex}
  \small
  \providecommand*\lettergroupDefault[1]{}
  \providecommand*\lettergroup[1]{}
  ~n"
  :close "~n~n\end{theindex}~n"
:tree)
\end{filecontents*}

\makeindex[title=Change History,columns=1,options=-M \jobname.xdy]

\newcommand\changes[2]{\index{#1!#2}}
\newcommand\PrintChanges{\printindex}

\begin{document}
\changes{v1.0}{First public version}%
\changes{v2.0}{Second public version (much better)}%
%
This is a nice document but its next version will be much better.
%
\PrintChanges
\end{document}

enter image description here

That's nice but the last changes are in last position and that wouldn't be very handy if the change history would become lengthy, especially for an assiduous reader who regularly wants to check the last changes.

Hence, what would be nice would be a change history (and therefore here an index) in the reverse order. (Notice that this request is valid for change history as provided by doc package as well.)

Update

Thanks to egreg's suggestion, I tried to make use of define-sort-rule-orientations command for which manual says:

This command must precede all sort-rule commands in an index style.

OK, let's try to do so. Running texindy with the -d script option let us see that, in fact, running:

texindy -d script test.idx

in fact runs:

xindy -d script -L general -C latin -M tex/inputenc/latin -M texindy -M page-ranges -M word-order -I latex test.idx

But, even reduced to its minimum:

xindy -d script test.idx

running xindy loads the module latin9-lang.xdy, containing:

(require "lang/general/latin9.xdy")
(define-sort-rule-orientations (forward backward forward forward))
(use-rule-set :run 0
          :rule-set ("xy-alphabetize" "xy-ignore-special"))
(use-rule-set :run 1
          :rule-set ("xy-resolve-diacritics" "xy-ignore-special"))
(use-rule-set :run 2
          :rule-set ("xy-resolve-case" "xy-ignore-special"))
(use-rule-set :run 3
          :rule-set ("xy-resolve-special"))

Hence, it's seems impossible to specify another define-sort-rule-orientations before all sort-rule.

Hence, the question remains: how get an (xindy) index in the reverse order?

2
  • 1
    The manual is unreadable, but I think that define-sort-rule-orientations is what you need.
    – egreg
    Oct 25, 2016 at 10:29
  • @egreg I agree with you about readability of the manual :$ Oct 25, 2016 at 14:58

1 Answer 1

1

Sorry for this late answer: I found this thread a few days ago while investigating about printing in reverse order the change history of babel-french.

Here are some thoughts about the question asked by Denis.

  1. Using "define-sort-rule-orientations" is not an option: it is meant for reading patterns from left to right (forward) or from right to left (backwards) during the 4 sorting phases, not for reverse sorting; see http://xindy.sourceforge.net/doc/new-sort-rules.ps

  2. Running xindy (or texindy) on an index or glossary produced by LaTeX, XeLaTeX or LuaLaTeX, involves the binary "tex2indy" which converts the ".idx" or ".glo" file into a format readable by xindy. Unfortunately, some character codes (i.e. those defined by \levelchar, \actualchar, \quotechar) are hardcoded into the binary to the defaults of ".idx" files; as "doc.sty" changes them, tex2indy is inappropriate to convert a ".glo" file procuded using doc.sty.

  3. Hence, it looks mandatory to bypass "tex2indy" with a home-made filter able to convert the ".glo" file into the internal format readable by "xindy -I xindy".

    Example for a ".glo" entry produced by doc.sty:

    \changes{v.2.3c}{2001/01/01}{Foo changed into Bar} occurring on page 15, not embedded in a \begin{macro}...\end{macro} environment, produces

    \glossaryentry{v2.3c> =General:>Foo changed into Bar}{15}

    It should be converted into xindy internal syntax which looks like this:

    (indexentry :tkey (("sort-key0" "v2.3c") ("sort-key1" "General:") (" Foo changed into Bar")) :locref "15")

  4. The filter (relying on regular expressions) can be written f.i. in Perl, Lua, etc.

    -- "sort-key0" can be derived from version number 2.3c (in ascending or descending order) to implement normal or reverse sorting without changing anything in xindy modules.

    -- "sort-key1" can be chosen to sort these changes before (or after) those made inside {macro} environments.

  5. Running "xindy -I xindy" with an appropriate style module ("-M style.xdy") would generate the final, properly sorted, ".gls" file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .