\allowbreakは\indexでは機能しません

\allowbreakは\indexでは機能しません

\allowbreakエントリに含めたいのです\indexが、うまくいきません。 が.idx ファイルで\allowbreakに変更され\penalty \z@、生成されたインデックスが破損します。

これをどうすれば解決できますか?

答え1

おそらく\index別のコマンドの引数を呼び出しているのでしょう。以下にエミュレーションを示します。

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

\begin{document}

a\index{abcdef@abc\allowbreak def}

% now do the call in the argument of a command
\textbf{g\index{ghijkl@ghi\allowbreak jkl}}

% now use the proper input
\textbf{m\index{mnopqr@mno\protect\allowbreak pqr}}

\printindex

\end{document}

これにより、次の.idxファイルが生成されます。

\indexentry{abcdef@abc\allowbreak def}{1}
\indexentry{ghijkl@ghi\penalty \z@ jkl}{1}
\indexentry{mnopqr@mno\allowbreak pqr}{1}

\allowbreak次のような場合にも、同じ問題が\penalty \z@発生します。

\newcommand{\indexword}[1]{#1\index{#1}}

そして、やります

\indexword{abc\allowbreak def}

\protect\allowbreakこの場合も を使用できます。ただし、\allowbreakその中のインデックス エントリを並べ替えると、間違った結果になる可能性があります。

関連情報