Debian Codegraph @

texmf-dist/doc/latex/sanitize-umlaut/sanitize-umlaut.tex

raw
1 % \LaTeX-Main\
2 % !TeX encoding=UTF-8
3 % !TeX spellcheck=en_US
4 %%
5 %% The LaTeX package sanitize-umlaut - version 1.4.0 (2026/02/10)
6 %% sanitize-umlaut.tex: Manual
7 %%
8 %% -------------------------------------------------------------------------------------------
9 %% Copyright (c) 2016-2026 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
10 %% -------------------------------------------------------------------------------------------
11 %%
12 %% This work may be distributed and/or modified under the
13 %% conditions of the LaTeX Project Public License, either version 1.3
14 %% of this license or (at your option) any later version.
15 %% The latest version of this license is in
16 %% https://www.latex-project.org/lppl.txt
17 %% and version 1.3c or later is part of all distributions of LaTeX
18 %% version 2008 or later.
19 %%
20 %% This work has the LPPL maintenance status `author-maintained'.
21 %%
22 %% This work consists of all files listed in README.md
23 %%
24 \documentclass[a4paper,11pt]{ltxdoc}
25
26 \usepackage{sanitize-umlaut.doc}
27 \usepackage{%
28 sanitize-umlaut}
29
30 \def\version{1.4.0}%
31 \def\datum{2026/02/10}%
32
33 \hypersetup{
34 pdftitle={Manual for the sanitize-umlaut package},
35 pdfauthor={Thomas F. Sturm},
36 pdfsubject={sanitize umlauts for makeindex},
37 pdfkeywords={index, umlauts, makeindex, pdflatex}
38 }
39
40
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 \begin{document}
43
44 \begin{center}
45 \begin{tcolorbox}[enhanced,hbox,tikznode,left=8mm,right=8mm,boxrule=0.4pt,
46 colback=white,colframe=black!50!yellow,
47 drop lifted shadow=black!50!yellow,arc is angular,
48 before=\par\vspace*{5mm},after=\par\bigskip]
49 {\bfseries\LARGE The \texttt{sanitize-umlaut} package}\\[3mm]
50 {\large Manual for version \version\ (\datum)}
51 \end{tcolorbox}
52 {\large Thomas F.~Sturm%
53 \footnote{Prof.~Dr.~Dr.~Thomas F.~Sturm, Institut f\"{u}r Mathematik und Informatik,
54 University of the Bundeswehr Munich, D-85577 Neubiberg, Germany;
55 email: \href{mailto:[email protected]}{[email protected]}}\par\medskip
56 \normalsize\url{https://www.ctan.org/pkg/sanitize-umlaut}\par
57 \url{https://github.com/T-F-S/sanitize-umlaut}
58 }
59 \end{center}
60 \bigskip
61 \begin{absquote}
62 \begin{center}\bfseries Abstract\end{center}
63 The packages sanitizes umlauts to be used directly in index entries for
64 MakeIndex and friends with |pdflatex|. This means, that inside |\index| an umlaut can
65 be used as \texttt{"U} or \texttt{Ü}. In both cases, the letter is written
66 as \texttt{"U} into the raw index file for correct processing with MakeIndex
67 and |pdflatex|. |lualatex| and |xelatex| are also supported with a different approach.
68 \end{absquote}
69
70 \begin{tcolorbox}[breakable,enhanced jigsaw,title={Contents},fonttitle=\bfseries\Large,
71 colback=yellow!10!white,colframe=red!50!black,before=\par\bigskip\noindent,
72 colbacktitle=red!50!yellow!75!black,
73 enlargepage flexible=\baselineskip,pad at break*=3mm,
74 attach boxed title to top center={yshift=-0.25mm-\tcboxedtitleheight/2,yshifttext=2mm-\tcboxedtitleheight/2},
75 boxed title style={enhanced,boxrule=0.5mm,
76 frame code={ \path[tcb fill frame] ([xshift=-4mm]frame.west) -- (frame.north west)
77 -- (frame.north east) -- ([xshift=4mm]frame.east)
78 -- (frame.south east) -- (frame.south west) -- cycle; },
79 interior code={ \path[tcb fill interior] ([xshift=-2mm]interior.west)
80 -- (interior.north west) -- (interior.north east)
81 -- ([xshift=2mm]interior.east) -- (interior.south east) -- (interior.south west)
82 -- cycle;} },
83 drop fuzzy shadow]
84 \makeatletter
85 \@starttoc{toc}
86 \makeatother
87 \end{tcolorbox}
88
89 \clearpage
90 \section{Purpose of the Package}%
91 The package sanitizes umlauts to be used directly in index entries for
92 |makeindex| and friends with |pdflatex|. This means, that inside |\index| an umlaut can
93 be used as \myverb{"U} or \myverb{Ü}. In both cases, the letter is written
94 as \myverb{"U} into the raw index file for correct processing with |makeindex|
95 and |pdflatex|.
96
97 The package is intended
98 \begin{itemize}
99 \item for documents in German language using the babel package with a setting
100 identical or similar to \myverb{\usepackage[ngerman]{babel}}.
101 \item for documents which are processed by |latex| or |pdflatex| (also for |lualatex| or |xelatex|,
102 but with more compilation overhead).
103 \item for documents with an index which is processed using the
104 MakeIndex program.
105 \item for authors who like to use \myverb{\index{Übermaß}} instead of
106 \myverb{\index{"Uberma"s}}.
107 \end{itemize}
108
109 All these conditions are satisfiable by simply including the |sanitize-umlaut|
110 package.
111
112 An alternative would be to filter the resulting raw \myverb{.idx} index
113 \emph{before} |makeindex| is applied to create the final \myverb{.ind} index.
114 Another alternative is to replace MakeIndex by Upmendex or another index
115 processor.
116
117 \clearpage
118 \section{Important Compatibility Informations}%
119
120 \subsection{Past}
121 Until 2018, the default encoding for \LaTeX\ files was 7-bit ASCII.
122 For other encodings, packages like |inputenc| had to be loaded.
123 Also, |inputenc| used to expand characters like umlauts during |\index| output.
124 The package |sanitize-umlaut| version 1.00 replaced this expansion code
125 for |\index| output to get \myverb{"U} instead of \myverb{Ü}, etc.
126
127 \subsection{Present}
128 Since April 2018, the default encoding for \LaTeX\ files has been changed to UTF-8.
129 This is done by preloading the UTF-8 settings of the package |inputenc|
130 by default \LaTeX, i.e. if you want to use UTF-8 (recommended!), you do not
131 longer need to load |inputenc| inside your preamble.
132 But, also the implementation of |inputenc| changed for UTF-8 (October 2019?).
133 Nowadays, characters like umlauts are not longer expanded during |\index| output,
134 but are preserved as is.
135 Therefore, |sanitize-umlaut| version 1.00 \textbf{is not compatible} to
136 |inputenc| with UTF-8 dating from 2019 or newer.
137
138 |sanitize-umlaut| version 1.10 (or newer) patches some UTF-8 code of
139 \LaTeX/|inputenc| to return and replace character expansion during |\index| output.
140 This patch \textbf{is not compatible} to older versions of \LaTeX/|inputenc| (before October 2019).
141 Therefore, if your \LaTeX\ distribution is not reasonable up to date, you
142 should stay at version 1.00 of |sanitize-umlaut|.
143
144 With the 2022 June release of \LaTeX, characters defined via |utf8.def| are now
145 defined as |\protected| macros. Therefore, |sanitize-umlaut| version 1.2.0 (or newer)
146 patches some relevant parts of two-octets characters during |\index| back to
147 pre 2022 June behaviour. Obviously, you loose |\protected| here, if you
148 load |sanitize-umlaut|.
149
150 |sanitize-umlaut| version 1.3.0 (or newer) also supports |lualatex| and |xelatex|
151 with a different approach. Here, |\index| is patched such that its argument
152 is processed to replace umlauts.
153
154 \subsection{Future}
155 As always, the future is uncertain and difficult to predict. Further changes to
156 the |inputenc| implementation may necessitate additional changes to
157 |sanitize-umlaut|. Hopefully, this will not occur too soon or too frequently.
158
159 It is also conceivable that, at some point, MakeIndex may be updated to properly
160 recognize UTF-8, rendering |sanitize-umlaut| obsolete. More likely, however, is
161 that another index processor will eventually replace MakeIndex.
162
163 See Section~\ref{upmendex} for |upmendex| as a candidate for a nearly drop-in replacement.
164
165
166 \clearpage
167 \section{Package Usage}%
168
169 \subsection{Prerequisites}
170 The source document may need some encoding by |inputenc| since |pdflatex|
171 is assumed as engine. For example:
172
173 \begin{dispListing}
174 \usepackage[latin1]{inputenc}
175 \end{dispListing}
176
177 For |utf8| (UTF-8), modern \LaTeX\ does not need this package inclusion any more!
178 Also, for |lualatex| and |xelatex| this has to be omitted.
179
180 Just some few encodings are supported by |sanitize-umlaut|.
181 These are the most important for German language texts:
182
183 \tcbox[center,size=minimal,enhanced,frame hidden,colback=red!10]{\begin{tabular}{>{\ttfamily}l>{\ttfamily}l}\toprule
184 \textnormal{\bfseries encoding} & \textnormal{\bfseries recognized as}\\\midrule
185 utf8 & utf8\\
186 utf8-2018 & utf8-2018\\
187 latin1, ansinew, cp1252 & latin1\\
188 applemac & applemac\\\bottomrule
189 \end{tabular}}
190
191 Further, the |babel| package with German settings is needed:
192
193 \begin{dispListing}
194 \usepackage[ngerman]{babel}
195 \end{dispListing}
196
197 \subsection{Package Application}
198 Now, the package application is simple. You just put
199
200 \begin{dispListing}
201 \usepackage{sanitize-umlaut}
202 \end{dispListing}
203
204 into your document preamble \emph{after} |inputenc| and, maybe, after |babel|.
205 That is all.
206
207
208 \subsection{Sanitized Characters}
209
210 The umlauts and the sharp s are replaced by their |babel| shorthand codes
211 which are written to the \myverb{.idx} file.
212
213 \tcbox[center,size=minimal,enhanced,frame hidden,colback=red!10]{\begin{tabular}{>{\ttfamily}l>{\ttfamily}l}\toprule
214 \textnormal{\bfseries character} & \textnormal{\bfseries replacement}\\\midrule
215 ä & "a\\
216 ö & "o\\
217 ü & "u\\
218 Ä & "A\\
219 Ö & "O\\
220 Ü & "U\\
221 ß & "s\\\bottomrule
222 \end{tabular}}
223
224
225 \clearpage
226 \subsection{Technical Information}
227
228 The package uses \myverb{\inputencodingname} (set by \LaTeX\ and the |inputencoding| package)
229 to determine the current encoding.
230
231 The package redefines the \myverb{\@sanitize} macro at the begin of the
232 document. It adds some encoding redefinitions to this macro.
233 \myverb{\@sanitize} is used inside \myverb{\index} in a local group.
234 If another package (besides |babel|) also changes this macro or uses it
235 outside \myverb{\index}, strange things may happen.
236
237 If \myverb{\inputencodingname} is \emph{not} present, the package checks, if
238 the current engine is |luatex| or |xetex| and patches the \myverb{\index} macro
239 itself. All umlauts inside the argument of \myverb{\index} are replaced by their
240 |babel| shorthand codes using \LaTeX3 token replacement.
241 This increases compilation time considerably compared to the \myverb{\@sanitize} hack
242 for |pdflatex|. A very rough figure is approximately a plus of 0.8 seconds per
243 10000 \myverb{\index} calls (will differ on other maschines and other example codes).
244
245
246 \clearpage
247 \section{Application Examples}%
248
249 \tcbinputlisting{docexample,listing file=german.ist,listing only,minted style=colorful,
250 title={file |"german.ist"| for the examples}}
251
252
253 \begin{fullexample}{run arara}
254 % !TeX encoding=UTF-8
255 % arara: pdflatex
256 % arara: makeindex: { style: german.ist, german: true }
257 % arara: pdflatex
258 \documentclass[a4paper,12pt]{article}
259 \usepackage[T1]{fontenc}
260 \usepackage[ngerman]{babel}
261 \usepackage{makeidx}
262 \usepackage{sanitize-umlaut}
263 \makeindex
264 \begin{document}
265 \section{Basic Example}
266 Test äöüÄÖÜß.
267 \index{Aber} \index{Arg} \index{Ärger}
268 \index{Ofen} \index{Ö - wie schön} \index{oberhalb}
269 \index{Ufer} \index{Übermaß}
270 \index{Latex=\LaTeX} \index{Ärger>Index}
271 Test äöüÄÖÜß.
272 \printindex
273 \end{document}
274 \end{fullexample}
275
276
277 \begin{fullexample}{run arara}
278 % !TeX encoding=UTF-8
279 % arara: pdflatex
280 % arara: makeindex: { style: german.ist, german: true }
281 % arara: pdflatex
282 \documentclass[a4paper,12pt]{article}
283 \usepackage[T1]{fontenc}
284 \usepackage[ngerman]{babel}
285 \usepackage{makeidx}
286 \usepackage{sanitize-umlaut}
287 \usepackage[hyperindex,colorlinks]{hyperref}
288 \makeindex
289 \begin{document}
290 \section{Example with hyperref}
291 Test äöüÄÖÜß.
292 \index{Aber} \index{Arg} \index{Ärger}
293 \index{Ofen} \index{Ö - wie schön} \index{oberhalb}
294 \index{Ufer} \index{Übermaß}
295 \index{Latex=\LaTeX} \index{Ärger>Index}
296 Test äöüÄÖÜß.
297 \printindex
298 \end{document}
299 \end{fullexample}
300
301
302 \begin{fullexample}{run arara}
303 % !TeX encoding=UTF-8
304 % arara: pdflatex
305 \documentclass[a4paper,12pt]{article}
306 \usepackage[T1]{fontenc}
307 \usepackage[ngerman]{babel}
308 \usepackage[makeindex]{imakeidx}
309 \makeindex[options=-s german.ist -g]
310 \usepackage{sanitize-umlaut}
311 \begin{document}
312 \section{Example with imakeidx}
313 Test äöüÄÖÜß.
314 \index{Aber} \index{Arg} \index{Ärger}
315 \index{Ofen} \index{Ö - wie schön} \index{oberhalb}
316 \index{Ufer} \index{Übermaß}
317 \index{Latex=\LaTeX} \index{Ärger>Index}
318 Test äöüÄÖÜß.
319 \printindex
320 \end{document}
321 \end{fullexample}
322
323
324 \begin{fullexample}{run arara}
325 % !TeX encoding=UTF-8
326 % arara: pdflatex
327 \documentclass[a4paper,12pt]{article}
328 \usepackage[T1]{fontenc}
329 \usepackage[ngerman]{babel}
330 \usepackage[makeindex]{imakeidx}
331 \makeindex[options=-s german.ist -g]
332 \usepackage{sanitize-umlaut}
333 \usepackage[hyperindex,colorlinks]{hyperref}
334 \begin{document}
335 \section{Example with imakeidx and hyperref}
336 Test äöüÄÖÜß.
337 \index{Aber} \index{Arg} \index{Ärger}
338 \index{Ofen} \index{Ö - wie schön} \index{oberhalb}
339 \index{Ufer} \index{Übermaß}
340 \index{Latex=\LaTeX} \index{Ärger>Index}
341 Test äöüÄÖÜß.
342 \printindex
343 \end{document}
344 \end{fullexample}
345
346
347 \begin{fullexample}{run arara}
348 % !TeX encoding=UTF-8
349 % arara: pdflatex
350 \documentclass[a4paper,12pt]{article}
351 \usepackage[T1]{fontenc}
352 \usepackage[ngerman]{babel}
353 \usepackage[makeindex]{imakeidx}
354 \indexsetup{level=\section*,noclearpage}
355 \makeindex[name=personen,title=Personenregister,options=-s german.ist -g]
356 \makeindex[name=allgemein,title=Allgemeines Register,options=-s german.ist -g]
357 \usepackage{sanitize-umlaut}
358 \begin{document}
359 \section{Example with multiple indexes}
360 Test äöüÄÖÜß.
361 \index[personen]{Huber, Hans} \index[personen]{Hübner, Jörg}
362 \index[allgemein]{Aber} \index[allgemein]{Arg}
363 \index[allgemein]{Ärger} \index[allgemein]{Ofen}
364 \index[allgemein]{Ö - wie schön} \index[allgemein]{oberhalb}
365 \index[allgemein]{Ufer} \index[allgemein]{Übermaß}
366 \index[allgemein]{Latex=\LaTeX} \index[allgemein]{Ärger>Index}
367 Test äöüÄÖÜß.
368 \clearpage
369 \printindex[allgemein]
370 \printindex[personen]
371 \end{document}
372 \end{fullexample}
373
374
375 \begin{fullexample}{run arara}
376 % !TeX encoding=UTF-8
377 % arara: lualatex
378 \documentclass[a4paper,12pt]{article}
379 \usepackage{fontspec}
380 \usepackage[ngerman]{babel}
381 \usepackage[makeindex]{imakeidx}
382 \indexsetup{level=\section*,noclearpage}
383 \makeindex[name=personen,title=Personenregister,options=-s german.ist -g]
384 \makeindex[name=allgemein,title=Allgemeines Register,options=-s german.ist -g]
385 \usepackage{sanitize-umlaut}
386 \begin{document}
387 \section{Example with multiple indexes for lualatex}
388 Test äöüÄÖÜß.
389 \index[personen]{Huber, Hans} \index[personen]{Hübner, Jörg}
390 \index[allgemein]{Aber} \index[allgemein]{Arg}
391 \index[allgemein]{Ärger} \index[allgemein]{Ofen}
392 \index[allgemein]{Ö - wie schön} \index[allgemein]{oberhalb}
393 \index[allgemein]{Ufer} \index[allgemein]{Übermaß}
394 \index[allgemein]{Latex=\LaTeX} \index[allgemein]{Ärger>Index}
395 Test äöüÄÖÜß.
396 \clearpage
397 \printindex[allgemein]
398 \printindex[personen]
399 \end{document}
400 \end{fullexample}
401
402
403 \clearpage
404 \section{Nearly Drop-in Replacement by Upmendex}\label{upmendex}
405
406 The purpose of this package is to provide the missing capability of |makeindex|
407 to handle umlauts directly. As an alternative, other index processors such as
408 |xindex| or |upmendex| can be used, since they natively support UTF-8. While
409 |xindex| follows a different approach, |upmendex| is largely backward compatible
410 with |makeindex|.
411
412 To use |upmendex| as a nearly drop-in replacement for |makeindex| together with |sanitize-umlaut|,
413 the following steps are required:
414 \begin{itemize}
415 \item All |\index| macros must use direct umlauts and never the |babel| shorthands;
416 that is, always |\index{überall}| and never |\index{"überall}|.
417 \item Do not load |sanitize-umlaut|.
418 \item Do not use the |-g| option with |upmendex|, as it has a different meaning there.
419 \item Choose the desired sorting rule:
420 \begin{itemize}
421 \item DIN 5007-1 (lexical sorting, sorting |ä| like |a|) is the default.
422 In this case, the style file |german.ist| can be used as before.
423 \item DIN 5007-2 (phonebook sorting, sorting |ä| like |ae|), which is used
424 by |makeindex|. In this case, add |icu_locale "de@collation=phonebook"| to the
425 style file; see |upgerman.ist| below.
426 \end{itemize}
427 \end{itemize}
428
429
430 \medskip
431
432 \tcbinputlisting{docexample,listing file=upgerman.ist,listing only,minted style=colorful,
433 title={file |"upgerman.ist"| for upmendex}}
434
435 \medskip
436
437 Currently, |upmendex| is not as well supported as |makeindex|. The main drawbacks are:
438 \begin{itemize}
439 \item |upmendex| is not included in the list of commands allowed for
440 restricted shell execution (in \TeX Live 2025).
441 % kpsewhich -expand-var '$shell_escape_commands'
442 Therefore, invoking it from \LaTeX\ requires |-shell-escape|.
443 \item |upmendex| is not supported by |imakeidx|. The following example shows
444 how |imakeidx| can be patched to work with |upmendex|.
445 \item |upmendex| is not yet supported by |arara|. However, a local rule for
446 |upmendex| can be added, and official support is currently under consideration.
447 \end{itemize}
448
449 Within these limitations and with only minor adaptations, |makeindex| together
450 with |sanitize-umlaut| can be replaced by |upmendex|, and vice versa.
451
452 The following example demonstrates the use of a patched |imakeidx| setup with |upmendex|.
453
454 \begin{fullexample}{run arara}
455 % !TeX encoding=UTF-8
456 % arara: pdflatex: { shell: yes }
457 \documentclass[a4paper,12pt]{article}
458 \usepackage[T1]{fontenc}
459 \usepackage[ngerman]{babel}
460 \usepackage{imakeidx}
461 \makeatletter
462 \def\imki@progdefault{upmendex}% patch imakeidx
463 \def\imki@program{upmendex}% patch imakeidx
464 \makeatother
465 \indexsetup{level=\section*,noclearpage}
466 \makeindex[name=personen,title=Personenregister,options=-s upgerman.ist]
467 \makeindex[name=allgemein,title=Allgemeines Register,options=-s upgerman.ist]
468 % \usepackage{sanitize-umlaut}% do NOT use sanitize-umlaut
469 \begin{document}
470 \section{Example with multiple indexes}
471 Test äöüÄÖÜß.
472 \index[personen]{Huber, Hans} \index[personen]{Hübner, Jörg}
473 \index[allgemein]{Aber} \index[allgemein]{Arg}
474 \index[allgemein]{Ärger} \index[allgemein]{Ofen}
475 \index[allgemein]{Ö - wie schön} \index[allgemein]{oberhalb}
476 \index[allgemein]{Ufer} \index[allgemein]{Übermaß}
477 \index[allgemein]{Latex=\LaTeX} \index[allgemein]{Ärger>Index}
478 Test äöüÄÖÜß.
479 \clearpage
480 \printindex[allgemein]
481 \printindex[personen]
482 \end{document}
483 \end{fullexample}
484
485
486
487
488 \end{document}