5

Although I read some postings about indices on the forum, I still have trouble with making an index in Polish. I want to have bold letters before a group connected with a single letter (like in the first picture, which was taken from another post to demonstrate my goal, also with diacritic letters - Ć, Ś). The entries should be also sorted alphabetically (like Ć comes after C)

How can I achieve that?

Here is the code, which was compiled with LuaLaTeX, and makeindex: https://www.overleaf.com/read/rnfrvvbxhfgr

I added also the second picture, which shows the current result.

The code of index is divided into two files (only a short parts, because I'm not sure that it is all):

  1. Preambuła/preambula.tex:
(...)

\usepackage{fontspec} \usepackage{polski}

(...)

\usepackage[makeindex]{imakeidx} %obsługa indeksów \makeindex[columns=2, options=-s names.mst -C utf8 -L polish]

  1. Zawartość końcowa/skorowidz.tex:
(...)

\printindex

(...)

  1. names.mst:
headings_flag 1
heading_prefix "\\textbf\{"
heading_suffix "}\\nopagebreak\n"
delim_0 ": "
delim_1 ": "
delim_2 ": "
delim_r "\\nohyperpage{-}"
  1. Example indexes with short part of text:
(... - from Rozdziały/planimetria.tex)

W dowolnym trójkącie dwusieczne\index{dwusieczna}, symetralne \index{symetralna}, środkowe\index[names]{Srodkowa@Środkowa}, wysokości\index{wysokość} przecinają się w \myuline{jednym punkcie}. (...)

Indeks

Current look

David Carlisle
  • 757,742

3 Answers3

11

You can't do it with makeindex because it cannot sort correctly other languages than English. Change to xindy.

Also polski is not compatible with LuaLaTeX, use babel.

Run with -shell-escape enabled, if you want automatic processing with xindy.

\documentclass{article}
\usepackage[polish]{babel}
\usepackage{fontspec}
\usepackage[xindy]{imakeidx}

\makeindex[columns=2, options=-C utf8 -L polish]

\begin{document}

Some text

\index{a} \index{al} \index{c} \index{ć} \index{s} \index{sa} \index{se} \index{ś}

\printindex

\end{document}

enter image description here

egreg
  • 1,121,712
  • It's a big problem, because I use \usepackage[nosingleletter]{impnattypo}, which must be in LuaLaTeX to avoid single letters... Also, I have discovered, that some options in tikzpictures are damaged...

    Example of errors (in planimetria.tex)

    Argument of \language@active@arg" has an extra }. ...aw pic["$\delta$", angle radius = 8mm, draw] Paragraph ended before \language@active@arg" was complete. ...aw pic["$\delta$", angle radius = 8mm, draw] Missing \endcsname inserted. ...aw pic["$\delta$", angle radius = 8mm, draw]

    – constantin_d Jul 14 '22 at 10:42
  • 2
    @constantin_d You can compile with LuaLaTeX, why not? – egreg Jul 14 '22 at 10:50
  • Yes, but now I'm having problems with these bugs and similar .. can I upload the project again so you can see what I did wrong? – constantin_d Jul 14 '22 at 10:51
  • 3
    There's no way around it, you'll have to use a unicode-aware package like xindy. As to preventing line breaks after single letter words etc. check out the out luavlna package. – Ingmar Jul 14 '22 at 10:56
  • @egreg We tried with Jasper your idea... Unfortunately, we still don't know, what is wrong in this case - your example works fine, but my isn't... Can You look on the current code? – constantin_d Jul 14 '22 at 14:16
  • 2
    @constantin_d Sorry, but it doesn't work like this. I'm not going to debug a huge project that takes ages even to fail and definitely not going to pay in order to get more compile time. Prepare a short example that shows the issues you have, but in a separate question, because those errors have nothing to do with the index. – egreg Jul 14 '22 at 14:22
  • @egreg Okey, sorry! – constantin_d Jul 14 '22 at 14:23
  • @egreg You have right of course about these errors, they had been solved recently, but not index... unfortunately :/ Sorry again... – constantin_d Jul 14 '22 at 14:26
  • 3
    @constantin_d You can turn shorthands off with the package option shorthands=off. – Javier Bezos Jul 14 '22 at 14:41
5

A workaround, if using xindy is an option, could be that you sort words that start with ć or ś under C and S, using something like the following approach. You can use xxx@xxx as argument of the macro \index where everything in front of @ is the sorting string, while the stuff in front of @ is the string that will be printed:

\documentclass[12pt, a4paper, openany]{book}
\usepackage[makeindex]{imakeidx}

\begin{filecontents}{names.ist} headings_flag 1 heading_prefix "{\bfseries " heading_suffix "}\nopagebreak\n" delim_0 " \dotfill " delim_1 " \dotfill " delim_2 " \dotfill " \end{filecontents}

\makeindex[columns=2, options=-s names]

\begin{document}

Foo \index{a} \index{al} \index{c} \index{czz@ć} \index{s} \index{sa} \index{se} \index{szz@ś}

\printindex

\end{document}

enter image description here

4

My personal advice is to switch to upmendex. Create a file named names.ist with

icu_locale "pl"
headings_flag 1
heading_prefix "{\\bfseries "
heading_suffix "}\\nopagebreak\n"
delim_0 " \\dotfill "
delim_1 " \\dotfill "
delim_2 " \\dotfill "

The key point here is the line icu_locale "pl". Just run

upmendex -s names <your file>.idx

Here is the example in previous answers, slightly modified. I don’t use imakeidx, so I don’t know how to deal with upmendex. This is why I run it by hand.

\documentclass{article}
\usepackage[polish]{babel}
\usepackage[noautomatic]{imakeidx}

\makeindex[columns=2]

\begin{document}

Some text

\index{a} \index{ś} \index{ć} \index{s} \index{al} \index{c} \index{sa} \index{se}

\printindex

\end{document}

As to the line breaking with single letters, babel now provides this feature. See one-letter word at the end of line .

Javier Bezos
  • 10,003
  • With combination of xindy on TeXstudio your idea works perfect... But in Overleaf there are problems with diacritic letters... Unfortunately... link – constantin_d Jul 17 '22 at 10:15