| 1 |
%% |
| 2 |
%% This is file `luaindex.sty', |
| 3 |
%% generated with the docstrip utility. |
| 4 |
%% |
| 5 |
%% The original source files were: |
| 6 |
%% |
| 7 |
%% luaindex.dtx (with options: `package') |
| 8 |
%% |
| 9 |
%% Copyright (c) 2011 by Markus Kohm <komascript(at)gmx.info> |
| 10 |
%% |
| 11 |
%% This file was generated from file(s) of luaindex distribution. |
| 12 |
%% -------------------------------------------------------------- |
| 13 |
%% |
| 14 |
%% This work may be distributed and/or modified under the conditions of |
| 15 |
%% the LaTeX Project Public License, version 1.3c of the license. |
| 16 |
%% The latest version of this license is in |
| 17 |
%% http://www.latex-project.org/lppl.txt |
| 18 |
%% and version 1.3c or later is part of all distributions of LaTeX |
| 19 |
%% version 2005/12/01 or later. |
| 20 |
%% |
| 21 |
%% This work has the LPPL maintenance status "maintained". |
| 22 |
%% |
| 23 |
%% The Current Maintainer and author of this work is Markus Kohm. |
| 24 |
%% |
| 25 |
%% This file may only be distributed together with the files listed in |
| 26 |
%% `luaindex.dtx'. You may however distribute the files listed in |
| 27 |
%% `luaindex.dtx' without this file. |
| 28 |
%% |
| 29 |
%% NOTE: THIS IS AN ALPHA-VERSION! |
| 30 |
%% |
| 31 |
\NeedsTeXFormat{LaTeX2e}[1995/06/01] |
| 32 |
\ProvidesPackage{luaindex} |
| 33 |
[2011/02/18 v0.1b LuaLaTeX Package |
| 34 |
index processor]% |
| 35 |
\RequirePackage{ifluatex} |
| 36 |
\ifluatex\else |
| 37 |
\PackageError{luaindex}{lualatex needed}{% |
| 38 |
Package `luaindex' needs LuaTeX.\MessageBreak |
| 39 |
So you should use `lualatex' to process you document!\MessageBreak |
| 40 |
See documentation of `luaindex' for further information.}% |
| 41 |
\expandafter\expandafter\expandafter\csname endinput\endcsname |
| 42 |
\fi |
| 43 |
\RequirePackage{luatexbase-compat}[2010/10/10] |
| 44 |
\RequirePackage{luatexbase-modutils}[2010/10/10] |
| 45 |
\luatexbase@ensure@primitive{luaescapestring} |
| 46 |
\directlua{% |
| 47 |
if not tex.error then |
| 48 |
luatexbase.module_error('luaindex', |
| 49 |
'undefined function!\string\n% |
| 50 |
LuaTeX function tex.error() needed but not defined.\string\n% |
| 51 |
Maybe you are using the wrong version of LuaTeX.') |
| 52 |
end |
| 53 |
if not tex.print then |
| 54 |
luatexbase.module_error('luaindex', |
| 55 |
'undefined function!\string\n% |
| 56 |
LuaTeX function tex.print() needed but not defined.\string\n% |
| 57 |
Maybe you are using the wrong version of LuaTeX.') |
| 58 |
end |
| 59 |
if not tex.sprint then |
| 60 |
luatexbase.module_error('luaindex', |
| 61 |
'undefined function!\string\n% |
| 62 |
LuaTeX function tex.sprint() needed but not defined.\string\n% |
| 63 |
Maybe you are using the wrong version of LuaTeX.') |
| 64 |
end |
| 65 |
} |
| 66 |
\RequireLuaModule{luaindex} |
| 67 |
\newwrite\@indexfile |
| 68 |
\AtBeginDocument{% |
| 69 |
\IfFileExists{\jobname.ldx}{\directlua{dofile('\jobname.ldx')}}{}% |
| 70 |
\openout\@indexfile=\jobname.ldx |
| 71 |
} |
| 72 |
\RequirePackage{scrbase} |
| 73 |
\DefineFamily{luaindex} |
| 74 |
\DefineFamilyMember{luaindex} |
| 75 |
\newcommand*{\luaindex@sortorder}{} |
| 76 |
\DefineFamilyKey{luaindex}{sortorder}{% |
| 77 |
\edef\luaindex@sortorder{#1}% |
| 78 |
} |
| 79 |
\DefineFamilyKey{luaindex}{locale}{% |
| 80 |
\if@atdocument |
| 81 |
\expandafter\@firstofone |
| 82 |
\else |
| 83 |
\expandafter\AtBeginDocument |
| 84 |
\fi |
| 85 |
{% |
| 86 |
\protected@write\@indexfile{}{% |
| 87 |
os.setlocale('#1','collate') |
| 88 |
}% |
| 89 |
}% |
| 90 |
} |
| 91 |
\newcommand*{\luaindex@pageformat}{} |
| 92 |
\DefineFamilyKey{luaindex}{pageformat}{% |
| 93 |
\def\luaindex@pageformat{#1}% |
| 94 |
} |
| 95 |
\FamilyBoolKey{luaindex}{singlepass}{@luaindexsinglepass} |
| 96 |
\FamilyProcessOptions{luaindex}\relax |
| 97 |
\newcommand*{\setupluaindex}{\FamilyOptions{luaindex}} |
| 98 |
\newcommand*\see[2]{\emph{\seename} #1} |
| 99 |
\providecommand*\seealso[2]{\emph{\alsoname} #1} |
| 100 |
\providecommand\seename{see} |
| 101 |
\providecommand*\alsoname{see also} |
| 102 |
\newcommand*{\newindex}[2][]{% |
| 103 |
\directlua{luaindex.newindex('\luatexluaescapestring{#2}')}% |
| 104 |
\begingroup |
| 105 |
\setupluaindex{#1}% |
| 106 |
\ifx\luaindex@sortorder\@empty\else |
| 107 |
\AtBeginDocument{% |
| 108 |
\protected@write\@indexfile{}{% |
| 109 |
luaindex.sortorder('\luatexluaescapestring{#2}', |
| 110 |
'\luaindex@sortorder') |
| 111 |
}}% |
| 112 |
\fi |
| 113 |
\endgroup |
| 114 |
} |
| 115 |
\@onlypreamble\newindex |
| 116 |
\newcommand*{\luaindex}[1]{% |
| 117 |
\@bsphack |
| 118 |
\begingroup |
| 119 |
\edef\luaindex@name{#1}% |
| 120 |
\lua@index |
| 121 |
} |
| 122 |
\newcommand*{\lua@index}[2][]{% |
| 123 |
\set@display@protect |
| 124 |
\edef\luaindex@sort{#2}% |
| 125 |
\define@key{luaindex.setindex}{sort}{\edef\luaindex@sort{##1}}% |
| 126 |
\define@key{luaindex.setindex}{pageformat}{\def\luaindex@pageformat{##1}}% |
| 127 |
\define@key{luaindex.setindex}{locale}{\luaindexsetup{locale=#1}}% |
| 128 |
\setkeys{luaindex.setindex}{#1}% |
| 129 |
\protected@write\@indexfile{\let\luatexluaescapestring\relax}{% |
| 130 |
luaindex.insert('\luatexluaescapestring{\luaindex@name}', |
| 131 |
'{\luatexluaescapestring{\luaindex@pageformat{\thepage}}}', |
| 132 |
'\luatexluaescapestring{\luaindex@sort}', |
| 133 |
'\luatexluaescapestring{#2}') |
| 134 |
}% |
| 135 |
\endgroup |
| 136 |
\@esphack |
| 137 |
} |
| 138 |
\newcommand*{\luasubindex}[1]{% |
| 139 |
\@bsphack |
| 140 |
\begingroup |
| 141 |
\edef\luaindex@name{#1}% |
| 142 |
\lua@subindex |
| 143 |
} |
| 144 |
\newcommand*{\lua@subindex}[2][]{% |
| 145 |
\set@display@protect |
| 146 |
\edef\luaindex@sort{#2}% |
| 147 |
\define@key{luaindex.setindex}{sort}{\edef\luaindex@sort{##1}}% |
| 148 |
\define@key{luaindex.setindex}{pageformat}{\def\luaindex@pageformat{##1}}% |
| 149 |
\define@key{luaindex.setindex}{locale}{\luaindexsetup{locale=#1}}% |
| 150 |
\setkeys{luaindex.setindex}{#1}% |
| 151 |
\protected@write\@indexfile{\let\luatexluaescapestring\relax}{% |
| 152 |
luaindex.insert('\luatexluaescapestring{\luaindex@name}', |
| 153 |
'{\luatexluaescapestring{\luaindex@pageformat{\thepage}}}', |
| 154 |
'\luatexluaescapestring{\luaindex@sort}', |
| 155 |
'\luatexluaescapestring{#2}', |
| 156 |
}% |
| 157 |
\aftergroup\lua@@subindex |
| 158 |
\endgroup |
| 159 |
} |
| 160 |
\newcommand*{\lua@@subindex}[2][]{% |
| 161 |
\begingroup |
| 162 |
\set@display@protect |
| 163 |
\edef\luaindex@sort{#2}% |
| 164 |
\define@key{luaindex.setindex}{sort}{\edef\luaindex@sort{##1}}% |
| 165 |
\setkeys{luaindex.setindex}{#1}% |
| 166 |
\protected@write\@indexfile{\let\luatexluaescapestring\relax}{% |
| 167 |
\@spaces |
| 168 |
'\luatexluaescapestring{\luaindex@sort}', |
| 169 |
'\luatexluaescapestring{#2}') |
| 170 |
}% |
| 171 |
\endgroup |
| 172 |
\@esphack |
| 173 |
} |
| 174 |
\newcommand*{\luasubsubindex}[1]{% |
| 175 |
\@bsphack |
| 176 |
\begingroup |
| 177 |
\edef\luaindex@name{#1}% |
| 178 |
\lua@subsubindex |
| 179 |
} |
| 180 |
\newcommand*{\lua@subsubindex}[2][]{% |
| 181 |
\set@display@protect |
| 182 |
\edef\luaindex@sort{#2}% |
| 183 |
\define@key{luaindex.setindex}{sort}{\edef\luaindex@sort{##1}}% |
| 184 |
\define@key{luaindex.setindex}{pageformat}{\def\luaindex@pageformat{##1}}% |
| 185 |
\define@key{luaindex.setindex}{locale}{% |
| 186 |
\luaindexsetup{locale=#1}% |
| 187 |
} |
| 188 |
\setkeys{luaindex.setindex}{#1}% |
| 189 |
\protected@write\@indexfile{\let\luatexluaescapestring\relax}{% |
| 190 |
luaindex.insert('\luatexluaescapestring{\luaindex@name}', |
| 191 |
'{\luatexluaescapestring{\luaindex@pageformat{\thepage}}}', |
| 192 |
'\luatexluaescapestring{\luaindex@sort}', |
| 193 |
'\luatexluaescapestring{#2}', |
| 194 |
}% |
| 195 |
\aftergroup\lua@@@subindex |
| 196 |
\endgroup |
| 197 |
} |
| 198 |
\newcommand*{\lua@@@subindex}[2][]{% |
| 199 |
\begingroup |
| 200 |
\set@display@protect |
| 201 |
\edef\luaindex@sort{#2}% |
| 202 |
\define@key{luaindex.setindex}{sort}{\edef\luaindex@sort{##1}}% |
| 203 |
\setkeys{luaindex.setindex}{#1}% |
| 204 |
\protected@write\@indexfile{\let\luatexluaescapestring\relax}{% |
| 205 |
\@spaces |
| 206 |
'\luatexluaescapestring{\luaindex@sort}', |
| 207 |
'\luatexluaescapestring{#2}', |
| 208 |
}% |
| 209 |
\aftergroup\lua@@subindex |
| 210 |
\endgroup |
| 211 |
} |
| 212 |
\renewcommand*{\makeindex}{% |
| 213 |
\newindex{general}% |
| 214 |
\renewcommand*\index{\luaindex{general}}% |
| 215 |
\newcommand*\subindex{\luasubindex{general}}% |
| 216 |
\newcommand*\subsubindex{\luasubsubindex{general}}% |
| 217 |
} |
| 218 |
\newcommand*{\printindex}[1][]{% |
| 219 |
\begingroup |
| 220 |
\edef\luaindex@name{general}% |
| 221 |
\define@key{luaindex.setindex}{index}{\edef\luaindex@name{##1}}% |
| 222 |
\define@key{luaindex.setindex}{singlepass}[true]{% |
| 223 |
\setupluaindex{singlepass}{##1}% |
| 224 |
}% |
| 225 |
\setkeys{luaindex.setindex}{#1}% |
| 226 |
\if@luaindexsinglepass |
| 227 |
\closeout\@indexfile |
| 228 |
\clearpage |
| 229 |
\directlua{% |
| 230 |
luaindex.removeentries('\luatexluaescapestring{\luaindex@name}') |
| 231 |
dofile('\jobname.ldx') |
| 232 |
}% |
| 233 |
\fi |
| 234 |
\directlua{% |
| 235 |
luaindex.printindex('\luatexluaescapestring{\luaindex@name}') |
| 236 |
}% |
| 237 |
\endgroup |
| 238 |
} |
| 239 |
\providecommand*{\indexgroup}[1]{% |
| 240 |
\indexspace\textbf{#1}\nopagebreak |
| 241 |
} |
| 242 |
\providecommand*{\indexspace}{% |
| 243 |
\def\indexspace{\vskip\baselineskip} |
| 244 |
} |
| 245 |
\providecommand*{\symbolsname}{Symbols} |
| 246 |
\providecommand*{\numbersname}{Numbers} |
| 247 |
\AtBeginDocument{% |
| 248 |
\providecaptionname{english}\symbolsname{Symbols}% |
| 249 |
\providecaptionname{english}\numbersname{Numbers}% |
| 250 |
\providecaptionname{german}\symbolsname{Symbole}% |
| 251 |
\providecaptionname{german}\numbersname{Zahlen}% |
| 252 |
\providecaptionname{ngerman}\symbolsname{Symbole}% |
| 253 |
\providecaptionname{ngerman}\numbersname{Zahlen}% |
| 254 |
\providecaptionname{austrian}\symbolsname{Symbole}% |
| 255 |
\providecaptionname{austrian}\numbersname{Zahlen}% |
| 256 |
\providecaptionname{naustrian}\symbolsname{Symbole}% |
| 257 |
\providecaptionname{naustrian}\numbersname{Zahlen}% |
| 258 |
\providecaptionname{french}\symbolsname{Symbole}% |
| 259 |
\providecaptionname{french}\numbersname{Chiffres}% |
| 260 |
\providecaptionname{spanish}\symbolsname{Simbolos}% |
| 261 |
\providecaptionname{spanish}\numbersname{N\'umeros}% |
| 262 |
} |
| 263 |
\providecommand*{\indexpagenumbers}[1]{% |
| 264 |
\def\index@pagenumbersep{\let\index@pagenumbersep\indexpagenumbersep}% |
| 265 |
\nobreakspace-- #1} |
| 266 |
\providecommand*{\indexpagenumber}[1]{\index@pagenumbersep #1} |
| 267 |
\providecommand*{\indexpagenumbersep}{, } |
| 268 |
\endinput |
| 269 |
%% |
| 270 |
%% End of file `luaindex.sty'. |