[OS X TeX] Entering specially formatted items in the index

Morten Høgholm morten.hoegholm at gmail.com
Wed Aug 23 00:45:50 CEST 2006


On Wed, 23 Aug 2006 00:31:03 +0200, Alain Schremmer  
<Schremmer.Alain at gmail.com> wrote:


>>
>> Assuming the definition
>>   \newcommand*\DEKA{\ensuremath{\denom{D\mathsmaller{EKA}}}}
>> you should be able to get by with just
>>   \index{DEKA@\DEKA}
>
> Would there be a way other than entering one definition for each metric  
> prefix?

You could do something like this (entirely untested):

\newcommand*\DefineMetricPrefix[1]{%
   \expandafter\@ifdefineable\csname #1\endcsname{%
     \DefineMetricPrefix at aux#1\@nil
   }

}
\def\DefineMetricPrefix at aux#1#2\@nil{%
   \expandafter\DeclareRobustCommand \csname#1#2\endcsname{%
     \ensuremath{#1\mathsmaller{#2}}%
   }%
   \expandafter\protected at edef\csname index#1#2\endcsname{%
     \noexpand\index{#1@\expandafter\noexpand\csname #1#2\endcsname}}%
}

\DefineMetricPrefix{DEKA} then defines
   \DEKA -> \ensuremath{D\mathsmaller{EKA}}
and
   \indexDEKA -> \index{DEKA@\DEKA}
-- 
Morten
------------------------- Info --------------------------
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/
          & FAQ: http://latex.yauh.de/faq/
TeX FAQ: http://www.tex.ac.uk/faq
List Archive: http://tug.org/pipermail/macostex-archives/




More information about the macostex-archives mailing list