
我想包含\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
可能會給出錯誤的結果。