3

I would like to add the translation (in another language) of an index entry after it. After compiling the following document the index looks like

espace ....................... space, 1

I would like rather to have the following form:

espace, 1 ....................... space

How to modify the index command to achieve this? One motivation for this style is merging the index and the glossary/dictionary.

\documentclass{article}
\usepackage{makeidx}
\makeindex
\begin{document}
espace \index{espace\dotfill space}
\printindex
\end{document}
4
  • 1
    Not sure this would help readers; I'd much prefer “espace (space).....1”
    – egreg
    Sep 5, 2015 at 13:18
  • This is another .ist style of makeindex, I would assume
    – user31729
    Sep 5, 2015 at 14:31
  • @ChristianHupfer Would it be possible to elaborate the point regarding .ist style of makeindex?
    – Name
    Sep 5, 2015 at 14:41
  • @Name: makeindex uses a index style file .ist which finally determines the typesetting of the index entry. There is a bunch of such .ist files normally available under /usr/local/texlive/2015/texmf-dist/makeindex/base (please change the path of course to your actual setup). Unfortunately, I am no expert in those .ist files. And I would say, that egreg's proposition of espace(space)....1 is better, in my point of view.
    – user31729
    Sep 5, 2015 at 14:44

2 Answers 2

3

In my solution, you write index entry ordinarily \index{entry} and you can write a dictionary in the form:

\tr {espace} {space}
\tr {monde}  {world}
% ... etc.

The full example follows:

\documentclass{article}
\usepackage{makeidx}
\makeindex

\long\def\addto#1#2{\expandafter\def\expandafter#1\expandafter{#1#2}}
\addto\theindex{\catcode`\^^X=13 \endlinechar=`\^^X}
{\catcode`\^^X=13
 \gdef^^X{}
 \expandafter\gdef\csname @idxitem\endcsname#1, #2^^X{\par #1, #2%
    \leaders\hbox{\kern1pt.\kern1pt}\hfill \csname tr:#1\endcsname\par}
}
\def\indexspace{}
\catcode`\^^X=9
\def\tr #1#2{\expandafter\def\csname tr:#1\endcsname{#2}}

\tr {espace} {space}
\tr {monde}  {world}

\begin{document}
espace \index{espace}
mode \index{monde}   
\printindex
\end{document}
0
2

Here is a solution

\documentclass{article}
\usepackage{makeidx}
\makeindex
\let\mtindex\theindex
\renewcommand{\theindex}{%
\mtindex%
\let\par\empty%
\def\item##1##2{%
\ifx\mtitem\undefined\else
\dotfill\mbox{\mtitem}\endgraf
\fi
\gdef\mtitem{##2}%
\hangindent 40pt ##1}}
\let\mtendindex\endtheindex
\renewcommand{\endtheindex}{%
\dotfill\mbox{\mtitem}%
\let\par\endgraf%
\mtendindex}
\begin{document}
espace \index{{espace}{space}}
mode \index{{monde}{world}}
\newpage
espace \index{{espace}{space}}
\printindex
\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .