5

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.

1 Answer 1

1

I couldn't get afterpage to work for me. To solve this problem I wound up using a combination of hand work and software.

Let's suppose I have an item ITEM with subitem SUB6 and the bottom of one column and SUB7 at the top of the next. I need to insert a continuation between them.

  1. In a file containing a list of continuations, I add an index entry in the position where I want the continuation. For example,

    \index{ITEM!SUB61}
    
  2. These entries get run through a program that takes the last item in the list and replaces the "actual" text with the continuation and adds the page number CCC. For example,

    \index{ITEM!SUB61}
    

    becomes

    \indexentry {ITEM!SUB61@z{\par\penalty-9000 \item ITEM (continued)}}{CCC}
    

    And

    \index{ITE}
    

    becomes

    \indexentry {ITE@z{\par\penalty-9000}}{CCC}
    

    And

    \index{ITEM!SUB12!SUBSUB97}
    

    becomes

    \indexentry {ITEM!SUB12+SUBSUB97@z{\par\penalty-9000\item ITEM (continued) \subitem SUB12 (continued)}}{CCC}
    

    The \indexentry lines get added to the document's idx file.

  3. Run makeindex with the -s wide.ist option, which adds this style option:

    line_max 2000
    
  4. Postprocess the resulting .ind file to find all lines with page CCC, strip off the page and the initial control sequence, and include just what's between the matching braces z{...}.

The process is tedious because every time a new continuation is added to the list, the positions of all subsequent items change. But for a two-column, 27-page index I was able to get it all done in less than an hour. And the results are perfect.

You must log in to answer this question.

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