GeneralCase insensitive index

LaTeX specific issues not fitting into one of the other forums of this category.
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Case insensitive index

Post by NinV »

Hi,

I am very frustated :oops:

I would like a case insensitive index, i.e. the words "Entry" and "entry" should be indexed together:

Code: Select all

entry, 1,2
I tried some codes:

Code: Select all

\DeclareRobustCommand\minterm[1]{
\index{\lowercase{#1}}
#1
}

\DeclareRobustCommand\minterm[1]{
\lowercase{\index{#1}}
#1
}

\DeclareRobustCommand\minterm[1]{
\def\Term{\lowercase{#1}}%
\index{\Term}
#1
}
but they don't work!

It seems that nobody had this need: I've looked at CTAN archive, but I didn't find any help.

Any help?

Thank you very much.
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Case insensitive index

Post by NinV »

I've found a solution!

I used the package mkfirstuc (thanks Nicola Talbot!).
First I changed

Code: Select all

\def\makefirstuc#1
to

Code: Select all

\DeclareRobustCommand\makefirstuc[1]
so that I can use it in sectioning commands (\chapter, etc).

Then I duplicated \makefirstuc and \def\@gls@makefirstuc renaming them to \makefirstlc and \def\@gls@makefirstlc.

Now in the package mkfirstuc I have the commands \makefirstuc and \makefirstlc :) and I can use the code corrected by Talbot himself in http://www.latex-community.org/forum/vi ... 092#p16252 and to index a word I write

Code: Select all

\term[\makefirstlc]{Word}
Thanks to Nicola Talbot!

Ciao,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Re: Case insensitive index

Post by NinV »

It doesn't work as expected! :cry:
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Case insensitive index

Post by nlct »

Perhaps you should try it the other way around:

Code: Select all

\term[\makefirstuc]{word}
To index "word" but make "Word" appear

Regards
Nicola Talbot
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Case insensitive index

Post by NinV »

nlct wrote:Perhaps you should try it the other way around:

Code: Select all

\term[\makefirstuc]{word}
To index "word" but make "Word" appear
I've tried that, but the problem is that in the case of a text like:
[page1]
.....
This \term[\makefirstuc]{entry} should be
[pag2]
added to \term{entry} .............
I get:
entry, 1
entry, 2
and not
entry, 1, 2
I'll try this other way around:

Code: Select all

\makefirstuc{\term{word}}
after that I'll try xindy instead of makeindex.

Thanks for your help.

Ciao,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Case insensitive index

Post by nlct »

NinV wrote: I'll try this other way around:

Code: Select all

\makefirstuc{\term{word}}
That won't work as it's equivalent to

Code: Select all

\term{\MakeUppercase{w}ord}
The following works fine for me:

Code: Select all

\documentclass{article}

\usepackage{datatool}
\usepackage{mfirstuc}
\usepackage{makeidx}

\makeindex

\DeclareRobustCommand\term[2][]{%
\def\Term{#2}%
\DTLsplitstring{#2}{-}{\before}{\after}
\ifx\before\Term
  #1{#2}\index{#2}
\else
  #1{#2}\index{\after @#2}
\fi
}

\begin{document}

\term[\makefirstuc]{word}

\newpage

\term{word}

\printindex

\end{document}
Regards
Nicola Talbot
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Case insensitive index

Post by NinV »

Yes, that doesn't work:

Code: Select all

\makefirstuc{\term{word}}
and I failed to compile xindy on Ubuntu :cry:

Your last code works for me, too. But I was trying to unifying the command for indexing "-word" and the one indexing "words" and "Words", as option, as one same entry. :)

But it seems too difficult for me... a beginner!

Thanks,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
User avatar
nlct
Posts: 276
Joined: Thu Nov 06, 2008 11:15 am

Case insensitive index

Post by nlct »

How about

Code: Select all

\DeclareRobustCommand\term[2][]{%
\def\Term{#2}%
\DTLsplitstring{#2}{-}{\before}{\after}%
\ifx\before\Term
  #1{#2}\index{#2}%
\else
  \ifx\makefirstuc#1\relax
    \before-\xmakefirstuc{\after}%
  \else
    #1{#2}%
  \fi
  \index{\after @#2}%
\fi
}
Regards
Nicola Talbot
phi
Posts: 577
Joined: Tue Oct 21, 2008 8:10 pm

Case insensitive index

Post by phi »

NinV wrote:and I failed to compile xindy on Ubuntu :cry:

Code: Select all

sudo apt-get install xindy
NinV
Posts: 69
Joined: Sun Oct 05, 2008 12:57 pm

Case insensitive index

Post by NinV »

Thanks, nict!

I've modified a little bit your code:

Code: Select all

\DeclareRobustCommand\term[2][]{%
    \def\Term{#2}%
    \DTLsplitstring{#2}{-}{\before}{\after}%
    \ifx#1M 
     \ifx\before\Term
      \makefirstuc{#2}\index{#2}
     \else
      \makefirstuc{#2}\index{\after @#2}
     \fi
    \else%
     \ifx#1T
      \ifx\before\Term
       \makefirstuc{#2}\index{#2}%
      \else
        \before-\xmakefirstuc{\after}%
      \index{\after @#2}%
     \fi
    \else%
     \ifx\before\Term
      #2\index{#2}
     \else
      #2\index{\after @#2}
     \fi
    \fi
   \fi
  \fi
}
now it seems to work as I like and I can add more options!

Can I discuss with you some changes I'd like to do to your glossaries.sty?

Ciao,
Nino
Window + MiKTeX 2.7
Ubuntu + TexLive + Kile
Xandros (eeePC) + TeTex + TexMaker
Post Reply