TransWikia.com

Conflict between exerquiz and animate: no preview

TeX - LaTeX Asked by JPG on February 23, 2021

Since my last update of Texlive, I have conflict when loading animate and exerquiz in the same document: the document compiles, the animation plays well in Acrobat, but when I open the pdf with another reader (evince, okular,…) that do not support animations, I have only a white rectangle in place of my animation, instead of the first frame.

MWE:

documentclass{standalone} 
usepackage{animate}
%usepackage{exerquiz} % uncomment this line and the animation preview disappear

begin{document}

Watch this counter:begin{animateinline}[loop,autoplay,poster=0,controls]{2}
    multiframe{10}{in=0+1}{%
        fbox{in}
    }
end{animateinline}

end{document}

When I compile this MWE, and open it in evince, I see the counter 0 in the fbox, and the controls beneath.

When I uncomment the usepackage{exerquiz} line and compile this MWE, and open it with evince, I see nothing except "Watch this counter:"; but in Acrobat the animation still plays.

This did not happen before I updated Texlive; I always saw the first frame in evince. How can I restore the old behaviour?

One Answer

At some point in the loading chain of packages, hyperref is invoked in a way that puts the key /NeedAppearances true in the AcroForm dictionary of the PDF Catalog. NeedAppearances is declared deprecated in the current ISO PDF-2.0 standard.

Also, animate and hyperref concurrently want to write the Fields entry in the AcroForm dictionary, if hyperref's Form environment is set (implicitly done by exerquiz).

The following fix suppresses NeedAppearances in the PDF output and hooks into hyperref's mechanism of Form field registration:

documentclass{standalone} 

usepackage{animate}
usepackage{exerquiz}

begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Fix compatibility with hyperref Forms %%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ExplSyntaxOn
makeatletter
% suppress deprecated /NeedAppearances true|false
HyField@NeedAppearancesfalse
% hook into hyperref's Form Field registration
cs_set_protected_nopar:Nnpbs_appendtofields:n{
  tl_gput_left:NxHyField@afields{#1space}
}
makeatother
ExplSyntaxOff
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Watch this counter:begin{animateinline}[loop,autoplay,controls]{2}
    multiframe{10}{in=0+1}{%
        fbox{in}
    }
end{animateinline}

end{document}

Correct answer by AlexG on February 23, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP