5

I am making a songbook, using the songs package. The book is in norwegian, and thus we need the norwegian letters æ,ø,å to be indexed after z. As far as i understand, this is only possible with the xindy package. Creating the index is no problem, but I want to customize how it looks. As pr. now, it looks like this:

Current layout

Using makeindex, I was able to make it look correct Correct layout

Here is the code for makeindex

\usepackage[makeindex]{imakeidx} % Normal LaTeX indexing
\makeindex[columns=1, title=Sangregister,program=makeindex,intoc=true,options=-s idxconf.ist] % Properties of index

This is for xindy

\usepackage[texindy]{imakeidx} 
\def\xindylangopt{-M lang/norwegian/latin1-test }
\makeindex[columns=1,name=master,title =Sangregister,intoc=true,options=\xindylangopt]

The layout-options, is in the file idxconf.ist, which works on makeindex looks like this

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

Is it possible to use the idxconf.ist file with xindy? If not, how do I customize xindy to look like the last picture.

Here is a minimum working example:

xindy:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[norsk]{babel}
\usepackage[texindy]{imakeidx}
\def\xindylangopt{-M lang/norwegian/latin1-test}
\makeindex[columns=1,name=xindytest,title =Sangregister,  options=\xindylangopt]
\begin{document}
start
\index{a}\index{æ}\index{ø}\index{å}
end
blabla
\printindex
\end{document}

makeindex, which looks correct, but æøå is treated as symbols.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[norsk]{babel}
\usepackage[makeindex]{imakeidx}
\makeindex[columns=1, title=Sangregister,program=makeindex,intoc=true,options=-s idxconf.ist] % Egenskaper til indeks
\begin{document}
start
\index{a}\index{æ}\index{ø}\index{å}
end
blabla
\printindex
\end{document}
lockstep
  • 250,273

3 Answers3

10

For a smilar work, in italian (songbook with songs beginning with accented letters) I used this style file (indicealfabetico.xdy)

 (markup-index :open  "\begin{theindex}\sffamily~n
 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
 \par\textbf{\large#1}\par
   \nopagebreak
  }"
          :close "~n~n\end{theindex}~n"
          :tree)


;; The indexentries (item_<..> specifiers)

(markup-indexentry :open "~n  \item "           :depth 0)
(markup-indexentry :open "~n    \subitem "     :depth 1)
(markup-indexentry :open "~n      \subsubitem " :depth 2)

;; Location-references

;; delim_0 <string>         ", "
;; delim_1 <string>         ", "
;; delim_2 <string>         ", "

(markup-locclass-list :open "\dotfill " :sep ", ")

;; delim_n <string>         ", "

(markup-locref-list   :sep ", ")

;; delim_r <string>         "--"

(markup-range :sep "--")

using xindy in this way:

% arara: xelatex: { shell : yes }
\documentclass[12pt]{book}
\usepackage{imakeidx} 
\makeindex[name=alfabetico,title=Indice alfabetico,program=truexindy,options=-M texindy -C utf8 -L italian -M indicealfabetico]

A compilable example, that works with xelatex:

% arara: xelatex: { shell : yes}
\begin{filecontents*}{style.xdy}
(markup-index :open  "\begin{theindex}\sffamily~n
 \providecommand*\lettergroupDefault[1]{}
 \providecommand*\lettergroup[1]{%
 \par\textbf{\large#1}\par
   \nopagebreak
  }"
          :close "~n~n\end{theindex}~n"
          :tree)

(markup-locclass-list :open "\dotfill " :sep ", ")
;; End
\end{filecontents*}
\documentclass{article}
\usepackage{fontspec}
\usepackage{imakeidx}
\makeindex[columns=1,title=Sangregister,program=truexindy,options=-M texindy -C utf8 -L norwegian -M style]
\begin{document}
start
\index{a}\index{æ}\index{ø}\index{å}\index{Song}
end
blabla
\printindex
\end{document}

That gives:enter image description here

6

Not entirely shure I answer your question sufficiently, but using the provided MWE I created the desired result using the "glossaries" package instead of trying to tweak "imakeidx".

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[norsk]{babel}
\usepackage[xindy]{glossaries}
\renewcommand*\glspostdescription{\dotfill}      % Dotted line to page numbers
\renewcommand*{\glsnamefont}[1]{\textnormal{#1}} % No bold font on index names

\makeglossaries

\begin{document}

\newglossaryentry{a}{name={a},description={}}
\newglossaryentry{ae}{name = {{æ}},description = {}} %Improtant to note the double curly
\newglossaryentry{oe}{name = {{ø}},description = {}} %brackets around the special caracters,
\newglossaryentry{aa}{name = {{å}},description = {}} %and only ASCII (afaik) in the handle.

start \gls{ae} \gls{aa} \gls{oe} \gls{a}
end
blabla

\printglossary[style=indexgroup, title=Sangregister]
\end{document}

This gives:

LaTeX xindy glossary result

I commented the places where I thought an explanation would be needed. I recommend reading the user documentation found here: CTAN Glossaries.

In case you're using MiKTeX, and haven't already fully installed xindy and pearl, I recommed these three posts from user Speravir:

If you're using TeXmaker (or one of its derivatives): Here's a good answer to where to add the "makeglossaries" command:

Hope this helps!

Yngve
  • 61
1

I made some minor edits to Francesco's answer.

  • I use the overwrite option for the filecontents environment so that my formatting changes are saved.

  • You don't need (markup-index ...) in the form given here, since this is the default.

  • The separator in the reference list is set by (markup-locref-list :sep "; ") and not by the :sep variable of (markup-locclass-list :open "\dotfill " :sep ", ").

  • Add a language package like polyglossia in luatex or babel in pdftex to get the local term for "see", e.g., "Sjå" in Norwegian.

So my modified version is as follows.

% !TeX program = lualatex
% !TEX encoding = UTF-8 Unicode
% !TeX spellcheck = en_NO
\begin{filecontents*}[overwrite]{style.xdy}
(markup-locclass-list :open "\dotfill ")
(markup-locref-list            :sep "; ")
\end{filecontents*}
\documentclass{article}
\usepackage{fontspec}
\usepackage[babelshorthands=true]{polyglossia}
\setdefaultlanguage{norwegian}
\usepackage[texindy]{imakeidx}
\makeindex[columns=1,title=Sangregister,options= -C utf8 -L norwegian  -M style]
\begin{document}
  a\index{a}, æ\index{æ}, ø\index{ø}, å\index{å}, Song\index{Song}\newpage
  a\index{a}, æ\index{æ}, ø\index{ø}, å\index{å}, Lied\index{Lied|see{Song}}
  \printindex
\end{document