1

After reading this answer https://tex.stackexchange.com/a/292362/64189, i'm trying to use it for my index.

\newcommand{\ukindex}[2][\imki@jobname]{%
  \index[#1]{\detokenize{#2}}%
}

But i need to call \ukindex with something like this

\string лінійне програмування/ZZZZ{\string \textit {див. також} \string цілочисельне лінійне програмування, 0-1 цілочисельне програмування}

Actually this was excerpt from .idx file, but i need it to be expanded.

EDIT: I add code as David asked

\documentclass{book}
\usepackage[T1, T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, ukrainian]{babel}
\usepackage[xindy]{imakeidx}
\makeindex[program=truexindy]

\makeatletter

\newcommand{\ukindex}[2][\imki@jobname]{%
  \index[#1]{\detokenize{#2}}%
}

\renewcommand{\seealso}[2]{%
  \indexas{\string#1/ZZZZ}{\string\textit{див. також} \string#2}%
}

\newcommand{\indexas}[2]{\begingroup\ukindex{#1{#2}[]}\endgroup}

\makeatother

\begin{document}

\seealso{лінійне програмування}{цілочисельне лінійне програмування, 0-1 цілочисельне
програмування}

Blablabla said Nobody 
\printindex

\end{document}
  • 1
    can't you just remove the \string from your \seealso definition? what else do you need to expand? – David Carlisle Sep 13 '16 at 16:25
  • @DavidCarlisle I think \textit. Edited: oh sorry, i think you are right. I'll check on the real file. – Yola Sep 13 '16 at 16:27
  • 1
    \texttit isn't expandable, it causes italic fonts to be selected when typesetting but it can not expand to anything useful when writing the idx file. – David Carlisle Sep 13 '16 at 16:29
  • 1
    Just remove all \string commands. – egreg Sep 13 '16 at 16:31
0

If I remove the \string commands,

\documentclass{book}
\usepackage[T1, T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english, ukrainian]{babel}
\usepackage[xindy]{imakeidx}
\makeindex[program=truexindy]

\makeatletter

\newcommand{\ukindex}[2][\imki@jobname]{%
  \index[#1]{\detokenize{#2}}%
}

\renewcommand{\seealso}[2]{%
  \indexas{#1/ZZZZ}{\textit{див. також} #2}%
}

\newcommand{\indexas}[2]{\begingroup\ukindex{#1{#2}[]}\endgroup}

\makeatother

\begin{document}

\seealso{лінійне програмування}{цілочисельне лінійне програмування, 0-1 цілочисельне
програмування}

Blablabla said Nobody 
\printindex

\end{document}

the .idx file contains

\indexentry{лінійне програмування/ZZZZ{\textit {див. також} цілочисельне лінійне програмування, 0-1 цілочисельне програмування}[]}{1}

I'm not sure this is what you want, but at least there's no strange token.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.