I would like to include \allowbreak in an \index entry but I can't get it to work. The \allowbreak is changed to \penalty \z@ in the .idx file, which corrupts the generated index.

How can I solve this?

  • \protect\allowbreak? – egreg Jul 28 '15 at 21:02
  • 1
    A small working example code would be helpful and instructive. – Steven B. Segletes Jul 28 '15 at 21:02

You are probably calling \index in the argument to another command; here's an emulation:



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}}



This produces the following .idx file

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

The same problem with \allowbreak turned into \penalty \z@ would happen if you have something like


and do

\indexword{abc\allowbreak def}

Using \protect\allowbreak will do also in this case. However, sorting of index entries with \allowbreak in them will probably give wrong results.

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.