0

I'm trying to have dictionary like index, where some terms with different variations in text are defined. it seems this is easier with indexing. I try to have subitems of one index item on same line separated by ;

Here is a MWE:

            \documentclass{article}
            \usepackage{makeidx}
            \makeindex
            \def\igobble#1 {}
            \makeatletter
            % we don't want a page break before a subitem
            \renewcommand\subitem{\@idxitem\nobreak\hspace*{20\p@}}
            \makeatother
            \makeatletter
            % we don't want a page break before the first subitem
            \newif\iffirst@subitem
            \def\@idxitem{%
                \par\hangindent40\p@ % original
                \first@subitemtrue   % added
            }
            \def\subitem{%
            %   \par\hangindent40\p@
                \iffirst@subitem
                \nobreak
                \first@subitemfalse
                \fi
                %\hspace*{20\p@}
                }
            \makeatother


            \begin{document}

            some text\index{k} with some index entries\index{b}
            and some\index{c} \emph{see also} entries as well.
            \index{Term to define!zzzzz@\igobble |seealso {b, c}}
            \index{Term to define!\emph{Derived term} here is its definition and here is where we see it \textbf{bcd 12}}
            \index{Term to define!\emph{Anoter derived term} here is its definition and here is where we see it \textbf{bcccc 17}}
            \index{c!zzzzz@\igobble |seealso {a, b}}

            \printindex
            \end{document}

subitem macros are taken from hereHow can I prevent a column break before the first sub-entry in the index?

Here is an output. In red is what i'd like to have p. in front of page number and ; after page number

enter image description here

  • 1
    you can do this with \index{bla|scpage} where scpage is defined with \newcommand{\scpage}[1]{\textcolor{red}{p.} #1;}. What if there is more than one page? I think the best is to use a style file. – touhami Feb 08 '16 at 17:55
  • That works, but can i \scpage put it newcommand to avoid multiple writes? this: '\newcommand{\dic}[1]{\index{#1}|scpage}' and using in text \dic{Something!To Explain}has no effect...I'd prefer to use custom sty le file but dont know how :) – Levan Shoshiashvili Feb 08 '16 at 18:06
  • yes you can. your problem is \index{#1}|scpage} that should be \index{#1|scpage}} – touhami Feb 08 '16 at 18:08
  • uupps... right :) – Levan Shoshiashvili Feb 08 '16 at 18:13
  • sorry but it seems I don't understand the question, in my comment it add p. semicolon for all entries not subitems only. – touhami Feb 08 '16 at 20:37

0 Answers0