I was editing a text that carries a watermark and decided to add an index. Everything was going fine until at some point an error message came out. After debugging I could identify the issue.
There is some incompatibility between packages imakeidx and xwatermark when more than one page with indexes are presented, but not always. I mean, it seems to have a certain event, which I don't know, that returns an error when there is more than one index page AND a certain number of indexes. I must say this because sometimes there are two index pages and no error appears.
The erro mensage is something like:
Something's wrong--perhaps a missing \item. {\bf P
I checked the lines of the generated .ind file and nothing seemed to be wrong. All blocks follow the same structure.
\indexspace {\bf P}\nopagebreak% \indexspace\nopagebreak% \item p, \hyperpage{1} If I change the number of columns to more than one, it won't have any error since all indexes fit in only one page. That's a nice workaround, but not a general solution. Another workaround is to prevent the watermark to be printed over index pages, by changing allpages for something like pages=1-3.
The following MWE reproduces the problem.
\documentclass{article} \usepackage{imakeidx} \makeindex[columns=1, options=-s style_file_imakeidx_alfa_01.ist] % columns=2 works fine, since it doesn't need more than one page \usepackage{tikz} \usepackage[printwatermark]{xwatermark} \newsavebox\myboxr\savebox\myboxr{\tikz[color=red!80,opacity=0.4]\node{\huge{Watermark}};} \newwatermark[allpages, angle=45, scale=6, xpos=-10, ypos=10]{\usebox\myboxr} % Another workaround: Don't print wateermark over index. Example: allpages <-> pages=1-3. \begin{document} Text. \clearpage a\index{a} \clearpage b\index{b} c\index{c} d\index{d} e\index{e} f\index{f} g\index{g} h\index{h} i\index{i} j\index{j} k\index{k} l\index{l} m\index{m} n\index{n} o\index{o} After letter p, if columns = 1, error. % Something's wrong--perhaps a missing \item. {\bf P % (Un)comment these lines to change from error/no error when columns = 1 p\index{p} q\index{q} r\index{r} \printindex \end{document} This is the file style_file_imakeidx_alfa_01.ist to generate the formatted index list (I don't if this setup contributes to the error).
quote '+' headings_flag 1 symhead_positive "Symbol" numhead_positive "Number" heading_prefix "{\\bf " heading_suffix "}\\nopagebreak%\n \\indexspace\\nopagebreak%" delim_r "~--~" suffix_2p "\\,f" suffix_3p "\\,ff" preamble "\\markright{Index}\n\n\\begin{theindex}\n\\thispagestyle{headings}\n" postamble "\n\n\\end{theindex}\n" Of course I can continue working with or watermark or printindex, but not both at the same time, or even limiting the pages with watermark.
The question is: know what is going on and how to correct it? If possible.


draftwatermarkinstead.