I was getting "The control sequence at the end of the top line" referring to \leavevmodeifvmode for all my entries in an .ind file. Each entry of \indexentry in the idx file is translated to

 \item \emph  {{\textendash }\leavevmodeifvmode \kern .5em \textnormal  {something }, 11,22

in the .ind file.

Since I could not find any reference to leavevmodeifvmode I guess this relates to leavevmode@ifvmode which seems to be a new definition from 2018/12/01 Function and usage of \leavevmode.

The related lines in preamble are:


\makeindex[intoc,  name=title, title={Index: Titles}, columns=1, options=-M title  -C utf8 ]

I could fix the problem temporarily by doing something like this:

        (require "tex/inputenc/utf8.xdy")
        (require "texindy.xdy")



However, I guess there is a problem with in translating \indextermto the correct lines (whether by xindy or imakeidx ?). Is this a problem to wait for a bug fix or I wrote something wrong (sorry, not easy to make a MWE)


An MWE (I had to involve biblatex as the index is populated by biblatex, so now I think a suspect might be biblatex):

    autocite = superscript,

    author = {Knuth, Donald E.},
    year = {1986},
    title = {The \TeX book},

(require "tex/inputenc/utf8.xdy")
(require "texindy.xdy")

(require "page-ranges.xdy")
(require "book-order.xdy")
(markup-index :open  "~n
%   \makeatletter
%   \providecommand*\leavevmodeifvmode{\leavevmode@ifvmode}
%   \makeatother
    :close "~n~n\end{theindex}~n"

\makeindex[intoc,  name=title, title={Index: Titles}, columns=1, options=-M title  -C utf8 ]



                \indexfield{maintitle}%      booktitle
                \indexfield{booktitle}%      booktitle

      {\BibliographyWarning{Ignoring prenote argument}}%
      {\BibliographyWarning{Ignoring postnote argument}}}


For test \autocite{Knu86}.



Note: look at the title.ind at this line:

  \item m {}book\emph  {{\textendash }\leavevmodeifvmode \kern .5em \textnormal  {The T\kern -.1667em\lower .5ex\hbox {E}\kern -.125emX\spacefactor \m {}book}}, 1
  • Can you please make a complete example?
    – egreg
    Sep 11, 2019 at 9:03
  • @egreg, I added an MWE with some notes.
    – Shahryar
    Sep 11, 2019 at 10:27
  • @egreg in the robustness branch it works. Frank will be pleased ;-) Sep 11, 2019 at 10:59

1 Answer 1


You need to make two commands robust. They break when going through the idx:


(In a development version of latex they are already robust and your example compiles without problems).

  • Thanks for the answer.
    – Shahryar
    Sep 11, 2019 at 13:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .