Credits to Paulo, for showing me this: all arara rules have an implicit parameter called files, which takes a (comma-separated) list of file names. arara will then iterate in this list and apply that directive to each item in the list.
Another point is that you don't need the two pdfLaTeX runs between BibTeX and MakeIndex: the first run of pdfLaTeX is enough to generate the auxiliary files for the external tools. The final two runs of pdfLaTeX are necessary to include the generated bibliographies/indexes and sort out cross references.
Your list of directives could be changed to:
% arara: pdflatex
% arara: bibtex
% arara: makeindex
% arara: makeindex: { files: [ names ] }
% arara: pdflatex
% arara: pdflatex
and perhaps replace the two makeindex lines by only one (supposing your main .tex file is main.tex): % arara: makeindex: { files: [ main, names ] }.
Or, if you want arara to be clever and skip unnecessary steps (explanation here):
% arara: pdflatex: { draft: yes }
% arara: bibtex if changed (toFile('mybib.bib'))
% arara: --> || found ('log', 'Warning: Citation')
% arara: makeindex: { files: [ main, names ] } if changed ('idx')
% arara: pdflatex until !found('log', '\\(?(R|r)e\\)?run (to get|LaTeX)')
Another option, as barbarabeeton mentioned in the comment, is the imakeidx package, which runs makeindex from within pdfLaTeX. Since makeindex is a trusted program, it is allowed to run in restricted shell-escape, which is usually enabled. The imakeidx package already takes care of multiple indexes and everything.
To use it you would just need to load it with \usepackage{makeindex}, and repalce \makeindex[names] by \makeindex[name=names].
However the repeatindex package you use seems to be incompatible with imakeidx... I'll try to figure out why.
Or, if you prefer to look like the cool kid (like me, who did all this before being told of the files parameter :-) and do it the hard way, you can make a small modification to the makeindex.yaml file and add a basename option which takes the base name of the index file (names, in your case) and works on it instead of the current file name.
First, below the arguments: line in makeindex.yaml you add the option itself:
- identifier: basename
flag: >
@{
parameters.basename
}
(apparently Java doesn't like if you use only base, for some reason, so I used the more verbose basename.) We set this option without a default value, so that when it's empty we use getBasename(file).
Now we modify the command: section to use that option:
command: >
@{
if (isEmpty(basename))
{ basename = getBasename(file); }
infile = basename.concat('.').concat(input);
outfile = [ '-o', basename.concat('.').concat(output) ];
logfile = [ '-t', basename.concat('.').concat(log) ];
return getCommand('makeindex', german, style, order, options,
logfile, infile, outfile);
}
first we check if basename is empty; if it is, use the current file name from getBasename(file). Then proceed normally adding the extensions of the input, output, and log files, and then calling the makeindex executable.
(complete modified version of makeindex.yaml file at the bottom of this answer, for your convenience)
After that, you can change your directives to:
% arara: pdflatex
% arara: bibtex
% arara: makeindex
% arara: makeindex: { basename: names }
% arara: pdflatex
% arara: pdflatex
(note that I removed the two pdflatex rules before makeindex: you don't need those.)
And you should now have the index compiled correctly.
If you didn't make the change in the original copy of makeindex.yaml (which you should really not), then you need to save the new makeindex.yaml file in some folder, and then create a .araraconfig.yaml file which contains:
paths:
- '/path/to/the/folder/'
and put this .araraconfig.yaml in the current working directory or in your USER_HOME folder (see the arara manual, chapter 4 for more on that). If the makeindex.yaml file is also in the current working directory you can use - './' in the second line of the config file.
Full makeindex.yaml file:
!config
# Arara, the cool TeX automation tool
# Copyright (c) 2018, Paulo Roberto Massa Cereda
# All rights reserved.
#
# This rule is part of arara.
identifier: nmakeindex
name: MakeIndex
authors:
- Marco Daniel
- Paulo Cereda
commands:
- name: The MakeIndex software
command: >
@{
if (isEmpty(basename))
{ basename = getBasename(file); }
infile = basename.concat('.').concat(input);
outfile = [ '-o', basename.concat('.').concat(output) ];
logfile = [ '-t', basename.concat('.').concat(log) ];
return getCommand('makeindex', german, style, order, options,
logfile, infile, outfile);
}
arguments:
- identifier: basename
flag: >
@{
parameters.basename
}
- identifier: input
flag: >
@{
parameters.input
}
default: idx
- identifier: output
flag: >
@{
parameters.output
}
default: ind
- identifier: log
flag: >
@{
parameters.log
}
default: ilg
- identifier: german
flag: >
@{
isTrue(parameters.german, '-g')
}
- identifier: order
flag: >
@{
if ([ 'letter', 'word' ].contains(parameters.order)) {
return isTrue(parameters.order == 'letter', '-l', '');
}
else {
throwError('The provided order is invalid.');
}
}
- identifier: style
flag: "@{ [ '-s', parameters.style ] }"
- identifier: options
flag: >
@{
if (isList(parameters.options)) {
return parameters.options;
}
else {
throwError('I was expecting a list of options.');
}
}
ararahas a built-in way of doing this task, and for some reason, he decided to delete it. I will poke him to undelete the answer and add an addendum to the quick way of doing it.:)– Paulo Cereda Aug 23 '19 at 20:52% arara: makeindex: { files: [ names ] }and have fun.:)– Paulo Cereda Aug 23 '19 at 20:53