2

Yes, I want exactly the same thing as in this question. However, I'm trying to get rid of the following three issues with repeatindex/afterpage:

  1. afterpage causes loathsome small vertical space after the second entry in the column.
  2. repeatindex does not work if index entries contain commands.
  3. My solution for the second issue works incorrectly with entries that have only subentries.

I don't know what really causes the first issue, but it's definitely afterpage. Its doc says that it does not work in two-column mode, so it kinda justifies this, but anyway... I've tried doing something like

\gdef\ResetAfterFix{\gdef\AfterFix{\ResetAfterFix}}
\ResetAfterFix
% ...
\newcommand{\metaitem}[2]{\item #1 #2\relax\AfterFix}

and then putting \gdef\AfterFix{\vskip-1234pt\ResetAfterFix} into what afterpage should output, but it seems that afterpage expands and lays out its 'aftertext' after the first couple of lines on the second page, so the \AfterFix is applied at the wrong place.

repeatindex appears to have a solution for this expansion issue (see \@entry and \@@entry) but I failed to adapt it to my case.

I don't really understand how afterpage works by delaying the output, but I also suspect its \baselineskip 'faking' in \addboxcontents as the cause of the issue.


I've circumvented the second issue by ditching the empty continuation checks from repeatindex which were expanding the contents:

% Reset afterpage contents
\long\def\ResetAfterPage#1{%
    \gdef\AP@{{#1\par}}%
    \global\output{%
        \the\AP@output
        \ifnum\outputpenalty>-\@Mi
            \global\output\expandafter{\the\AP@output}%
            \aftergroup\AP@@
        \fi
    }%
}

% This will be put at the top of the page
\gdef\index@cont{}

% Continuation label
\newcommand{\indexcont}{(\textit{cont.})}

% These commands are output by index-preparing program
\newcommand{\metaitem}[2]{%
    \item #1 #2
    \gdef\index@cont{#1\relax\ \indexcont}% Store what will be repeated
    \ResetAfterPage{}% And prevent repeating it without any following \subitems
}
\newcommand{\metasubitem}[2]{%
    \subitem #1 #2
    \ResetAfterPage{\index@cont}%
}
\newcommand{\metasubsubitem}[2]{
    \subsubitem #1 #2
    \ResetAfterPage{\index@cont}%
}

The third issue has to do with the entries like

foo
   bar, 12
   baz, 42

which result into

foo (cont.)
foo
   bar, 12
   baz, 42

if this happens at the top of the column. I believe it has to do something with afterpage again: it appears to be tricked by LaTeX into thinking that foo was left behind, but then LaTeX puts it onto the next page. However, I doubt this is a correct explanation as this happens regardless of the entry length or something, but the page numbers after the item do matter.

I've circumvented this by making the index preparer to output \ResetAfterPage{} after the first subitem of items without pages , but this is hardly an elegant solution.

Your Answer

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

Browse other questions tagged or ask your own question.