
我必須如何更改arara
以下命令才能列印名稱索引?就目前情況而言,我只得到主索引。
% arara: pdflatex
% arara: bibtex
% arara: pdflatex
% arara: pdflatex
% arara: nomencl
% arara: makeindex
% arara: pdflatex
% arara: pdflatex
% !arara: indent: { overwrite: false, output: outputfile.tex, trace: true }
\documentclass{memoir}
\usepackage[backend=bibtex,style=numeric]{biblatex}
\addbibresource{mybib.bib}
\usepackage{nomencl}
\makenomenclature
\makeindex
\makeindex[names]
\begin{document}
\chapter{Area} \label{chap:area}
\section{Area of a circle} \label{sec:circle-area}
Consult \textcite{Archimedes200} and \textcite{EulerE1776}.
\index[names]{Archimedes}
\index[names]{Euler, Leonhard}
The area $A$
\nomenclature{$A$}{area}%
of a circle with radius $r$
\nomenclature{$r$}{radius of circle}%
is defined as
\begin{equation}
A = \pi r^{2}.
\end{equation}
\index{area!of circle}
\index{area}
\index{circle!area of}
\printbibliography
\printnomenclature
\renewcommand{\indexname}{Index of Names}
\printindex[names]
\renewcommand{\indexname}{Index}
\printindex
\end{document}
這是文件mybib.bib
:
@article{Archimedes200,
author = {Archimedes},
title = {Pi's the limit},
journal = {Syracuse J. Gastronom.\ Math.},
year = {200BCE},
volume = {10},
pages={\textsc{CCCXV}--\textsc{CCCXIV}}
}
@article{EulerE1776,
author = {Euler, Leonhard},
title = {All about E},
journal = {Math.\ Psychol.},
year = {1776},
volume = {4},
pages={1--2718}
}
答案1
感謝 Paulo,他向我展示了這一點:所有arara
規則都有一個名為 的隱式參數files
,它採用(逗號分隔的)檔案名稱清單。arara
然後將迭代此列表並將該指令應用於列表中的每個項目。
另一點是,您不需要在 BibTeX 和 MakeIndex 之間運行兩次 pdfLaTeX:第一次運行 pdfLaTeX 足以為外部工具產生輔助檔案。最後兩次運行 pdfLaTeX 是必要的,以包含生成的參考書目/索引並整理交叉引用。
您的指令清單可以變更為:
% arara: pdflatex
% arara: bibtex
% arara: makeindex
% arara: makeindex: { files: [ names ] }
% arara: pdflatex
% arara: pdflatex
也許makeindex
只用一行替換兩行(假設您的主.tex
文件是main.tex
):% arara: makeindex: { files: [ main, names ] }
。
或者,如果您想arara
聰明一點並跳過不必要的步驟(解釋這裡):
% 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)')
正如 barbarabeeton 在評論中提到的,另一個選擇是從 pdfLaTeX 中imakeidx
運行的套件。makeindex
由於makeindex
它是受信任的程序,因此允許它在通常啟用的受限 shell 轉義中運行。該imakeidx
包已經處理了多個索引和所有內容。
要使用它,您只需使用 加載它\usepackage{makeindex}
,然後用\makeindex[names]
替換\makeindex[name=names]
。
然而,repeatindex
您使用的軟體包似乎與imakeidx
...不相容,我會嘗試找出原因。
或者,如果您喜歡看起來像個酷孩子(像我一樣,在被告知參數之前就完成了所有這些files
:-)並且以困難的方式完成它,您可以對文件進行小的修改makeindex.yaml
並添加一個basename
選項,此選項需要索引檔案的基本名稱(names
在您的情況下)並對其進行處理而不是當前檔案名稱。
首先,arguments:
在該行下方makeindex.yaml
新增選項本身:
- identifier: basename
flag: >
@{
parameters.basename
}
(顯然,出於某種原因,Java 不喜歡僅使用base
,所以我使用了更詳細的basename
。)我們設定此選項沒有預設值,因此當它為空時,我們使用getBasename(file)
。
現在我們修改該command:
部分以使用該選項:
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);
}
首先我們檢查是否basename
為空;如果是,則使用 中的目前檔案名稱getBasename(file)
。然後繼續正常新增輸入、輸出和日誌檔案的副檔名,然後呼叫makeindex
可執行檔。
makeindex.yaml
(為了方便起見,本答案底部的完整文件修改版本)
之後,您可以將指令變更為:
% arara: pdflatex
% arara: bibtex
% arara: makeindex
% arara: makeindex: { basename: names }
% arara: pdflatex
% arara: pdflatex
pdflatex
(請注意,我之前刪除了這兩個規則makeindex
:您不需要它們。)
現在您應該已經正確編譯了索引。
如果您沒有對原始副本進行更改makeindex.yaml
(您確實應該不是),然後您需要將新makeindex.yaml
文件保存在某個資料夾中,然後建立一個.araraconfig.yaml
包含以下內容的文件:
paths:
- '/path/to/the/folder/'
並將其放入.araraconfig.yaml
當前工作目錄或USER_HOME
資料夾中(有關更多信息,請參閱 arara 手冊第 4 章)。如果該makeindex.yaml
檔案也在目前工作目錄中,您可以- './'
在設定檔的第二行中使用。
完整makeindex.yaml
文件:
!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.');
}
}