The most simple solution is to change the Command
part of the Index
entry in TeX-command-list
via M-x customize-option
RET TeX-command-list
RET.
I suggest to input
makeindex -t %s.plg -o %s.pnd %s.pdx; makeindex -t %s.slg -o %s.snd %s.sdx;
there. Afterwards click the button Apply
.
This works but it has the disadvantage that you must repeat the setting after the next restart of Emacs.
Alternatively you can change the value of TeX-command-list
buffer-locally with file local variables in the LaTeX file. That is demonstrated with the file-local variables in the next example. The LaTeX part is stolen from Gilles' answer on tex.se.
One must take care that the modification of TeX-command-list
remains buffer local. That makes the form after the ;;; eval:
a bit complicated.
Nevertheless you find the above makeindex
command line in there and you can modify according to your needs.
\documentclass{article}
\usepackage{index}
\newindex{person}{pdx}{pnd}{Index of named persons}
\newindex{symbol}{sdx}{snd}{Index of symbolism}
\begin{document}
Hello, \index*[person]{vanden} \index*[symbol]{SomeSymbol}.
\printindex[person]
\printindex[symbol]
\end{document}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% eval: (setcar (or (cl-member "Index" (setq-local TeX-command-list (copy-list TeX-command-list)) :key #'car :test #'string-equal) (setq-local TeX-command-list (cons nil TeX-command-list))) '("Index" "makeindex -t %s.plg -o %s.pnd %s.pdx; makeindex -t %s.slg -o %s.snd %s.sdx;" TeX-run-index nil t :help "makeindex for index.sty"))
%%% End:
There are several alternatives for the form in %%% eval: ...
. They all have their pros and cons.
- Using
copy-alist
(setf (alist-get "Index" (setq-local mylist (copy-alist TeX-command-list)) nil nil #'string-equal) '("makeindex -t %s.plg -o %s.pnd %s.pdx; makeindex -t %s.slg -o %s.snd %s.sdx;" TeX-run-index nil t :help "makeindex for index.sty"))
PROS:
- somewhat shorter
- Just calls to
setf
, alist-get
, and copy-alist
CONS:
- all
cons
are copied not just the modified ones
- Defining a new function in your init file
(defun modified-alist (alist &optional modifications &rest plist)
"Make a copy of ALIST and apply MODIFICATIONS.
The entries of the association list MODIFICATIONS replace the
corresponding entries of ALIST.
\nKeywords supported: :test :test-not :key
\n(fn ALIST &optional MODIFICATIONS [KEYWORD VALUE]...)"
(setq alist (cl-copy-list alist))
(dolist (m modifications)
(setcar (or (apply #'cl-member (car m) alist plist) (setq alist (cons nil alist))) m))
alist)
You can use that function in the ;;; eval:...
line:
(setq-local TeX-command-list (modified-alist TeX-command-list '(("Index" "makeindex -t %s.plg -o %s.pnd %s.pdx; makeindex -t %s.slg -o %s.snd %s.sdx;" TeX-run-index nil t :help "makeindex for index.sty")) :key #'car :test #'string-equal)
PROS:
- including the
setq-local
just two commands
- only the modified cons is copied
CONS:
- requires code in init file
(TeX-add-style-hook "index"...)
Therein: Add parsingnewindex
macros toLaTeX-auto-regexp-list
. One gets a list of the new indexes. SubstituteTeX-run-index
by an alternativemy-TeX-run-indexes
inTeX-command-list
(e.g., via customization). Inmy-TeX-run-indexes
do essentially the stuff ofTeX-run-index
for all indexes found via the list of indexes generated by the new entry inLaTeX-auto-regexp-list
.